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(array $query = []): array
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 |
array |
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
An array with data (a list of Order), links and meta:
| 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
$query = ['status' => 'processing', 'limit' => 50];
do {
$page = $admin->orders->list($query);
// … $page['data']
$query['cursor'] = $page['meta']['nextCursor'];
} while ($query['cursor'] !== null);
Iterate over every order
$admin->orders->all(array $query = []): Generator
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
A generator of Order arrays, 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
foreach ($admin->orders->all(['updatedSince' => $lastSyncedAt]) as $order) {
$erp->saveOrder($order);
}
Get an order
$admin->orders->get(int $id): array
One order by its id, with its lines, totals, addresses and shipment. Scope: orders:read.
Parameters
| Parameter |
Type |
|
$id |
int |
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(int $id, array $input, string|false|null $idempotencyKey = null): array
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 |
int |
The order's id. |
$input |
array |
The fields below. |
$idempotencyKey |
string|false|null |
Your own Idempotency-Key, or false for none. One is made for you when null. |
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
$order = $admin->orders->get(1042);
$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(int $id, array $input, string|false|null $idempotencyKey = null): array
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 |
int |
The order's id. |
$input |
array |
The shipment's fields, below. |
$idempotencyKey |
string|false|null |
Your own Idempotency-Key, or false for none. One is made for you when null. |
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
$admin->orders->recordShipment(1042, [
'carrier' => 'aramex',
'trackingNumber' => '1234567890',
]);