This tutorial demonstrates a complete order fulfillment workflow: creating an order in Shopify, importing it into ShipEngine, creating a shipping label, and notifying Shopify of shipment.
In-cart rates via Sales Order API require a Shopify Plus account.
Create a test order in Shopify. The generated order ID becomes the external_order_id when imported into ShipEngine.
Trigger ShipEngine to import the newly created order:
PUT /v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__Find your order by sorting descending by order date:
GET /v-beta/sales_orders?order_source_id=__YOUR_ORDER_SOURCE_ID_HERE__&sort_dir=desc&sort_by=order_date&page=1&page_size=1 HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__Or query directly by external_order_id:
GET /v-beta/sales_orders?external_order_id=1011295486011 HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__Use the sales_order_id from the previous response:
POST /v-beta/labels/sales_order/:sales_order_id HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json{
"label_format": "pdf",
"shipment": {
"carrier_id": "se-123890",
"service_code": "usps_priority_mail",
"ship_from": {
"company_name": "Example Corp.",
"name": "John Doe",
"phone": "111-111-1111",
"address_line1": "4009 Marathon Blvd",
"city_locality": "Austin",
"state_province": "TX",
"postal_code": "78756",
"country_code": "US"
},
"packages": [{
"package_code": "package",
"weight": {
"value": 2,
"unit": "pound"
}
}]
}
}Inform Shopify the order has shipped:
POST /v-beta/sales_orders/:sales_order_id/notify_shipped HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json{
"tracking_number": "9374869901600064074368",
"carrier_code": "usps",
"sales_order_items": [{
"sales_order_item_id": ":sales_order_item_id",
"quantity": 1
}]
}Successful submission returns HTTP 204 No Content. Refresh your order source to update the sales order status.