Record a shipment
const url = 'https://api.ebitex.io/commerce/management/v1/orders/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/shipments';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"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"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
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"}Responses
Section titled “ Responses ”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.