Skip to content

Record a shipment

POST
/commerce/management/v1/orders/{orderId}/shipments
curl --request POST \
--url https://api.ebitex.io/commerce/management/v1/orders/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/shipments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "groupId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "lines": [ { "orderLineId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "quantity": 1 } ], "carrier": "example", "trackingNumber": "example", "trackingUrl": "example", "carrierPluginKey": "example", "externalReference": "example", "labelUrl": "example" }'

Records that some of an order’s items have shipped, and takes them off the shelf. Send { "groupId", "lines": [ { "orderLineId", "quantity" } ], "carrier", "trackingNumber", "trackingUrl", "carrierPluginKey", "externalReference", "labelUrl" }. carrier is required; the rest are optional. externalReference is your own id for the shipment, and carrierPluginKey names the carrier integration that made it.

A line cannot ship more than is still to ship (what was ordered, less what has shipped or been cancelled). The order must be paid. When everything has shipped the group finishes by itself, exactly as when a person records the shipment, and the order’s status follows.

Call it from your own server with a management key (the Management keys section of Commerce’s delivery keys screen); it has no CORS policy, so a browser page cannot use it. The key belongs to the organization and works on every store’s orders. It has two tiers: commerce.management.read reads orders, finds a shipment by its carrier reference and reads an order’s fulfilment; commerce.orders.fulfil does all of that and also records and updates shipments. Neither can refund, cancel, move an order along, change stock, or read who bought: no answer carries a buyer’s name, email or address. The key’s budget is 300 requests a minute.

Key: a Commerce management key with commerce.orders.fulfil.

orderId
required
string format: uuid
Media typeapplication/json
object
groupId
required
string format: uuid
lines
required
Array<object> | null
object
orderLineId
required
string format: uuid
quantity
required
integer | string format: int32
/^-?(?:0|[1-9]\d*)$/
carrier
required
null | string
trackingNumber
required
null | string
trackingUrl
required
null | string
carrierPluginKey
required
null | string
externalReference
required
null | string
labelUrl
required
null | string
Examplegenerated
{
"groupId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"lines": [
{
"orderLineId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"quantity": 1
}
],
"carrier": "example",
"trackingNumber": "example",
"trackingUrl": "example",
"carrierPluginKey": "example",
"externalReference": "example",
"labelUrl": "example"
}

OK

invalid_carrier, invalid_lines, invalid_quantity, invalid_tracking, invalid_trackingUrl or invalid_labelUrl: the request was malformed.

missing_api_key or invalid_api_key: no key was sent, or it is unknown, revoked or expired.

payment_required: the organization’s subscription needs attention.

scope_denied: the key holds only commerce.management.read.

scope_denied: the key lacks commerce.orders.fulfil. app_not_available: Commerce is not enabled for the organization. ip_denied: the key was used from an address outside its restrictions.

order_not_found or group_not_found.

order_not_paid, group_closed, line_not_in_group, quantity_exceeds_unshipped (nothing was recorded) or insufficient_stock_for_backorder.

rate_limited: the key spent its 300 requests a minute; Retry-After says how long to wait. too_many_failed_authentications: too many bad keys from this address.