On Update endpoints (HTTP PATCH verb)
How PATCH treats omitted fields, null, arrays, and addresses.
PATCH /orders/{id} is a partial update. What you leave out of the body is
left untouched, so you can change one nested field without resending the rest
of the order.
Three rules cover every field:
- An omitted field is left unchanged. An empty nested object (
{}) is the same as omitting it, and a body that sets nothing returns the order unchanged. - An explicit
nullclears a nullable field. Sending{"deliveryInstructions": {"notes": null}}removes the notes. - An array replaces the stored array in full. There is no partial update of an array, so send the complete list you want to end up with.
Changing only the delivery notes, for example:
curl -X PATCH "https://api.spoke.com/connect/v1/orders/W3kJpzQm9q4LV2BdH7sNuT" \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{"deliveryInstructions": {"notes": "Leave with the neighbour"}}'The following rules apply when editing an order:
addressis replaced, not merged. An address you send replaces the stored address in full and is geocoded again exactly as on create, so it has to carry at least one field that can locate the delivery. Sending onlyzipdiscards the street lines rather than amending them.deliveryInstructions.handOffInfo.handOffTypecannot be cleared. It acceptspickup_by_courier, and omitting it leaves the stored value alone. The deprecatedship_to_courieris treated aspickup_by_courieruntil a future API version rejects it.packageInfo.weightis replaced as a whole. Send{ amount, unit }to set it,nullto clear it, or omit it to leave it unchanged. Do not send it together with the deprecatedpackageLoadAmountfield, including null values.- Other nested objects cannot be
nullon an edit. Clear the individual leaves instead, for example{"deliveryInstructions": {"proofOfAttemptRequirements": {"enabled": null}}}.
Only an editable order can be updated. An order becomes read-only once the
courier puts it on a route, and an order the courier added on your behalf
(source: "courier") is read-only from the start. Both answer 409 Conflict
with code: "order_read_only".
Was this page helpful?