From fbee490c2b6ae68309cff34cfb2aeb818369092d Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:30:04 -0600 Subject: [PATCH 1/6] feat: re-run build_curls script --- .../create-carrier-curls/canadapost-wallet.sh | 10 ++ .../guides/create-carrier-curls/canadapost.sh | 8 +- .../guides/create-carrier-curls/daipost.sh | 1 + .../create-carrier-curls/deutschepostuk.sh | 10 +- .../guides/create-carrier-curls/dhlecs.sh | 6 +- .../guides/create-carrier-curls/dhlexpress.sh | 4 +- .../guides/create-carrier-curls/glsgroup.sh | 19 +++ .../guides/create-carrier-curls/gofowallet.sh | 12 ++ .../guides/create-carrier-curls/logissimo.sh | 8 +- official/guides/create-carrier-curls/tipsa.sh | 14 ++ .../upsmailinnovations.sh | 2 +- .../guides/create-carrier-curls/vehowallet.sh | 12 ++ .../build_curls.py | 133 ++++-------------- .../carrier_builder_data.py | 49 +++++++ .../carrier_builder_payloads.py | 71 ++++++++++ 15 files changed, 246 insertions(+), 113 deletions(-) create mode 100644 official/guides/create-carrier-curls/canadapost-wallet.sh create mode 100644 official/guides/create-carrier-curls/glsgroup.sh create mode 100644 official/guides/create-carrier-curls/gofowallet.sh create mode 100644 official/guides/create-carrier-curls/tipsa.sh create mode 100644 official/guides/create-carrier-curls/vehowallet.sh create mode 100644 tools/build_create_carrier_curl_requests/carrier_builder_data.py create mode 100644 tools/build_create_carrier_curl_requests/carrier_builder_payloads.py diff --git a/official/guides/create-carrier-curls/canadapost-wallet.sh b/official/guides/create-carrier-curls/canadapost-wallet.sh new file mode 100644 index 00000000..b476b3ed --- /dev/null +++ b/official/guides/create-carrier-curls/canadapost-wallet.sh @@ -0,0 +1,10 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "CanadaPostAccount", + "description": "CanadaPostAccount", + "payment_mode": "aggregation" + } +}' diff --git a/official/guides/create-carrier-curls/canadapost.sh b/official/guides/create-carrier-curls/canadapost.sh index 84da76ec..05613fe8 100644 --- a/official/guides/create-carrier-curls/canadapost.sh +++ b/official/guides/create-carrier-curls/canadapost.sh @@ -10,14 +10,18 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "contract_id": "VALUE", "customer_number": "VALUE", "has_credit_card": "VALUE", - "not_platform": "VALUE" + "not_platform": "VALUE", + "zonos_api_key": "VALUE", + "zonos_enabled": "VALUE" }, "test_credentials": { "api_key": "VALUE", "contract_id": "VALUE", "customer_number": "VALUE", "has_credit_card": "VALUE", - "not_platform": "VALUE" + "not_platform": "VALUE", + "zonos_api_key": "VALUE", + "zonos_enabled": "VALUE" } } }' diff --git a/official/guides/create-carrier-curls/daipost.sh b/official/guides/create-carrier-curls/daipost.sh index 30af80c6..8a3c6b51 100644 --- a/official/guides/create-carrier-curls/daipost.sh +++ b/official/guides/create-carrier-curls/daipost.sh @@ -7,6 +7,7 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "description": "DaiPostAccount", "credentials": { "account_code": "VALUE", + "api_key": "VALUE", "origin_terminal": "VALUE", "password": "VALUE", "username": "VALUE" diff --git a/official/guides/create-carrier-curls/deutschepostuk.sh b/official/guides/create-carrier-curls/deutschepostuk.sh index f2fc94d2..eed511f7 100644 --- a/official/guides/create-carrier-curls/deutschepostuk.sh +++ b/official/guides/create-carrier-curls/deutschepostuk.sh @@ -7,13 +7,19 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "description": "DeutschePostUKAccount", "credentials": { "account_number": "VALUE", + "api_key": "VALUE", "client_id": "VALUE", - "client_secret": "VALUE" + "client_secret": "VALUE", + "customer_identification": "VALUE", + "customer_pricing_reference": "VALUE" }, "test_credentials": { "account_number": "VALUE", + "api_key": "VALUE", "client_id": "VALUE", - "client_secret": "VALUE" + "client_secret": "VALUE", + "customer_identification": "VALUE", + "customer_pricing_reference": "VALUE" } } }' diff --git a/official/guides/create-carrier-curls/dhlecs.sh b/official/guides/create-carrier-curls/dhlecs.sh index fe4e0a5d..3aac9c5f 100644 --- a/official/guides/create-carrier-curls/dhlecs.sh +++ b/official/guides/create-carrier-curls/dhlecs.sh @@ -8,12 +8,14 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "credentials": { "client_id": "VALUE", "client_secret": "VALUE", - "distribution_center": "VALUE" + "distribution_center": "VALUE", + "pickup_id": "VALUE" }, "test_credentials": { "client_id": "VALUE", "client_secret": "VALUE", - "distribution_center": "VALUE" + "distribution_center": "VALUE", + "pickup_id": "VALUE" } } }' diff --git a/official/guides/create-carrier-curls/dhlexpress.sh b/official/guides/create-carrier-curls/dhlexpress.sh index 2132d8cd..2d21f40c 100644 --- a/official/guides/create-carrier-curls/dhlexpress.sh +++ b/official/guides/create-carrier-curls/dhlexpress.sh @@ -10,7 +10,9 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "country": "VALUE", "is_reseller": "VALUE", "password": "VALUE", - "site_id": "VALUE" + "site_id": "VALUE", + "zonos_api_key": "VALUE", + "zonos_enabled": "VALUE" } } }' diff --git a/official/guides/create-carrier-curls/glsgroup.sh b/official/guides/create-carrier-curls/glsgroup.sh new file mode 100644 index 00000000..6088b2dc --- /dev/null +++ b/official/guides/create-carrier-curls/glsgroup.sh @@ -0,0 +1,19 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "GlsGroupAccount", + "description": "GlsGroupAccount", + "credentials": { + "client_id": "VALUE", + "client_secret": "VALUE", + "contact_id": "VALUE" + }, + "test_credentials": { + "client_id": "VALUE", + "client_secret": "VALUE", + "contact_id": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/gofowallet.sh b/official/guides/create-carrier-curls/gofowallet.sh new file mode 100644 index 00000000..e6712753 --- /dev/null +++ b/official/guides/create-carrier-curls/gofowallet.sh @@ -0,0 +1,12 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "GofoWalletAccount", + "description": "GofoWalletAccount", + "credentials": { + "origin_hub": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/logissimo.sh b/official/guides/create-carrier-curls/logissimo.sh index f7fb8412..da38cc90 100644 --- a/official/guides/create-carrier-curls/logissimo.sh +++ b/official/guides/create-carrier-curls/logissimo.sh @@ -10,14 +10,18 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ "api_username": "VALUE", "client_id": "VALUE", "password": "VALUE", - "shipper_account_number": "VALUE" + "shipper_account_number": "VALUE", + "track_client_id": "VALUE", + "track_client_secret": "VALUE" }, "test_credentials": { "api_key": "VALUE", "api_username": "VALUE", "client_id": "VALUE", "password": "VALUE", - "shipper_account_number": "VALUE" + "shipper_account_number": "VALUE", + "track_client_id": "VALUE", + "track_client_secret": "VALUE" } } }' diff --git a/official/guides/create-carrier-curls/tipsa.sh b/official/guides/create-carrier-curls/tipsa.sh new file mode 100644 index 00000000..6275b761 --- /dev/null +++ b/official/guides/create-carrier-curls/tipsa.sh @@ -0,0 +1,14 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "TipsaAccount", + "description": "TipsaAccount", + "credentials": { + "agency_code": "VALUE", + "customer_code": "VALUE", + "password": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/upsmailinnovations.sh b/official/guides/create-carrier-curls/upsmailinnovations.sh index d963e9cd..dd9c5523 100644 --- a/official/guides/create-carrier-curls/upsmailinnovations.sh +++ b/official/guides/create-carrier-curls/upsmailinnovations.sh @@ -1,4 +1,4 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ +curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth \ -u "$EASYPOST_API_KEY": \ -H 'Content-Type: application/json' \ -d '{ diff --git a/official/guides/create-carrier-curls/vehowallet.sh b/official/guides/create-carrier-curls/vehowallet.sh new file mode 100644 index 00000000..5b78a22e --- /dev/null +++ b/official/guides/create-carrier-curls/vehowallet.sh @@ -0,0 +1,12 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "VehoWalletAccount", + "description": "VehoWalletAccount", + "credentials": { + "agreed_to_terms_at": "VALUE" + } + } +}' diff --git a/tools/build_create_carrier_curl_requests/build_curls.py b/tools/build_create_carrier_curl_requests/build_curls.py index be03d670..0d8e668e 100644 --- a/tools/build_create_carrier_curl_requests/build_curls.py +++ b/tools/build_create_carrier_curl_requests/build_curls.py @@ -3,9 +3,10 @@ import os import re +import carrier_builder_data +import carrier_builder_payloads import easypost - # Builds a file containing every create a Carrier Account cURL request via EasyPost # USAGE: EASYPOST_PROD_API_KEY=123... venv/bin/python build_curls.py @@ -14,27 +15,6 @@ END_CHARS = "\n" CUSTOM_WORKFLOW_CHARS = "## REQUIRES CUSTOM WORKFLOW ##\n" -FEDEX_CUSTOM_WORKFLOW_CARRIERS = [ - "FedexAccount", - "FedexSmartpostAccount", -] -UPS_CUSTOM_WORKFLOW_CARRIERS = [ - "UpsDapAccount", -] -OAUTH_CUSTOM_WORKFLOW_CARRIERS = [ - "AmazonShippingAccount", - "UpsAccount" -] -MAERSK_CUSTOM_WORKFLOW_CARRIERS = [ - "MaerskAccount" -] -DOORDASH_CUSTOM_WORKFLOW_CARRIERS = [ - "DoorDashAccount" -] -WALLET_CARRIERS = [ - "CanadaPostAccount", - "DhlEcsAccount", -] def main(): carrier_types = get_carrier_types() @@ -45,7 +25,7 @@ def main(): os.makedirs(output_destination) with open( - os.path.join(output_destination, f'{carrier["type"].lower().replace("account", "")}.sh'), + os.path.join(output_destination, f"{carrier['type'].lower().replace('account', '')}.sh"), "w", ) as carrier_curl_file: carrier_curl_file.write(re.sub(r"^.*?\n", "", curl_request)) @@ -61,7 +41,7 @@ def get_carrier_types(): def build_carrier_curl_request(carrier): """Builds a single cURL request for a carrier via EasyPost.""" - carrier_output = f'# {carrier.get("type")}\n' + carrier_output = f"# {carrier.get('type')}\n" carrier_output = add_curl_line(carrier_output, carrier) carrier_output = add_headers(carrier_output, carrier) carrier_output = add_credential_structure(carrier_output, carrier) @@ -71,16 +51,21 @@ def build_carrier_curl_request(carrier): def add_curl_line(carrier_output: str, carrier: dict[str, str]) -> str: """Add curl command and registration url.""" - if carrier["type"] in (FEDEX_CUSTOM_WORKFLOW_CARRIERS + UPS_CUSTOM_WORKFLOW_CARRIERS): - carrier_output += f"curl -X POST https://api.easypost.com/v2/carrier_accounts/register{LINE_BREAK_CHARS}" - elif carrier["type"] in OAUTH_CUSTOM_WORKFLOW_CARRIERS: - carrier_output += f"curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth{LINE_BREAK_CHARS}" - else: - carrier_output += f"curl -X POST https://api.easypost.com/v2/carrier_accounts{LINE_BREAK_CHARS}" + endpoint = get_create_endpoint(carrier["type"]) + carrier_output += f"curl -X POST https://api.easypost.com/{endpoint}{LINE_BREAK_CHARS}" return carrier_output +def get_create_endpoint(carrier_type: str) -> str: + """Resolve create endpoint for a carrier account type.""" + for endpoint, carrier_types in carrier_builder_data.CARRIER_CREATE_ENDPOINT_OVERRIDES.items(): + if carrier_type in carrier_types: + return endpoint + + return carrier_builder_data.DEFAULT_CREATE_ENDPOINT + + def add_headers(carrier_output: str, carrier: dict[str, str]) -> str: """Add necessry headers and authentication.""" carrier_output += f' -u "$EASYPOST_API_KEY":{LINE_BREAK_CHARS}' @@ -96,7 +81,7 @@ def write_wallet_curl(carrier: dict[str, str], carrier_account_json: dict) -> No wallet_account.pop("credentials", None) wallet_account.pop("test_credentials", None) wallet_account["payment_mode"] = "aggregation" - wallet_output = f'# {carrier.get("type")} (EasyPost Wallet)\n' + wallet_output = f"# {carrier.get('type')} (EasyPost Wallet)\n" wallet_output = add_curl_line(wallet_output, carrier) wallet_output = add_headers(wallet_output, carrier) wallet_output += f" -d '{json.dumps(wallet_json, indent=2)}'" @@ -133,7 +118,7 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st carrier_fields = carrier.get("fields").to_dict() # FedEx - if carrier["type"] in FEDEX_CUSTOM_WORKFLOW_CARRIERS: + if carrier["type"] in carrier_builder_data.FEDEX_CUSTOM_WORKFLOW_CARRIERS: carrier_account_json["carrier_account"]["registration_data"] = {} for category in carrier_fields["creation_fields"]: for item in carrier_fields["creation_fields"][category]: @@ -143,36 +128,9 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st carrier_output += END_CHARS carrier_output = carrier_output.replace(f"{LINE_BREAK_CHARS}{END_CHARS}", f"{END_CHARS}") # Maersk Parcel — custom static credential structure - elif carrier["type"] in MAERSK_CUSTOM_WORKFLOW_CARRIERS: - carrier_account_json = { - "carrier_account": { - "type": "MaerskAccount", - "description": "Maersk Account", - "reference": None, - "credentials": { - "first_name": "VALUE", - "last_name": "VALUE", - "company_name": "VALUE", - "email": "VALUE", - "phone": "VALUE", - "daily_number_of_shipments": "VALUE", - "channel": "VALUE", - "accepted_terms": "true", - "serial_number": "VALUE", - "origin_address_line_1": "VALUE", - "origin_address_line_2": "VALUE", - "origin_postal_code": "VALUE", - "origin_city": "VALUE", - "origin_state": "VALUE", - "billing_address_line_1": "VALUE", - "billing_address_line_2": "VALUE", - "billing_postal_code": "VALUE", - "billing_city": "VALUE", - "billing_state": "VALUE" - }, - "test_credentials": {} - } - } + # TODO: Why is this static? It should be exposed via carrier types endpoint + elif carrier["type"] in carrier_builder_data.MAERSK_CUSTOM_WORKFLOW_CARRIERS: + carrier_account_json = carrier_builder_payloads.maersk_account_payload() carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" carrier_output += END_CHARS @@ -180,48 +138,19 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st return carrier_output # UPS OAuth elif carrier["type"] == "UpsAccount": - carrier_account_json = { - "carrier_account_oauth_registrations": { - "type": "UpsAccount", - "account_number": "CUSTOMER UPS ACCOUNT NUMBER", - "description": "CUSTOMER ACCOUNT DESCRIPTION (optional)", - "reference": "UNIQUE ACCOUNT REFERENCE (optional)", - "return_to_url": "https://example.com (optional)" - } - } + carrier_account_json = carrier_builder_payloads.ups_oauth_registration_payload() carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" carrier_output += END_CHARS return carrier_output # Amazon Shipping - elif carrier["type"] in OAUTH_CUSTOM_WORKFLOW_CARRIERS: - carrier_account_json = { - "carrier_account_oauth_registrations": { - "type": "AmazonShippingAccount", - "description": "My Shipping Account (optional)", - "reference": "Internal reference id (optional)", - "return_to_url": "https://example.com (optional)", - "credentials": { - "account_type": "shipper", - "account_country": "US" - } - } - } + elif carrier["type"] in carrier_builder_data.OAUTH_CUSTOM_WORKFLOW_CARRIERS: + carrier_account_json = carrier_builder_payloads.amazon_shipping_oauth_registration_payload() carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" carrier_output += END_CHARS # DoorDash - elif carrier["type"] in DOORDASH_CUSTOM_WORKFLOW_CARRIERS: - carrier_account_json = { - "billToEasyPost": False, - "credentials": { - "developer_id": "VALUE", - "key_id": "VALUE", - "signing_secret": "VALUE", - "pickup_external_business_id": "VALUE" - }, - "test_credentials": {}, - "type": "DoorDashAccount" - } + elif carrier["type"] in carrier_builder_data.DOORDASH_CUSTOM_WORKFLOW_CARRIERS: + carrier_account_json = carrier_builder_payloads.doordash_account_payload() carrier_output = ( "# DoorDashAccount\n" @@ -229,10 +158,7 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st "-H 'Content-Type: application/json' " "-H 'X-EasyPost-User-Id: ' " "https://api.easypost.com/v2/carrier_accounts " - "-d '" - + json.dumps(carrier_account_json, indent=2) - + "'" - + END_CHARS + "-d '" + json.dumps(carrier_account_json, indent=2) + "'" + END_CHARS ) return carrier_output # Normal carriers @@ -252,22 +178,23 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st top_level_carrier_fields = carrier_fields[top_level] for item in top_level_carrier_fields: - if (carrier_account_json["carrier_account"].get(top_level)is None): + if carrier_account_json["carrier_account"].get(top_level) is None: carrier_account_json["carrier_account"][top_level] = {} carrier_account_json["carrier_account"][top_level][item] = "VALUE" - carrier_output += (f" -d '{json.dumps(carrier_account_json, indent=2)}'") + carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" carrier_output += end carrier_output = carrier_output.replace( f"{LINE_BREAK_CHARS}{END_CHARS}", END_CHARS, ) - if carrier["type"] in WALLET_CARRIERS: + if carrier["type"] in carrier_builder_data.WALLET_CARRIERS: write_wallet_curl(carrier, carrier_account_json) return carrier_output + if __name__ == "__main__": main() diff --git a/tools/build_create_carrier_curl_requests/carrier_builder_data.py b/tools/build_create_carrier_curl_requests/carrier_builder_data.py new file mode 100644 index 00000000..53d7d7e5 --- /dev/null +++ b/tools/build_create_carrier_curl_requests/carrier_builder_data.py @@ -0,0 +1,49 @@ +DEFAULT_CREATE_ENDPOINT = "v2/carrier_accounts" + +# Keep this focused on endpoint selection; payload one-offs are handled separately. +CARRIER_CREATE_ENDPOINT_OVERRIDES = { + "v2/carrier_accounts/open": { + "GofoWalletAccount", + "UniUniWalletAccount", + "VehoWalletAccount", + }, + "v2/carrier_accounts/register": { + "FedexAccount", + "FedexSmartpostAccount", + "UpsDapAccount", + }, + "v2/carrier_accounts/register_oauth": { + "AmazonShippingAccount", + "UpsAccount", + "UpsMailInnovationsAccount", + "UpsSurepostAccount", + "UspsShipAccount", + }, +} + +FEDEX_CUSTOM_WORKFLOW_CARRIERS = [ + "FedexAccount", + "FedexSmartpostAccount", +] + +UPS_CUSTOM_WORKFLOW_CARRIERS = [ + "UpsDapAccount", +] + +OAUTH_CUSTOM_WORKFLOW_CARRIERS = [ + "AmazonShippingAccount", + "UpsAccount", +] + +MAERSK_CUSTOM_WORKFLOW_CARRIERS = [ + "MaerskAccount", +] + +DOORDASH_CUSTOM_WORKFLOW_CARRIERS = [ + "DoorDashAccount", +] + +WALLET_CARRIERS = [ + "CanadaPostAccount", + "DhlEcsAccount", +] diff --git a/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py b/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py new file mode 100644 index 00000000..c95ee746 --- /dev/null +++ b/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py @@ -0,0 +1,71 @@ +def maersk_account_payload() -> dict: + return { + "carrier_account": { + "type": "MaerskAccount", + "description": "Maersk Account", + "reference": None, + "credentials": { + "first_name": "VALUE", + "last_name": "VALUE", + "company_name": "VALUE", + "email": "VALUE", + "phone": "VALUE", + "daily_number_of_shipments": "VALUE", + "channel": "VALUE", + "accepted_terms": "true", + "serial_number": "VALUE", + "origin_address_line_1": "VALUE", + "origin_address_line_2": "VALUE", + "origin_postal_code": "VALUE", + "origin_city": "VALUE", + "origin_state": "VALUE", + "billing_address_line_1": "VALUE", + "billing_address_line_2": "VALUE", + "billing_postal_code": "VALUE", + "billing_city": "VALUE", + "billing_state": "VALUE", + }, + "test_credentials": {}, + } + } + + +def ups_oauth_registration_payload() -> dict: + return { + "carrier_account_oauth_registrations": { + "type": "UpsAccount", + "account_number": "CUSTOMER UPS ACCOUNT NUMBER", + "description": "CUSTOMER ACCOUNT DESCRIPTION (optional)", + "reference": "UNIQUE ACCOUNT REFERENCE (optional)", + "return_to_url": "https://example.com (optional)", + } + } + + +def amazon_shipping_oauth_registration_payload() -> dict: + return { + "carrier_account_oauth_registrations": { + "type": "AmazonShippingAccount", + "description": "My Shipping Account (optional)", + "reference": "Internal reference id (optional)", + "return_to_url": "https://example.com (optional)", + "credentials": { + "account_type": "shipper", + "account_country": "US", + }, + } + } + + +def doordash_account_payload() -> dict: + return { + "billToEasyPost": False, + "credentials": { + "developer_id": "VALUE", + "key_id": "VALUE", + "signing_secret": "VALUE", + "pickup_external_business_id": "VALUE", + }, + "test_credentials": {}, + "type": "DoorDashAccount", + } From 03b1fb2c7e9bce0ca58e87d75a95119d3cd17799 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 13 Oct 2026 14:37:51 -0600 Subject: [PATCH 2/6] chore: remove unused carrier curls --- .../guides/create-carrier-curls/amazonmws.sh | 14 ------------- .../canadapost-default.sh | 9 -------- .../guides/create-carrier-curls/deliverit.sh | 19 ----------------- .../create-carrier-curls/firstmileconcise.sh | 19 ----------------- .../create-carrier-curls/gofo-wallet.sh | 11 ---------- .../create-carrier-curls/osmworldwide.sh | 16 -------------- .../guides/create-carrier-curls/pandion.sh | 15 ------------- .../create-carrier-curls/parcelforce.sh | 21 ------------------- .../guides/create-carrier-curls/royalmail.sh | 14 ------------- .../guides/create-carrier-curls/sendle.sh | 17 --------------- official/guides/create-carrier-curls/toll.sh | 19 ----------------- .../guides/create-carrier-curls/upsiparcel.sh | 14 ------------- .../create-carrier-curls/upssurepost.sh | 16 -------------- .../create-carrier-curls/veho-wallet.sh | 12 ----------- 14 files changed, 216 deletions(-) delete mode 100644 official/guides/create-carrier-curls/amazonmws.sh delete mode 100644 official/guides/create-carrier-curls/canadapost-default.sh delete mode 100644 official/guides/create-carrier-curls/deliverit.sh delete mode 100644 official/guides/create-carrier-curls/firstmileconcise.sh delete mode 100644 official/guides/create-carrier-curls/gofo-wallet.sh delete mode 100644 official/guides/create-carrier-curls/osmworldwide.sh delete mode 100644 official/guides/create-carrier-curls/pandion.sh delete mode 100644 official/guides/create-carrier-curls/parcelforce.sh delete mode 100644 official/guides/create-carrier-curls/royalmail.sh delete mode 100644 official/guides/create-carrier-curls/sendle.sh delete mode 100644 official/guides/create-carrier-curls/toll.sh delete mode 100644 official/guides/create-carrier-curls/upsiparcel.sh delete mode 100644 official/guides/create-carrier-curls/upssurepost.sh delete mode 100644 official/guides/create-carrier-curls/veho-wallet.sh diff --git a/official/guides/create-carrier-curls/amazonmws.sh b/official/guides/create-carrier-curls/amazonmws.sh deleted file mode 100644 index d9e0d8d0..00000000 --- a/official/guides/create-carrier-curls/amazonmws.sh +++ /dev/null @@ -1,14 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "type": "AmazonMwsAccount", - "description": "AmazonMwsAccount", - "carrier_account": { - "credentials": { - "access_key_id": "VALUE", - "merchant_id": "VALUE", - "secret_key": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/canadapost-default.sh b/official/guides/create-carrier-curls/canadapost-default.sh deleted file mode 100644 index 96740480..00000000 --- a/official/guides/create-carrier-curls/canadapost-default.sh +++ /dev/null @@ -1,9 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "CanadaPostAccount", - "payment_mode": "aggregation" - } -}' diff --git a/official/guides/create-carrier-curls/deliverit.sh b/official/guides/create-carrier-curls/deliverit.sh deleted file mode 100644 index e8d4cd5d..00000000 --- a/official/guides/create-carrier-curls/deliverit.sh +++ /dev/null @@ -1,19 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "DeliverItAccount", - "description": "DeliverItAccount", - "credentials": { - "account_number": "VALUE", - "password": "VALUE", - "username": "VALUE" - }, - "test_credentials": { - "account_number": "VALUE", - "password": "VALUE", - "username": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/firstmileconcise.sh b/official/guides/create-carrier-curls/firstmileconcise.sh deleted file mode 100644 index 72a693a1..00000000 --- a/official/guides/create-carrier-curls/firstmileconcise.sh +++ /dev/null @@ -1,19 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "FirstMileConciseAccount", - "description": "FirstMileConciseAccount", - "credentials": { - "account_number": "VALUE", - "password": "VALUE", - "username": "VALUE" - }, - "test_credentials": { - "account_number": "VALUE", - "password": "VALUE", - "username": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/gofo-wallet.sh b/official/guides/create-carrier-curls/gofo-wallet.sh deleted file mode 100644 index 4644c3fa..00000000 --- a/official/guides/create-carrier-curls/gofo-wallet.sh +++ /dev/null @@ -1,11 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "GofoWalletAccount", - "reference": "GOFO Wallet Account", - "description": "GOFO Wallet Account", - "origin_hub": "VALUE" - } -}' diff --git a/official/guides/create-carrier-curls/osmworldwide.sh b/official/guides/create-carrier-curls/osmworldwide.sh deleted file mode 100644 index 77dc9c2c..00000000 --- a/official/guides/create-carrier-curls/osmworldwide.sh +++ /dev/null @@ -1,16 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "OsmWorldwideAccount", - "description": "OsmWorldwideAccount", - "credentials": { - "account_number": "VALUE", - "aws_sftp_username": "VALUE", - "company_name": "VALUE", - "facility_code": "VALUE", - "mailer_id": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/pandion.sh b/official/guides/create-carrier-curls/pandion.sh deleted file mode 100644 index 37edb15f..00000000 --- a/official/guides/create-carrier-curls/pandion.sh +++ /dev/null @@ -1,15 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "type": "PandionAccount", - "description": "PandionAccount", - "carrier_account": { - "credentials": { - "api_key": "VALUE" - }, - "test_credentials": { - "api_key": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/parcelforce.sh b/official/guides/create-carrier-curls/parcelforce.sh deleted file mode 100644 index c66c0de6..00000000 --- a/official/guides/create-carrier-curls/parcelforce.sh +++ /dev/null @@ -1,21 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "ParcelForceAccount", - "description": "ParcelForceAccount", - "credentials": { - "account_number": "VALUE", - "department_id": "VALUE", - "password": "VALUE", - "username": "VALUE" - }, - "test_credentials": { - "account_number": "VALUE", - "department_id": "VALUE", - "password": "VALUE", - "username": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/royalmail.sh b/official/guides/create-carrier-curls/royalmail.sh deleted file mode 100644 index ef20542b..00000000 --- a/official/guides/create-carrier-curls/royalmail.sh +++ /dev/null @@ -1,14 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "type": "RoyalMailAccount", - "description": "RoyalMailAccount", - "carrier_account": { - "credentials": { - "account_number": "VALUE", - "posting_location_number": "VALUE", - "username": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/sendle.sh b/official/guides/create-carrier-curls/sendle.sh deleted file mode 100644 index 7304ba87..00000000 --- a/official/guides/create-carrier-curls/sendle.sh +++ /dev/null @@ -1,17 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "SendleAccount", - "description": "SendleAccount", - "credentials": { - "api_key": "VALUE", - "user_id": "VALUE" - }, - "test_credentials": { - "api_key": "VALUE", - "user_id": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/toll.sh b/official/guides/create-carrier-curls/toll.sh deleted file mode 100644 index b4bdaee1..00000000 --- a/official/guides/create-carrier-curls/toll.sh +++ /dev/null @@ -1,19 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "type": "TollAccount", - "description": "TollAccount", - "carrier_account": { - "credentials": { - "account_number": "VALUE", - "business_unit": "VALUE", - "source_system_code": "VALUE" - }, - "test_credentials": { - "account_number": "VALUE", - "business_unit": "VALUE", - "source_system_code": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/upsiparcel.sh b/official/guides/create-carrier-curls/upsiparcel.sh deleted file mode 100644 index 18c6c429..00000000 --- a/official/guides/create-carrier-curls/upsiparcel.sh +++ /dev/null @@ -1,14 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "type": "UpsIparcelAccount", - "description": "UpsIparcelAccount", - "carrier_account": { - "credentials": { - "api_key": "VALUE", - "oauth_status": "VALUE", - "partner_oauth_url": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/upssurepost.sh b/official/guides/create-carrier-curls/upssurepost.sh deleted file mode 100644 index ae52cae8..00000000 --- a/official/guides/create-carrier-curls/upssurepost.sh +++ /dev/null @@ -1,16 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "UpsSurepostAccount", - "description": "UpsSurepostAccount", - "credentials": { - "account_number": "VALUE", - "oauth_status": "VALUE", - "partner_oauth_url": "VALUE", - "password": "VALUE", - "user_id": "VALUE" - } - } -}' diff --git a/official/guides/create-carrier-curls/veho-wallet.sh b/official/guides/create-carrier-curls/veho-wallet.sh deleted file mode 100644 index aeb5017e..00000000 --- a/official/guides/create-carrier-curls/veho-wallet.sh +++ /dev/null @@ -1,12 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "VehoWalletAccount", - "reference": "Veho Wallet Account", - "description": "Veho Wallet Account", - "company": "VALUE", - "agreed_to_terms_at": "VALUE" - } -}' From bb1166da3f5849c54aef1d2040815ac30a6fd10d Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:06:56 -0600 Subject: [PATCH 3/6] feat: blow away curls output dir automatically --- ...nadapost-wallet.sh => canadapostwallet.sh} | 0 .../{dhlecs-wallet.sh => dhlecswallet.sh} | 0 .../README.md | 16 +++++++++-- .../build_curls.py | 28 +++++++++---------- 4 files changed, 27 insertions(+), 17 deletions(-) rename official/guides/create-carrier-curls/{canadapost-wallet.sh => canadapostwallet.sh} (100%) rename official/guides/create-carrier-curls/{dhlecs-wallet.sh => dhlecswallet.sh} (100%) diff --git a/official/guides/create-carrier-curls/canadapost-wallet.sh b/official/guides/create-carrier-curls/canadapostwallet.sh similarity index 100% rename from official/guides/create-carrier-curls/canadapost-wallet.sh rename to official/guides/create-carrier-curls/canadapostwallet.sh diff --git a/official/guides/create-carrier-curls/dhlecs-wallet.sh b/official/guides/create-carrier-curls/dhlecswallet.sh similarity index 100% rename from official/guides/create-carrier-curls/dhlecs-wallet.sh rename to official/guides/create-carrier-curls/dhlecswallet.sh diff --git a/tools/build_create_carrier_curl_requests/README.md b/tools/build_create_carrier_curl_requests/README.md index edd8ca79..205050bf 100644 --- a/tools/build_create_carrier_curl_requests/README.md +++ b/tools/build_create_carrier_curl_requests/README.md @@ -1,8 +1,10 @@ # Build Create Carrier Curl Requests Tool -This tool creates a file containing all the create carrier account curl requests for all carriers on the EasyPost platform. +This tool generates all carrier create curl files from the `/carrier_types` endpoint. -EasyPost publishes these curl requests for convenience in this repo along with populating those requests on each carrier guide on our documentation. +EasyPost publishes these curl requests for convenience in this repo and uses them to populate each carrier guide in our docs. + +The output is intentionally fully automated. Whatever carrier types are available from `/carrier_types` at run time is the source of truth for what should be checked in. ## Install @@ -16,6 +18,16 @@ venv/bin/pip install easypost ## Usage +The script automatically deletes and rebuilds `official/guides/create-carrier-curls` on every run. + ```shell EASYPOST_PROD_API_KEY=123... venv/bin/python build_curls.py ``` + +This workflow is required because it guarantees all of the following: + +- New carrier create curls are added automatically. +- Existing carrier create curls are refreshed with any updated values. +- Carrier create curls for carriers that are no longer available are removed automatically. + +Do not add one-off manual curl files to `official/guides/create-carrier-curls`. If a carrier is genuinely addable via API but does not appear in this tool output (for example, because it is currently marked unavailable on the EasyPost backend), we still do not check in manual exceptions. The next automated run will remove manual files anyway, and the intended process is fully automated. diff --git a/tools/build_create_carrier_curl_requests/build_curls.py b/tools/build_create_carrier_curl_requests/build_curls.py index 0d8e668e..8e3c8eae 100644 --- a/tools/build_create_carrier_curl_requests/build_curls.py +++ b/tools/build_create_carrier_curl_requests/build_curls.py @@ -2,6 +2,7 @@ import json import os import re +import shutil import carrier_builder_data import carrier_builder_payloads @@ -14,18 +15,24 @@ LINE_BREAK_CHARS = " \\\n" END_CHARS = "\n" CUSTOM_WORKFLOW_CHARS = "## REQUIRES CUSTOM WORKFLOW ##\n" +OUTPUT_DESTINATION = os.path.join("..", "..", "official", "guides", "create-carrier-curls") + + +def reset_output_directory() -> None: + """Delete and recreate the output directory so every run is fully regenerated.""" + if os.path.exists(OUTPUT_DESTINATION): + shutil.rmtree(OUTPUT_DESTINATION) + + os.makedirs(OUTPUT_DESTINATION) def main(): + reset_output_directory() carrier_types = get_carrier_types() for carrier in sorted(carrier_types, key=lambda x: x["type"]): curl_request = build_carrier_curl_request(carrier) - output_destination = os.path.join("../", "../", "official", "guides", "create-carrier-curls") - if not os.path.exists(output_destination): - os.makedirs(output_destination) - with open( - os.path.join(output_destination, f"{carrier['type'].lower().replace('account', '')}.sh"), + os.path.join(OUTPUT_DESTINATION, f"{carrier['type'].lower().replace('account', '')}.sh"), "w", ) as carrier_curl_file: carrier_curl_file.write(re.sub(r"^.*?\n", "", curl_request)) @@ -90,18 +97,9 @@ def write_wallet_curl(carrier: dict[str, str], carrier_account_json: dict) -> No f"{LINE_BREAK_CHARS}{END_CHARS}", END_CHARS, ) - output_destination = os.path.join( - "..", - "..", - "official", - "guides", - "create-carrier-curls", - ) - if not os.path.exists(output_destination): - os.makedirs(output_destination) carrier_filename = carrier["type"].lower().replace("account", "") with open( - os.path.join(output_destination, f"{carrier_filename}-wallet.sh"), + os.path.join(OUTPUT_DESTINATION, f"{carrier_filename}wallet.sh"), "w", ) as wallet_file: wallet_file.write(re.sub(r"^.*?\n", "", wallet_output)) From 5c44e2292afe36a4302b4fa71900a6b49898c377 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 14 Oct 2026 10:36:34 -0600 Subject: [PATCH 4/6] feat: add feature flag carrier curls --- official/guides/create-carrier-curls/gori.sh | 17 ++++++++++ .../create-carrier-curls/osmworldwide.sh | 16 ++++++++++ .../guides/create-carrier-curls/royalmail.sh | 14 +++++++++ .../guides/create-carrier-curls/tiktok.sh | 13 ++++++++ .../create-carrier-curls/upssurepost.sh | 16 ++++++++++ .../guides/create-carrier-curls/uspsship.sh | 31 +++++++++++++++++++ .../create-carrier-curls/uspsshipplatform.sh | 19 ++++++++++++ .../README.md | 8 +++++ 8 files changed, 134 insertions(+) create mode 100644 official/guides/create-carrier-curls/gori.sh create mode 100644 official/guides/create-carrier-curls/osmworldwide.sh create mode 100644 official/guides/create-carrier-curls/royalmail.sh create mode 100644 official/guides/create-carrier-curls/tiktok.sh create mode 100644 official/guides/create-carrier-curls/upssurepost.sh create mode 100644 official/guides/create-carrier-curls/uspsship.sh create mode 100644 official/guides/create-carrier-curls/uspsshipplatform.sh diff --git a/official/guides/create-carrier-curls/gori.sh b/official/guides/create-carrier-curls/gori.sh new file mode 100644 index 00000000..83dfce23 --- /dev/null +++ b/official/guides/create-carrier-curls/gori.sh @@ -0,0 +1,17 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "GoriAccount", + "description": "GoriAccount", + "credentials": { + "client_id": "VALUE", + "client_secret": "VALUE" + }, + "test_credentials": { + "client_id": "VALUE", + "client_secret": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/osmworldwide.sh b/official/guides/create-carrier-curls/osmworldwide.sh new file mode 100644 index 00000000..77dc9c2c --- /dev/null +++ b/official/guides/create-carrier-curls/osmworldwide.sh @@ -0,0 +1,16 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "OsmWorldwideAccount", + "description": "OsmWorldwideAccount", + "credentials": { + "account_number": "VALUE", + "aws_sftp_username": "VALUE", + "company_name": "VALUE", + "facility_code": "VALUE", + "mailer_id": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/royalmail.sh b/official/guides/create-carrier-curls/royalmail.sh new file mode 100644 index 00000000..f253f737 --- /dev/null +++ b/official/guides/create-carrier-curls/royalmail.sh @@ -0,0 +1,14 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "RoyalMailAccount", + "description": "RoyalMailAccount", + "credentials": { + "account_number": "VALUE", + "posting_location_number": "VALUE", + "username": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/tiktok.sh b/official/guides/create-carrier-curls/tiktok.sh new file mode 100644 index 00000000..b28939db --- /dev/null +++ b/official/guides/create-carrier-curls/tiktok.sh @@ -0,0 +1,13 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "TikTokAccount", + "description": "TikTokAccount", + "credentials": { + "refresh_token": "VALUE", + "shop_code": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/upssurepost.sh b/official/guides/create-carrier-curls/upssurepost.sh new file mode 100644 index 00000000..5c4fae8d --- /dev/null +++ b/official/guides/create-carrier-curls/upssurepost.sh @@ -0,0 +1,16 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "UpsSurepostAccount", + "description": "UpsSurepostAccount", + "credentials": { + "account_number": "VALUE", + "oauth_status": "VALUE", + "partner_oauth_url": "VALUE", + "password": "VALUE", + "user_id": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/uspsship.sh b/official/guides/create-carrier-curls/uspsship.sh new file mode 100644 index 00000000..8f1ed73e --- /dev/null +++ b/official/guides/create-carrier-curls/uspsship.sh @@ -0,0 +1,31 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "UspsShipAccount", + "description": "UspsShipAccount", + "credentials": { + "account_number": "VALUE", + "address_city": "VALUE", + "address_state": "VALUE", + "address_street": "VALUE", + "address_zip": "VALUE", + "client_id": "VALUE", + "client_secret": "VALUE", + "company_name": "VALUE", + "contract_number": "VALUE", + "customer_registration_id": "VALUE", + "email": "VALUE", + "mailer_id": "VALUE", + "manifest_id": "VALUE", + "partner_oauth_url": "VALUE", + "phone": "VALUE", + "platform_account_number": "VALUE", + "refresh_token": "VALUE", + "returns_mailer_id": "VALUE", + "secondary_account_number": "VALUE", + "shipper_id": "VALUE" + } + } +}' diff --git a/official/guides/create-carrier-curls/uspsshipplatform.sh b/official/guides/create-carrier-curls/uspsshipplatform.sh new file mode 100644 index 00000000..94b67a85 --- /dev/null +++ b/official/guides/create-carrier-curls/uspsshipplatform.sh @@ -0,0 +1,19 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "UspsShipPlatformAccount", + "description": "UspsShipPlatformAccount", + "credentials": { + "address_city": "VALUE", + "address_state": "VALUE", + "address_street": "VALUE", + "address_zip": "VALUE", + "company_name": "VALUE", + "email": "VALUE", + "phone": "VALUE", + "shipper_id": "VALUE" + } + } +}' diff --git a/tools/build_create_carrier_curl_requests/README.md b/tools/build_create_carrier_curl_requests/README.md index 205050bf..d85b8448 100644 --- a/tools/build_create_carrier_curl_requests/README.md +++ b/tools/build_create_carrier_curl_requests/README.md @@ -6,6 +6,14 @@ EasyPost publishes these curl requests for convenience in this repo and uses the The output is intentionally fully automated. Whatever carrier types are available from `/carrier_types` at run time is the source of truth for what should be checked in. +## Carrier Availability Feature Flags + +Some carriers are behind feature flags and will not be returned by `/carrier_types` unless the API user has the associated `available_for_presentation` flag enabled for that carrier. + +It is recommended to run this tool with the `Docs Tooling` EasyPost user, since that user is already configured with the needed carrier feature flags and should return the full list. + +If the Docs Tooling user is not available, the user running this tool must be enabled on the backend for all `available_for_presentation` feature flags. + ## Install ```shell From 34bbff9193162634bbbcb45ee30c85372e70c780 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:06:58 -0600 Subject: [PATCH 5/6] feat: static carrier types --- .../create-carrier-curls/canadapostwallet.sh | 3 +- .../create-carrier-curls/dhlecswallet.sh | 3 +- .../create-carrier-curls/dhlexpresswallet.sh | 9 +++++ .../create-carrier-curls/fedexdefault.sh | 16 ++++++++ .../guides/create-carrier-curls/upsdap.sh | 21 +++++++++++ .../guides/create-carrier-curls/uspswallet.sh | 9 +++++ .../README.md | 2 + .../build_curls.py | 32 ++++++++++++---- .../carrier_builder_data.py | 16 +++++++- .../carrier_builder_payloads.py | 37 +++++++++++++++++++ 10 files changed, 135 insertions(+), 13 deletions(-) create mode 100644 official/guides/create-carrier-curls/dhlexpresswallet.sh create mode 100644 official/guides/create-carrier-curls/fedexdefault.sh create mode 100644 official/guides/create-carrier-curls/upsdap.sh create mode 100644 official/guides/create-carrier-curls/uspswallet.sh diff --git a/official/guides/create-carrier-curls/canadapostwallet.sh b/official/guides/create-carrier-curls/canadapostwallet.sh index b476b3ed..fefa9262 100644 --- a/official/guides/create-carrier-curls/canadapostwallet.sh +++ b/official/guides/create-carrier-curls/canadapostwallet.sh @@ -4,7 +4,6 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ -d '{ "carrier_account": { "type": "CanadaPostAccount", - "description": "CanadaPostAccount", - "payment_mode": "aggregation" + "description": "CanadaPostAccount" } }' diff --git a/official/guides/create-carrier-curls/dhlecswallet.sh b/official/guides/create-carrier-curls/dhlecswallet.sh index 3a281b61..a3259b68 100644 --- a/official/guides/create-carrier-curls/dhlecswallet.sh +++ b/official/guides/create-carrier-curls/dhlecswallet.sh @@ -4,7 +4,6 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts \ -d '{ "carrier_account": { "type": "DhlEcsAccount", - "description": "DhlEcsAccount", - "payment_mode": "aggregation" + "description": "DhlEcsAccount" } }' diff --git a/official/guides/create-carrier-curls/dhlexpresswallet.sh b/official/guides/create-carrier-curls/dhlexpresswallet.sh new file mode 100644 index 00000000..30e54500 --- /dev/null +++ b/official/guides/create-carrier-curls/dhlexpresswallet.sh @@ -0,0 +1,9 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "DhlExpressAccount", + "description": "DhlExpressAccount" + } +}' diff --git a/official/guides/create-carrier-curls/fedexdefault.sh b/official/guides/create-carrier-curls/fedexdefault.sh new file mode 100644 index 00000000..21b6b301 --- /dev/null +++ b/official/guides/create-carrier-curls/fedexdefault.sh @@ -0,0 +1,16 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "FedexDefaultAccount", + "name": "VALUE", + "street1": "VALUE", + "city": "VALUE", + "state": "VALUE", + "postal_code": "VALUE", + "country": "VALUE", + "phone": "VALUE", + "email": "VALUE" + } +}' diff --git a/official/guides/create-carrier-curls/upsdap.sh b/official/guides/create-carrier-curls/upsdap.sh new file mode 100644 index 00000000..8720924b --- /dev/null +++ b/official/guides/create-carrier-curls/upsdap.sh @@ -0,0 +1,21 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts/open \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "UpsDapAccount", + "description": "VALUE", + "name": "VALUE", + "title": "VALUE", + "company": "VALUE", + "street1": "VALUE", + "street2": "VALUE", + "city": "VALUE", + "state": "VALUE", + "postal_code": "VALUE", + "country": "VALUE", + "website": "VALUE", + "email": "VALUE", + "phone": "VALUE" + } +}' diff --git a/official/guides/create-carrier-curls/uspswallet.sh b/official/guides/create-carrier-curls/uspswallet.sh new file mode 100644 index 00000000..bfe144da --- /dev/null +++ b/official/guides/create-carrier-curls/uspswallet.sh @@ -0,0 +1,9 @@ +curl -X POST https://api.easypost.com/v2/carrier_accounts \ + -u "$EASYPOST_API_KEY": \ + -H 'Content-Type: application/json' \ + -d '{ + "carrier_account": { + "type": "UspsAccount", + "description": "UspsAccount" + } +}' diff --git a/tools/build_create_carrier_curl_requests/README.md b/tools/build_create_carrier_curl_requests/README.md index d85b8448..7320adae 100644 --- a/tools/build_create_carrier_curl_requests/README.md +++ b/tools/build_create_carrier_curl_requests/README.md @@ -14,6 +14,8 @@ It is recommended to run this tool with the `Docs Tooling` EasyPost user, since If the Docs Tooling user is not available, the user running this tool must be enabled on the backend for all `available_for_presentation` feature flags. +The tool also includes static fallbacks for carriers under `STATIC_CARRIER_TYPES`, which are currently known to be omitted from `/carrier_types` due to not being marked for presentation. + ## Install ```shell diff --git a/tools/build_create_carrier_curl_requests/build_curls.py b/tools/build_create_carrier_curl_requests/build_curls.py index 8e3c8eae..d77c0958 100644 --- a/tools/build_create_carrier_curl_requests/build_curls.py +++ b/tools/build_create_carrier_curl_requests/build_curls.py @@ -43,6 +43,11 @@ def get_carrier_types(): client = easypost.EasyPostClient(API_KEY) carrier_accounts = client.carrier_account.types() + existing_types = {carrier["type"] for carrier in carrier_accounts} + for static_carrier_type in carrier_builder_data.STATIC_CARRIER_TYPES: + if static_carrier_type not in existing_types: + carrier_accounts.append({"type": static_carrier_type}) + return carrier_accounts @@ -82,12 +87,15 @@ def add_headers(carrier_output: str, carrier: dict[str, str]) -> str: def write_wallet_curl(carrier: dict[str, str], carrier_account_json: dict) -> None: - """Create a Wallet cURL for carriers that support EasyPost aggregation.""" + """Create a Wallet cURL for carriers that support EasyPost BYOCA and Wallet.""" wallet_json = copy.deepcopy(carrier_account_json) wallet_account = wallet_json["carrier_account"] wallet_account.pop("credentials", None) wallet_account.pop("test_credentials", None) - wallet_account["payment_mode"] = "aggregation" + # TODO: It is too difficult to properly assess the need for payment_mode as it + # is a case-by-base basis and we should not make assumptions for either the carrier + # or the user here; however, this could use some better documentation and distinction. + # wallet_account["payment_mode"] = "aggregation" wallet_output = f"# {carrier.get('type')} (EasyPost Wallet)\n" wallet_output = add_curl_line(wallet_output, carrier) wallet_output = add_headers(wallet_output, carrier) @@ -107,6 +115,18 @@ def write_wallet_curl(carrier: dict[str, str], carrier_account_json: dict) -> No def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> str: """Iterate over the carrier fields and print the credential structure.""" + if carrier["type"] == "UpsDapAccount": + carrier_account_json = carrier_builder_payloads.ups_dap_account_payload() + carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" + carrier_output += END_CHARS + return carrier_output + + if carrier["type"] == "FedexDefaultAccount": + carrier_account_json = carrier_builder_payloads.fedex_default_account_payload() + carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'" + carrier_output += END_CHARS + return carrier_output + carrier_account_json = { "carrier_account": { "type": carrier["type"], @@ -126,7 +146,6 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st carrier_output += END_CHARS carrier_output = carrier_output.replace(f"{LINE_BREAK_CHARS}{END_CHARS}", f"{END_CHARS}") # Maersk Parcel — custom static credential structure - # TODO: Why is this static? It should be exposed via carrier types endpoint elif carrier["type"] in carrier_builder_data.MAERSK_CUSTOM_WORKFLOW_CARRIERS: carrier_account_json = carrier_builder_payloads.maersk_account_payload() @@ -166,10 +185,9 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st # top_level here means `credentials`, `test_credentials`, # or `custom_workflow` for top_level in carrier_fields: - # TODO: If there is a custom_workflow such as 3rd party auth + # If there is a custom_workflow such as 3rd party auth # or a similar flow, warn about that here. The credential - # structure will differ from a normal carrier account and is - # currently not automated. + # structure will differ from a normal carrier account and is not automated. if top_level == "custom_workflow": end += CUSTOM_WORKFLOW_CHARS else: @@ -188,7 +206,7 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st END_CHARS, ) - if carrier["type"] in carrier_builder_data.WALLET_CARRIERS: + if carrier["type"] in carrier_builder_data.BYOCA_AND_WALLET_CARRIER_TYPES: write_wallet_curl(carrier, carrier_account_json) return carrier_output diff --git a/tools/build_create_carrier_curl_requests/carrier_builder_data.py b/tools/build_create_carrier_curl_requests/carrier_builder_data.py index 53d7d7e5..3573402d 100644 --- a/tools/build_create_carrier_curl_requests/carrier_builder_data.py +++ b/tools/build_create_carrier_curl_requests/carrier_builder_data.py @@ -3,14 +3,15 @@ # Keep this focused on endpoint selection; payload one-offs are handled separately. CARRIER_CREATE_ENDPOINT_OVERRIDES = { "v2/carrier_accounts/open": { + "FedexDefaultAccount", "GofoWalletAccount", + "UpsDapAccount", "UniUniWalletAccount", "VehoWalletAccount", }, "v2/carrier_accounts/register": { "FedexAccount", "FedexSmartpostAccount", - "UpsDapAccount", }, "v2/carrier_accounts/register_oauth": { "AmazonShippingAccount", @@ -21,6 +22,13 @@ }, } +# Carrier account types that should always be emitted even when omitted by +# /carrier_types (eg: due to being marked unavailable for presentation). +STATIC_CARRIER_TYPES = [ + "FedexDefaultAccount", + "UpsDapAccount", +] + FEDEX_CUSTOM_WORKFLOW_CARRIERS = [ "FedexAccount", "FedexSmartpostAccount", @@ -43,7 +51,11 @@ "DoorDashAccount", ] -WALLET_CARRIERS = [ +# The following are both a BYOCA (Bring Your Own Carrier Account) and +# wallet carrier type depending on what `payment_type` is set to. +BYOCA_AND_WALLET_CARRIER_TYPES = [ "CanadaPostAccount", "DhlEcsAccount", + "DhlExpressAccount", + "UspsAccount", ] diff --git a/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py b/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py index c95ee746..18bb5208 100644 --- a/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py +++ b/tools/build_create_carrier_curl_requests/carrier_builder_payloads.py @@ -69,3 +69,40 @@ def doordash_account_payload() -> dict: "test_credentials": {}, "type": "DoorDashAccount", } + + +def ups_dap_account_payload() -> dict: + return { + "carrier_account": { + "type": "UpsDapAccount", + "description": "VALUE", + "name": "VALUE", + "title": "VALUE", + "company": "VALUE", + "street1": "VALUE", + "street2": "VALUE", + "city": "VALUE", + "state": "VALUE", + "postal_code": "VALUE", + "country": "VALUE", + "website": "VALUE", + "email": "VALUE", + "phone": "VALUE", + } + } + + +def fedex_default_account_payload() -> dict: + return { + "carrier_account": { + "type": "FedexDefaultAccount", + "name": "VALUE", + "street1": "VALUE", + "city": "VALUE", + "state": "VALUE", + "postal_code": "VALUE", + "country": "VALUE", + "phone": "VALUE", + "email": "VALUE", + } + } From 42860f3d04706ea8e9185a854302462adf454a22 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:22:31 -0600 Subject: [PATCH 6/6] chore: remove tiktok curl --- official/guides/create-carrier-curls/tiktok.sh | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 official/guides/create-carrier-curls/tiktok.sh diff --git a/official/guides/create-carrier-curls/tiktok.sh b/official/guides/create-carrier-curls/tiktok.sh deleted file mode 100644 index b28939db..00000000 --- a/official/guides/create-carrier-curls/tiktok.sh +++ /dev/null @@ -1,13 +0,0 @@ -curl -X POST https://api.easypost.com/v2/carrier_accounts \ - -u "$EASYPOST_API_KEY": \ - -H 'Content-Type: application/json' \ - -d '{ - "carrier_account": { - "type": "TikTokAccount", - "description": "TikTokAccount", - "credentials": { - "refresh_token": "VALUE", - "shop_code": "VALUE" - } - } -}'