Store Hugs Developers

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

ParameterTypeDescription
statusany
paymentStatusany
sourceany
limitintegerAt least 1. At most 100. Default 50.
cursorstringmeta.nextCursor (or the cursor in links.next) of the previous page. At most 1000 characters.
updatedSincestring (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>:

FieldTypeDescription
linksobject
links.firstnull
links.lastnull
links.prevstring (uri) or null
links.nextstring (uri) or null
metaobject
meta.pathstring (uri)
meta.perPageinteger
meta.nextCursorstring or null
meta.prevCursorstring or null
dataarray of Order
data[].idinteger
data[].orderNumberstring
data[].statusstringOne of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled.
data[].paymentStatusstring or null
data[].paymentMethodstring or null
data[].sourcestringcheckout, whatsapp, quotation or enquiry.
data[].placedAtstring (date-time) or null
data[].paidAtstring (date-time) or null
data[].customerobject
data[].customer.idinteger or null
data[].customer.namestring or null
data[].customer.emailstring or null
data[].customer.phonestring or null
data[].shippingAddressobject
data[].shippingAddress.line1string or null
data[].shippingAddress.line2string or null
data[].shippingAddress.neighbourhoodstring or null
data[].shippingAddress.citystring or null
data[].shippingAddress.statestring or null
data[].shippingAddress.postalCodestring or null
data[].shippingAddress.countryCodestring or null
data[].billingAddressobject or nullNull when billing is the shipping address.
data[].billingAddress.namestring or null
data[].billingAddress.phonestring or null
data[].billingAddress.line1string or null
data[].billingAddress.line2string or null
data[].billingAddress.citystring or null
data[].billingAddress.statestring or null
data[].billingAddress.postalCodestring or null
data[].billingAddress.countryCodestring or null
data[].shippingMethodstring or null
data[].notesstring or null
data[].itemsarray of object
data[].items[].productIdinteger or null
data[].items[].titlestring or null
data[].items[].skustring or null
data[].items[].quantityinteger
data[].items[].unitPriceMoneyFields: amount, currency, formatted.
data[].items[].totalMoneyFields: amount, currency, formatted.
data[].subtotalMoneyFields: amount, currency, formatted.
data[].discountMoneyFields: amount, currency, formatted.
data[].couponCodestring or null
data[].shippingFeeMoneyFields: amount, currency, formatted.
data[].taxMoneyFields: amount, currency, formatted.
data[].totalMoneyFields: amount, currency, formatted.
data[].refundedMoneyFields: amount, currency, formatted.
data[].shipmentobject or null
data[].shipment.carrierstring or null
data[].shipment.trackingNumberstring or null
data[].shipment.statusstring or nullThe shipment status's label, in the response language.
data[].receiptUrlstring (uri)
data[].updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_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.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate 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:

FieldTypeDescription
[].idinteger
[].orderNumberstring
[].statusstringOne of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled.
[].paymentStatusstring or null
[].paymentMethodstring or null
[].sourcestringcheckout, whatsapp, quotation or enquiry.
[].placedAtstring (date-time) or null
[].paidAtstring (date-time) or null
[].customerobject
[].customer.idinteger or null
[].customer.namestring or null
[].customer.emailstring or null
[].customer.phonestring or null
[].shippingAddressobject
[].shippingAddress.line1string or null
[].shippingAddress.line2string or null
[].shippingAddress.neighbourhoodstring or null
[].shippingAddress.citystring or null
[].shippingAddress.statestring or null
[].shippingAddress.postalCodestring or null
[].shippingAddress.countryCodestring or null
[].billingAddressobject or nullNull when billing is the shipping address.
[].billingAddress.namestring or null
[].billingAddress.phonestring or null
[].billingAddress.line1string or null
[].billingAddress.line2string or null
[].billingAddress.citystring or null
[].billingAddress.statestring or null
[].billingAddress.postalCodestring or null
[].billingAddress.countryCodestring or null
[].shippingMethodstring or null
[].notesstring or null
[].itemsarray of object
[].items[].productIdinteger or null
[].items[].titlestring or null
[].items[].skustring or null
[].items[].quantityinteger
[].items[].unitPriceMoneyFields: amount, currency, formatted.
[].items[].totalMoneyFields: amount, currency, formatted.
[].subtotalMoneyFields: amount, currency, formatted.
[].discountMoneyFields: amount, currency, formatted.
[].couponCodestring or null
[].shippingFeeMoneyFields: amount, currency, formatted.
[].taxMoneyFields: amount, currency, formatted.
[].totalMoneyFields: amount, currency, formatted.
[].refundedMoneyFields: amount, currency, formatted.
[].shipmentobject or null
[].shipment.carrierstring or null
[].shipment.trackingNumberstring or null
[].shipment.statusstring or nullThe shipment status's label, in the response language.
[].receiptUrlstring (uri)
[].updatedAtstring (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:

FieldTypeDescription
idinteger
orderNumberstring
statusstringOne of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled.
paymentStatusstring or null
paymentMethodstring or null
sourcestringcheckout, whatsapp, quotation or enquiry.
placedAtstring (date-time) or null
paidAtstring (date-time) or null
customerobject
customer.idinteger or null
customer.namestring or null
customer.emailstring or null
customer.phonestring or null
shippingAddressobject
shippingAddress.line1string or null
shippingAddress.line2string or null
shippingAddress.neighbourhoodstring or null
shippingAddress.citystring or null
shippingAddress.statestring or null
shippingAddress.postalCodestring or null
shippingAddress.countryCodestring or null
billingAddressobject or nullNull when billing is the shipping address.
billingAddress.namestring or null
billingAddress.phonestring or null
billingAddress.line1string or null
billingAddress.line2string or null
billingAddress.citystring or null
billingAddress.statestring or null
billingAddress.postalCodestring or null
billingAddress.countryCodestring or null
shippingMethodstring or null
notesstring or null
itemsarray of object
items[].productIdinteger or null
items[].titlestring or null
items[].skustring or null
items[].quantityinteger
items[].unitPriceMoneyFields: amount, currency, formatted.
items[].totalMoneyFields: amount, currency, formatted.
subtotalMoneyFields: amount, currency, formatted.
discountMoneyFields: amount, currency, formatted.
couponCodestring or null
shippingFeeMoneyFields: amount, currency, formatted.
taxMoneyFields: amount, currency, formatted.
totalMoneyFields: amount, currency, formatted.
refundedMoneyFields: amount, currency, formatted.
shipmentobject or null
shipment.carrierstring or null
shipment.trackingNumberstring or null
shipment.statusstring or nullThe shipment status's label, in the response language.
receiptUrlstring (uri)
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_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.
404not_found: the shop has no such record.
429Rate 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

FieldTypeDescription
status requiredstringOne of pending, processing, ready_to_ship, shipped, completed, cancelled.
notestring or nullAt most 1000 characters.
notifyCustomerboolean or nullDefault false.
updatedAtstring (date-time) or nullThe record's updatedAt as you read it; a newer record gets 409 edit_conflict.

Returns

The changed Order:

FieldTypeDescription
idinteger
orderNumberstring
statusstringOne of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled.
paymentStatusstring or null
paymentMethodstring or null
sourcestringcheckout, whatsapp, quotation or enquiry.
placedAtstring (date-time) or null
paidAtstring (date-time) or null
customerobject
customer.idinteger or null
customer.namestring or null
customer.emailstring or null
customer.phonestring or null
shippingAddressobject
shippingAddress.line1string or null
shippingAddress.line2string or null
shippingAddress.neighbourhoodstring or null
shippingAddress.citystring or null
shippingAddress.statestring or null
shippingAddress.postalCodestring or null
shippingAddress.countryCodestring or null
billingAddressobject or nullNull when billing is the shipping address.
billingAddress.namestring or null
billingAddress.phonestring or null
billingAddress.line1string or null
billingAddress.line2string or null
billingAddress.citystring or null
billingAddress.statestring or null
billingAddress.postalCodestring or null
billingAddress.countryCodestring or null
shippingMethodstring or null
notesstring or null
itemsarray of object
items[].productIdinteger or null
items[].titlestring or null
items[].skustring or null
items[].quantityinteger
items[].unitPriceMoneyFields: amount, currency, formatted.
items[].totalMoneyFields: amount, currency, formatted.
subtotalMoneyFields: amount, currency, formatted.
discountMoneyFields: amount, currency, formatted.
couponCodestring or null
shippingFeeMoneyFields: amount, currency, formatted.
taxMoneyFields: amount, currency, formatted.
totalMoneyFields: amount, currency, formatted.
refundedMoneyFields: amount, currency, formatted.
shipmentobject or null
shipment.carrierstring or null
shipment.trackingNumberstring or null
shipment.statusstring or nullThe shipment status's label, in the response language.
receiptUrlstring (uri)
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_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.
404not_found: the shop has no such record.
409edit_conflict (the record changed after If-Unmodified-Since or updatedAt), or idempotency_in_progress.
422Validation errors, invalid_transition, or an idempotency refusal.
429Rate 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

FieldTypeDescription
carrier requiredstringOne of dhl, ups, fedex, aramex, smsa, dhl_ecommerce, babel_express, other.
carrierNamestring or nullRequired when carrier is other. At most 100 characters.
trackingNumber requiredstringAt most 60 characters.
trackingUrlstring (uri) or nullAt most 1000 characters.

Returns

The changed Order:

FieldTypeDescription
idinteger
orderNumberstring
statusstringOne of unconfirmed, pending, processing, ready_to_ship, shipped, completed, cancelled.
paymentStatusstring or null
paymentMethodstring or null
sourcestringcheckout, whatsapp, quotation or enquiry.
placedAtstring (date-time) or null
paidAtstring (date-time) or null
customerobject
customer.idinteger or null
customer.namestring or null
customer.emailstring or null
customer.phonestring or null
shippingAddressobject
shippingAddress.line1string or null
shippingAddress.line2string or null
shippingAddress.neighbourhoodstring or null
shippingAddress.citystring or null
shippingAddress.statestring or null
shippingAddress.postalCodestring or null
shippingAddress.countryCodestring or null
billingAddressobject or nullNull when billing is the shipping address.
billingAddress.namestring or null
billingAddress.phonestring or null
billingAddress.line1string or null
billingAddress.line2string or null
billingAddress.citystring or null
billingAddress.statestring or null
billingAddress.postalCodestring or null
billingAddress.countryCodestring or null
shippingMethodstring or null
notesstring or null
itemsarray of object
items[].productIdinteger or null
items[].titlestring or null
items[].skustring or null
items[].quantityinteger
items[].unitPriceMoneyFields: amount, currency, formatted.
items[].totalMoneyFields: amount, currency, formatted.
subtotalMoneyFields: amount, currency, formatted.
discountMoneyFields: amount, currency, formatted.
couponCodestring or null
shippingFeeMoneyFields: amount, currency, formatted.
taxMoneyFields: amount, currency, formatted.
totalMoneyFields: amount, currency, formatted.
refundedMoneyFields: amount, currency, formatted.
shipmentobject or null
shipment.carrierstring or null
shipment.trackingNumberstring or null
shipment.statusstring or nullThe shipment status's label, in the response language.
receiptUrlstring (uri)
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_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.
404not_found: the shop has no such record.
409shipment_not_allowed, or idempotency_in_progress.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

await admin.orders.recordShipment(1042, {
    carrier: 'aramex',
    trackingNumber: '1234567890',
});