Skip to main content

Download a printable label

GET /orders/{id}/shippingLabels renders an order's labels as a single PDF and returns a signed link to it. The PDF is A6, one page per package, with a Code 128 barcode per page taken from the order's barcodes.

The labels hang off the order's own id, so append /shippingLabels to it:

curl "https://api.spoke.com/connect/v1/orders/W3kJpzQm9q4LV2BdH7sNuT/shippingLabels" \
-H "Authorization: Bearer <api-key>"
{
"url": "https://storage.googleapis.com/.../W3kJpzQm9q4LV2BdH7sNuT.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Expires=3600&X-Goog-Signature=...",
"expiresAt": 1778514703
}

The host and path are storage details rather than contract. Treat the whole URL as opaque and follow it exactly as given.

Fetch it straight away

The link is signed and needs no API key, which is exactly why it expires in one hour. expiresAt is the moment it stops working, in seconds since epoch.

curl -o label.pdf "<url from the response>"

Fetch it server-side as soon as you get it and store the PDF yourself if you need to keep it. Do not put this URL in an email, a stored record, or anything a person opens later. It is deliberately too short-lived for that, and it grants access to the label without authentication for as long as it lives.

Every call renders the labels afresh and signs a new URL, so the PDF always reflects the order's current packages. Nothing is cached between calls. If you need the link again, ask for it again rather than storing it.

When it fails

StatuscodeWhat happened
400validationThe id in the path is not a valid order id.
401The API key is missing, invalid, or expired.
404order_not_foundNo such order for your account, or it was deleted.
422order_invalid_fieldsThe order cannot produce a label yet. param names the field.

The 422 you are most likely to see names barcodes:

{
"message": "The order has no barcodes yet.",
"code": "order_invalid_fields",
"param": "barcodes"
}

Orders you create through the API get their barcodes at creation time, one per package, so this normally only shows up for orders that reached your account another way. Read the order back and check barcodes before treating it as an error worth alerting on.