Connect API

On resource IDs

How prefixed ids such as orders/{id} address a resource.

Every resource in the Connect API has a unique id that Spoke generates. Every resource representation the API returns shows that id in the following format:

{
  "id": "collectionName/resourceId"
}

So an order comes back as:

{
  "id": "orders/W3kJpzQm9q4LV2BdH7sNuT"
}

Ids are unique per collection, so orders/..., couriers/..., and pickupLocations/... name an order, a courier, and a pickup location respectively.

This means that to act on a resource directly you append its id to the base address exactly as it came back:

curl "https://api.spoke.com/connect/v1/`serializedId`" \
  -H "Authorization: Bearer <api-key>"

For the order above that is:

curl "https://api.spoke.com/connect/v1/orders/W3kJpzQm9q4LV2BdH7sNuT" \
  -H "Authorization: Bearer <api-key>"

Sub-resources hang off the same id, so that order's labels are at orders/W3kJpzQm9q4LV2BdH7sNuT/shippingLabels.

The endpoint reference below writes the same paths in OpenAPI template notation, as /orders/{id}. That describes the URL you just built, so there is no second id format to keep track of.

Send ids back in the form you received them. courierId on POST /orders:submit, and pickupLocationId on an order, both take the full prefixed value.

Was this page helpful?