OptionaldefaultLocationId: stringCreate a new order builder
OptionallocationId: string
Optional location ID (uses default if not provided)
Order builder instance
Create an order directly (without builder)
Order creation options
OptionallocationId: string
Optional location ID
Created order
Get an order by ID
Order ID
Order details, including its tenders (the payments applied to
it) and each tax's appliedMoney
Pay for an order
Order ID
Payment IDs to apply
Optionaloptions: { idempotencyKey?: string }
OptionalidempotencyKey?: stringReuse the same key when retrying
Updated order
Search for orders
Optionaloptions: SearchOrdersOptions
Search options including query filters and sort
Paginated list of orders
// Simple search
const { data, cursor } = await square.orders.search({
locationIds: ['LXXX'],
limit: 10,
});
// Search with filters
const { data } = await square.orders.search({
locationIds: ['LXXX'],
query: {
filter: {
dateTimeFilter: {
createdAt: {
startAt: '2024-01-01T00:00:00Z',
endAt: '2024-12-31T23:59:59Z',
},
},
stateFilter: {
states: ['OPEN', 'COMPLETED'],
},
fulfillmentFilter: {
fulfillmentTypes: ['PICKUP', 'SHIPMENT'],
},
},
sort: {
sortField: 'CREATED_AT',
sortOrder: 'DESC',
},
},
});
Search for recent orders with simplified filter options
Optionaloptions: SearchRecentOrdersOptions
Simplified search options
Paginated list of orders
// Get completed orders from the last hour
const { data } = await square.orders.searchRecent({
states: ['COMPLETED'],
since: new Date(Date.now() - 60 * 60 * 1000),
});
// Get first page of orders from a date range
const { data, cursor } = await square.orders.searchRecent({
since: new Date('2024-01-01'),
until: new Date('2024-01-31'),
limit: 50,
});
// Fetch next page
const page2 = await square.orders.searchRecent({
since: new Date('2024-01-01'),
until: new Date('2024-01-31'),
cursor,
limit: 50,
});
Update an order. Only the fields you set are sent (a sparse update), so everything else on the order is left as it is.
Order ID to update
The order's current version, and the fields to change.
Pass idempotencyKey and reuse it when resending the identical request
(say, after a timeout) so Square deduplicates it. After re-reading the
order for a new version, use a new key: Square rejects a reused key
with a different body.
OptionallocationId: string
Override the client's default location
Updated order
const order = await square.orders.get('ORDER_123');
// Mark a shipment shipped, with tracking
await square.orders.update('ORDER_123', {
version: order.version!,
fulfillments: [{
uid: order.fulfillments![0].uid!,
state: 'COMPLETED',
shipmentDetails: { carrier: 'Canada Post', trackingNumber: '1234567890' },
}],
});
// Cancel an order
await square.orders.update('ORDER_123', { version: order.version!, state: 'CANCELED' });
Orders service for managing Square orders
Example