Orders
The shop's orders, with their lines, totals, addresses and shipment: read them, move them through their statuses, and record the shipments your own system books.
Reach them through admin.orders. Reading needs the orders:read scope, changing them orders:write.
List orders
admin.orders.list(query?: ListQuery & { status?: string; paymentStatus?: string; source?: string }): Promise<CursorPage<Order>>
One page of the shop's orders, by status, payment status or source; or oldest change first with updatedSince. Read the next page with meta.nextCursor as cursor. Scope: orders:read.
Parameters
| Parameter |
Type |
|
query |
object |
The query fields below, by name. |
Query fields
| Parameter | Type | Description |
|---|
status | any | |
paymentStatus | any | |
source | any | |
limit | integer | At least 1. At most 100. Default 50. |
cursor | string | meta.nextCursor (or the cursor in links.next) of the previous page. At most 1000 characters. |
updatedSince | string (date-time) | Records changed at or after this time (ISO 8601, any offset or Z), oldest change first, for incremental sync. |
Returns
A CursorPage<Order>:
| Field | Type | Description |
|---|
links | object | |
links.first | null | |
links.last | null | |
links.prev | string (uri) or null | |
links.next | string (uri) or null | |
meta | object | |
meta.path | string (uri) | |
meta.perPage | integer | |
meta.nextCursor | string or null | |
meta.prevCursor | string or null | |
data | array of Order | |
data[].id | integer | |
data[].orderNumber | string | |
data[].status | string | One of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled. |
data[].paymentStatus | string or null | |
data[].paymentMethod | string or null | |
data[].source | string | checkout, whatsapp, quotation or enquiry. |
data[].placedAt | string (date-time) or null | |
data[].paidAt | string (date-time) or null | |
data[].customer | object | |
data[].customer.id | integer or null | |
data[].customer.name | string or null | |
data[].customer.email | string or null | |
data[].customer.phone | string or null | |
data[].shippingAddress | object | |
data[].shippingAddress.line1 | string or null | |
data[].shippingAddress.line2 | string or null | |
data[].shippingAddress.neighbourhood | string or null | |
data[].shippingAddress.city | string or null | |
data[].shippingAddress.state | string or null | |
data[].shippingAddress.postalCode | string or null | |
data[].shippingAddress.countryCode | string or null | |
data[].billingAddress | object or null | Null when billing is the shipping address. |
data[].billingAddress.name | string or null | |
data[].billingAddress.phone | string or null | |
data[].billingAddress.line1 | string or null | |
data[].billingAddress.line2 | string or null | |
data[].billingAddress.city | string or null | |
data[].billingAddress.state | string or null | |
data[].billingAddress.postalCode | string or null | |
data[].billingAddress.countryCode | string or null | |
data[].shippingMethod | string or null | |
data[].notes | string or null | |
data[].items | array of object | |
data[].items[].productId | integer or null | |
data[].items[].title | string or null | |
data[].items[].sku | string or null | |
data[].items[].quantity | integer | |
data[].items[].unitPrice | Money | Fields: amount, currency, formatted. |
data[].items[].total | Money | Fields: amount, currency, formatted. |
data[].subtotal | Money | Fields: amount, currency, formatted. |
data[].discount | Money | Fields: amount, currency, formatted. |
data[].couponCode | string or null | |
data[].shippingFee | Money | Fields: amount, currency, formatted. |
data[].tax | Money | Fields: amount, currency, formatted. |
data[].total | Money | Fields: amount, currency, formatted. |
data[].refunded | Money | Fields: amount, currency, formatted. |
data[].shipment | object or null | |
data[].shipment.carrier | string or null | |
data[].shipment.trackingNumber | string or null | |
data[].shipment.status | string or null | The shipment status's label, in the response language. |
data[].receiptUrl | string (uri) | |
data[].updatedAt | string (date-time) or null | |
Errors
| Status | When |
|---|
401 | invalid_api_key: no active Admin key in Authorization: Bearer. |
403 | admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope. |
422 | Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid). |
429 | Rate limited. |
Example
const query = { status: 'processing', limit: 50 };
let cursor: string | null = null;
do {
const page = await admin.orders.list(cursor ? { ...query, cursor } : query);
// … page.data
cursor = page.meta.nextCursor;
} while (cursor !== null);
Iterate over every order
admin.orders.all(query?: ListQuery & { status?: string; paymentStatus?: string; source?: string }): AsyncGenerator<Order, void, undefined>
Every order matching the query, one at a time, fetching the next page as you read. It takes the same query as list, without cursor. Scope: orders:read.
Returns
An async generator of Order, each:
| Field | Type | Description |
|---|
[].id | integer | |
[].orderNumber | string | |
[].status | string | One of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled. |
[].paymentStatus | string or null | |
[].paymentMethod | string or null | |
[].source | string | checkout, whatsapp, quotation or enquiry. |
[].placedAt | string (date-time) or null | |
[].paidAt | string (date-time) or null | |
[].customer | object | |
[].customer.id | integer or null | |
[].customer.name | string or null | |
[].customer.email | string or null | |
[].customer.phone | string or null | |
[].shippingAddress | object | |
[].shippingAddress.line1 | string or null | |
[].shippingAddress.line2 | string or null | |
[].shippingAddress.neighbourhood | string or null | |
[].shippingAddress.city | string or null | |
[].shippingAddress.state | string or null | |
[].shippingAddress.postalCode | string or null | |
[].shippingAddress.countryCode | string or null | |
[].billingAddress | object or null | Null when billing is the shipping address. |
[].billingAddress.name | string or null | |
[].billingAddress.phone | string or null | |
[].billingAddress.line1 | string or null | |
[].billingAddress.line2 | string or null | |
[].billingAddress.city | string or null | |
[].billingAddress.state | string or null | |
[].billingAddress.postalCode | string or null | |
[].billingAddress.countryCode | string or null | |
[].shippingMethod | string or null | |
[].notes | string or null | |
[].items | array of object | |
[].items[].productId | integer or null | |
[].items[].title | string or null | |
[].items[].sku | string or null | |
[].items[].quantity | integer | |
[].items[].unitPrice | Money | Fields: amount, currency, formatted. |
[].items[].total | Money | Fields: amount, currency, formatted. |
[].subtotal | Money | Fields: amount, currency, formatted. |
[].discount | Money | Fields: amount, currency, formatted. |
[].couponCode | string or null | |
[].shippingFee | Money | Fields: amount, currency, formatted. |
[].tax | Money | Fields: amount, currency, formatted. |
[].total | Money | Fields: amount, currency, formatted. |
[].refunded | Money | Fields: amount, currency, formatted. |
[].shipment | object or null | |
[].shipment.carrier | string or null | |
[].shipment.trackingNumber | string or null | |
[].shipment.status | string or null | The shipment status's label, in the response language. |
[].receiptUrl | string (uri) | |
[].updatedAt | string (date-time) or null | |
Example
for await (const order of admin.orders.all({ updatedSince: lastSyncedAt })) {
await erp.saveOrder(order);
}
Get an order
admin.orders.get(id: number): Promise<Order>
One order by its id, with its lines, totals, addresses and shipment. Scope: orders:read.
Parameters
| Parameter |
Type |
|
id |
number |
The order's id. |
Returns
An Order:
| Field | Type | Description |
|---|
id | integer | |
orderNumber | string | |
status | string | One of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled. |
paymentStatus | string or null | |
paymentMethod | string or null | |
source | string | checkout, whatsapp, quotation or enquiry. |
placedAt | string (date-time) or null | |
paidAt | string (date-time) or null | |
customer | object | |
customer.id | integer or null | |
customer.name | string or null | |
customer.email | string or null | |
customer.phone | string or null | |
shippingAddress | object | |
shippingAddress.line1 | string or null | |
shippingAddress.line2 | string or null | |
shippingAddress.neighbourhood | string or null | |
shippingAddress.city | string or null | |
shippingAddress.state | string or null | |
shippingAddress.postalCode | string or null | |
shippingAddress.countryCode | string or null | |
billingAddress | object or null | Null when billing is the shipping address. |
billingAddress.name | string or null | |
billingAddress.phone | string or null | |
billingAddress.line1 | string or null | |
billingAddress.line2 | string or null | |
billingAddress.city | string or null | |
billingAddress.state | string or null | |
billingAddress.postalCode | string or null | |
billingAddress.countryCode | string or null | |
shippingMethod | string or null | |
notes | string or null | |
items | array of object | |
items[].productId | integer or null | |
items[].title | string or null | |
items[].sku | string or null | |
items[].quantity | integer | |
items[].unitPrice | Money | Fields: amount, currency, formatted. |
items[].total | Money | Fields: amount, currency, formatted. |
subtotal | Money | Fields: amount, currency, formatted. |
discount | Money | Fields: amount, currency, formatted. |
couponCode | string or null | |
shippingFee | Money | Fields: amount, currency, formatted. |
tax | Money | Fields: amount, currency, formatted. |
total | Money | Fields: amount, currency, formatted. |
refunded | Money | Fields: amount, currency, formatted. |
shipment | object or null | |
shipment.carrier | string or null | |
shipment.trackingNumber | string or null | |
shipment.status | string or null | The shipment status's label, in the response language. |
receiptUrl | string (uri) | |
updatedAt | string (date-time) or null | |
Errors
| Status | When |
|---|
401 | invalid_api_key: no active Admin key in Authorization: Bearer. |
403 | admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope. |
404 | not_found: the shop has no such record. |
429 | Rate limited. |
Change an order's status
admin.orders.updateStatus(id: number, input: OrderStatusInput, options?: RequestOptions): Promise<Order>
Moves the order to a status. Nothing goes back to unconfirmed; a move the order's status doesn't allow is 422 invalid_transition. With notifyCustomer, a cancelled order's customer is emailed. Send the updatedAt you read in input so a newer order is refused with 409 edit_conflict. Scope: orders:write.
Parameters
| Parameter |
Type |
|
id |
number |
The order's id. |
input |
object |
The fields below. |
options |
RequestOptions |
idempotencyKey, signal and headers (see retries). |
Request fields
| Field | Type | Description |
|---|
status required | string | One of pending, processing, ready_to_ship, shipped, completed, cancelled. |
note | string or null | At most 1000 characters. |
notifyCustomer | boolean or null | Default false. |
updatedAt | string (date-time) or null | The record's updatedAt as you read it; a newer record gets 409 edit_conflict. |
Returns
The changed Order:
| Field | Type | Description |
|---|
id | integer | |
orderNumber | string | |
status | string | One of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled. |
paymentStatus | string or null | |
paymentMethod | string or null | |
source | string | checkout, whatsapp, quotation or enquiry. |
placedAt | string (date-time) or null | |
paidAt | string (date-time) or null | |
customer | object | |
customer.id | integer or null | |
customer.name | string or null | |
customer.email | string or null | |
customer.phone | string or null | |
shippingAddress | object | |
shippingAddress.line1 | string or null | |
shippingAddress.line2 | string or null | |
shippingAddress.neighbourhood | string or null | |
shippingAddress.city | string or null | |
shippingAddress.state | string or null | |
shippingAddress.postalCode | string or null | |
shippingAddress.countryCode | string or null | |
billingAddress | object or null | Null when billing is the shipping address. |
billingAddress.name | string or null | |
billingAddress.phone | string or null | |
billingAddress.line1 | string or null | |
billingAddress.line2 | string or null | |
billingAddress.city | string or null | |
billingAddress.state | string or null | |
billingAddress.postalCode | string or null | |
billingAddress.countryCode | string or null | |
shippingMethod | string or null | |
notes | string or null | |
items | array of object | |
items[].productId | integer or null | |
items[].title | string or null | |
items[].sku | string or null | |
items[].quantity | integer | |
items[].unitPrice | Money | Fields: amount, currency, formatted. |
items[].total | Money | Fields: amount, currency, formatted. |
subtotal | Money | Fields: amount, currency, formatted. |
discount | Money | Fields: amount, currency, formatted. |
couponCode | string or null | |
shippingFee | Money | Fields: amount, currency, formatted. |
tax | Money | Fields: amount, currency, formatted. |
total | Money | Fields: amount, currency, formatted. |
refunded | Money | Fields: amount, currency, formatted. |
shipment | object or null | |
shipment.carrier | string or null | |
shipment.trackingNumber | string or null | |
shipment.status | string or null | The shipment status's label, in the response language. |
receiptUrl | string (uri) | |
updatedAt | string (date-time) or null | |
Errors
| Status | When |
|---|
401 | invalid_api_key: no active Admin key in Authorization: Bearer. |
403 | admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope. |
404 | not_found: the shop has no such record. |
409 | edit_conflict (the record changed after If-Unmodified-Since or updatedAt), or idempotency_in_progress. |
422 | Validation errors, invalid_transition, or an idempotency refusal. |
429 | Rate limited. |
Example
const order = await admin.orders.get(1042);
await admin.orders.updateStatus(1042, {
status: 'processing',
note: 'Picked in the warehouse',
notifyCustomer: false,
updatedAt: order.updatedAt, // 409 edit_conflict if it changed
});
Record a shipment
admin.orders.recordShipment(id: number, input: OrderShipmentInput, options?: RequestOptions): Promise<Order>
Records the carrier and tracking number your own system booked, once, while the order is ready to ship or shipped (409 shipment_not_allowed otherwise). carrierName is required when carrier is other. Scope: orders:write.
Parameters
| Parameter |
Type |
|
id |
number |
The order's id. |
input |
object |
The shipment's fields, below. |
options |
RequestOptions |
idempotencyKey, signal and headers (see retries). |
Request fields
| Field | Type | Description |
|---|
carrier required | string | One of dhl, ups, fedex, aramex, smsa, dhl_ecommerce, babel_express, other. |
carrierName | string or null | Required when carrier is other. At most 100 characters. |
trackingNumber required | string | At most 60 characters. |
trackingUrl | string (uri) or null | At most 1000 characters. |
Returns
The changed Order:
| Field | Type | Description |
|---|
id | integer | |
orderNumber | string | |
status | string | One of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled. |
paymentStatus | string or null | |
paymentMethod | string or null | |
source | string | checkout, whatsapp, quotation or enquiry. |
placedAt | string (date-time) or null | |
paidAt | string (date-time) or null | |
customer | object | |
customer.id | integer or null | |
customer.name | string or null | |
customer.email | string or null | |
customer.phone | string or null | |
shippingAddress | object | |
shippingAddress.line1 | string or null | |
shippingAddress.line2 | string or null | |
shippingAddress.neighbourhood | string or null | |
shippingAddress.city | string or null | |
shippingAddress.state | string or null | |
shippingAddress.postalCode | string or null | |
shippingAddress.countryCode | string or null | |
billingAddress | object or null | Null when billing is the shipping address. |
billingAddress.name | string or null | |
billingAddress.phone | string or null | |
billingAddress.line1 | string or null | |
billingAddress.line2 | string or null | |
billingAddress.city | string or null | |
billingAddress.state | string or null | |
billingAddress.postalCode | string or null | |
billingAddress.countryCode | string or null | |
shippingMethod | string or null | |
notes | string or null | |
items | array of object | |
items[].productId | integer or null | |
items[].title | string or null | |
items[].sku | string or null | |
items[].quantity | integer | |
items[].unitPrice | Money | Fields: amount, currency, formatted. |
items[].total | Money | Fields: amount, currency, formatted. |
subtotal | Money | Fields: amount, currency, formatted. |
discount | Money | Fields: amount, currency, formatted. |
couponCode | string or null | |
shippingFee | Money | Fields: amount, currency, formatted. |
tax | Money | Fields: amount, currency, formatted. |
total | Money | Fields: amount, currency, formatted. |
refunded | Money | Fields: amount, currency, formatted. |
shipment | object or null | |
shipment.carrier | string or null | |
shipment.trackingNumber | string or null | |
shipment.status | string or null | The shipment status's label, in the response language. |
receiptUrl | string (uri) | |
updatedAt | string (date-time) or null | |
Errors
| Status | When |
|---|
401 | invalid_api_key: no active Admin key in Authorization: Bearer. |
403 | admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope. |
404 | not_found: the shop has no such record. |
409 | shipment_not_allowed, or idempotency_in_progress. |
422 | Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid). |
429 | Rate limited. |
Example
await admin.orders.recordShipment(1042, {
carrier: 'aramex',
trackingNumber: '1234567890',
});