{
  "info": {
    "name": "CONNEX API",
    "description": "Rates, tracking and the tracking.updated webhook. Reference: https://store.connexglobal.co/docs\n\n1. Sign in to CONNEX and generate an API key: Tools → API keys (https://connex.fastship.co/api-keys).\n2. Set clientId and clientSecret.\n3. Run \"Get access token\" — accessToken is saved for every request after it. Repeat hourly.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Get access token",
          "request": {
            "method": "POST",
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{clientId}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{clientSecret}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{baseUrl}}/oauth/token",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "oauth",
                "token"
              ]
            },
            "description": "Client credentials: clientId and clientSecret come from your API key — CONNEX portal → Tools → API keys (https://connex.fastship.co/api-keys). Saves access_token into accessToken. Tokens last one hour — run this again when one expires."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.access_token) pm.collectionVariables.set('accessToken', json.access_token);"
                ]
              }
            }
          ],
          "response": []
        }
      ]
    },
    {
      "name": "Rates",
      "item": [
        {
          "name": "Get rates",
          "request": {
            "method": "POST",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"Country\": \"USA\",\n  \"ActualWeight\": 850,\n  \"Weight\": 1200,\n  \"Length\": 30,\n  \"Width\": 20,\n  \"Height\": 10\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/v1/rates",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "rates"
              ]
            },
            "description": "Requires rates:read. Country is ISO-3; weights in grams, dimensions in cm. Prices come back in THB."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Tracking",
      "item": [
        {
          "name": "Get tracking",
          "request": {
            "method": "GET",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/tracking?refs=ORD-10432,ORD-10433",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "tracking"
              ],
              "query": [
                {
                  "key": "refs",
                  "value": "ORD-10432,ORD-10433"
                }
              ]
            },
            "description": "Requires tracking:read. Up to 50 comma-separated order refs."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "Create order",
          "request": {
            "method": "POST",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"orderId\": \"ORD-10432\",\n  \"currency\": \"THB\",\n  \"customer\": {\n    \"name\": \"Jane Doe\",\n    \"email\": \"jane@example.com\",\n    \"phone\": \"+1 512 555 0100\"\n  },\n  \"shippingAddress\": {\n    \"name\": \"Jane Doe\",\n    \"phone\": \"+1 512 555 0100\",\n    \"line1\": \"1 Main St\",\n    \"city\": \"Austin\",\n    \"state\": \"TX\",\n    \"postalCode\": \"78701\",\n    \"country\": \"US\"\n  },\n  \"items\": [\n    {\n      \"sku\": \"SKU-001\",\n      \"name\": \"Gold Rook Ear Cuff\",\n      \"quantity\": 2,\n      \"unitPrice\": 500,\n      \"weight\": 50\n    }\n  ],\n  \"shipping\": {\n    \"serviceId\": \"EX001.\",\n    \"serviceName\": \"Fastship Express via UPS\",\n    \"price\": 1884\n  },\n  \"totals\": {\n    \"total\": 2884\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/v1/orders",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "orders"
              ]
            },
            "description": "Requires orders:write. Creates the order in the CONNEX account that generated this API key — a REAL order on that account's order desk, under its \"CONNEX API\" channel (created with the first order). Same orderId again = safe retry. Track it with Get tracking ?refs=<orderId>."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Register webhook endpoint",
          "request": {
            "method": "POST",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"{{webhookUrl}}\",\n  \"events\": [\n    \"tracking.updated\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/v1/webhook_endpoints",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "webhook_endpoints"
              ]
            },
            "description": "Requires webhooks:write. The secret is returned only here — it is saved into webhookSecret."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.id) pm.collectionVariables.set('webhookEndpointId', json.id);",
                  "if (json.secret) pm.collectionVariables.set('webhookSecret', json.secret);"
                ]
              }
            }
          ],
          "response": []
        },
        {
          "name": "Test webhook endpoint",
          "request": {
            "method": "POST",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/webhook_endpoints/{{webhookEndpointId}}/test",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "webhook_endpoints",
                "{{webhookEndpointId}}",
                "test"
              ]
            },
            "description": "Sends a sample tracking.updated (X-Connex-Test: true, orderRef TEST-ORDER-001) to the endpoint now and reports whether it accepted it."
          },
          "response": []
        },
        {
          "name": "List webhook endpoints",
          "request": {
            "method": "GET",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/webhook_endpoints",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "webhook_endpoints"
              ]
            },
            "description": "Requires webhooks:write."
          },
          "response": []
        },
        {
          "name": "Delete webhook endpoint",
          "request": {
            "method": "DELETE",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/webhook_endpoints/{{webhookEndpointId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "webhook_endpoints",
                "{{webhookEndpointId}}"
              ]
            },
            "description": "Requires webhooks:write."
          },
          "response": []
        },
        {
          "name": "Simulate tracking.updated (to your endpoint)",
          "request": {
            "method": "POST",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{webhookSecret}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"updates\": [\n    {\n      \"scope\": \"shipment\",\n      \"fastShipId\": 137971,\n      \"orderRef\": \"ORD-10432\",\n      \"fastshipShipmentId\": 884120,\n      \"trackingNo\": \"FS2604188412\",\n      \"agentTrackingNo\": \"1Z999AA10123456784\",\n      \"status\": \"OUT_FOR_DELIVERY\",\n      \"orderStatus\": \"SHIPPED\",\n      \"provider\": \"UPS\",\n      \"serviceAgent\": \"FSEXP-UPS\",\n      \"agentName\": \"UPS Worldwide Express\",\n      \"updatedAt\": \"2026-10-24T08:15:00.000Z\"\n    },\n    {\n      \"scope\": \"order\",\n      \"fastShipId\": 137971,\n      \"orderRef\": \"ORD-10433\",\n      \"orderStatus\": \"CANCELLED\",\n      \"updatedAt\": \"2026-10-24T08:16:30.000Z\"\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{webhookUrl}}",
              "host": [
                "{{webhookUrl}}"
              ]
            },
            "description": "Sends YOUR receiver exactly what CONNEX will send, signed with webhookSecret — use it to test your handler before going live. Expect 2xx; a wrong secret should get 401."
          },
          "response": []
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.connexglobal.co",
      "type": "string"
    },
    {
      "key": "clientId",
      "value": "cnx_client_…",
      "type": "string"
    },
    {
      "key": "clientSecret",
      "value": "",
      "type": "string"
    },
    {
      "key": "accessToken",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhookEndpointId",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhookUrl",
      "value": "https://your-app.com/webhooks/connex",
      "type": "string"
    },
    {
      "key": "webhookSecret",
      "value": "",
      "type": "string"
    }
  ]
}