Skip to main content
Omneya
EN
Start test system Try it
Developer docs menu

Update an order

Change the status, payment method, addresses and items of an order of your shop in one request.

What you can change

PATCH /orders/{orderId} changes one order by our order number. The key needs the scope orders.update; the operator grants it separately from orders.write.

Every order of the shop assigned to your access can be changed, no matter how it was placed. Send only the blocks you want to change, at least one of them:

  • order_status_id: an ID from GET /order-statuses.
  • payment_method_id: an ID from GET /payment-methods. The same rules as for a new order apply; for the collective invoice the customer of the order must be approved.
  • billing: the complete billing address; it replaces the old one.
  • shipping: the complete delivery address, or null (also {}) to remove it. The order then goes to the billing address.
  • items: add, update and remove, see below.
curl -X PATCH https://shop.example.com/api/v1/orders/104233 \
  -H "Authorization: Bearer $OMNEYA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Idempotency-Key: 6f1c2a8e-3b7d-4c55-9a0e-1d2f3a4b5c6d" \
  -d '{"items": {"update": [{"item_id": 88120, "quantity": 3}], "remove": [88121]}}'

The answer is the changed order in the same format as GET /orders/{orderId}, with the new totals.

Changing items

Each item of an order has an item_id, returned by GET /orders/{orderId} and by this endpoint.

  • items.add: new items with sku or article_id, quantity and an optional price. With price the item gets a fixed price; without it (or with null) the shop’s price applies, as for a new order.
  • items.update: item_id with quantity, price or both. Only what you send changes. A quantity change alone keeps the price of an item with a fixed price; all other items are priced again by the shop’s price rules, including volume prices. A sent price becomes a fixed price. Its tax rate is the rate of the delivery country after this request: if the same request changes the billing or delivery address to another country, the item gets the rate of the new country. If the shop has no tax rate for the article in that country, the request is rejected with article_tax_unresolved for items.update.N.price and nothing is changed.

A price of 0 is allowed and is a fixed price of 0: the item is free of charge and stays free when the quantity changes. To return an item to the shop’s price, remove it and add it again without price.

  • items.remove: a list of item_ids.

At most 100 entries are allowed per request in add, update and remove together. An item_id may appear only once, and not in update and remove at the same time. An item that is already partly delivered cannot be removed, and its quantity cannot be lower than the delivered quantity (item_already_delivered). The order must keep at least one item (order_empty); to empty an order, change its status to a cancelled status.

Totals, tax, shipping and the stock reservation are recalculated once per request.

When nothing is changed

All checks run before anything is written, and every problem comes back at once. If one entry is invalid, the whole request changes nothing:

  • 422 validation_failed: details lists every problem per field, for example items.update.0.item_id with unknown_item, or body with required if no block was sent. A field of the body that is not known on its level is rejected with unknown_field (for example items.update.0.qty instead of quantity, or billing.zip instead of postcode), never ignored. Query parameters in the URL are not checked. An article in items.add that is reserved for another customer is rejected with article_reserved.
  • 422 client_not_configured: no shop is assigned to your access; ask the operator to assign one.
  • 409 order_locked: the order is finalised (invoiced), cancelled or shipped (or all its goods are booked out). Items, addresses and the payment method can no longer be changed. To change the status of such an order, send order_status_id alone. The same code comes back if the new status would cancel a credit note that is already settled in a collective invoice. In one case this answer comes after other changes were saved: if the credit note was settled while the other changes of your request were being saved, those changes stay saved and only the status is not changed. The message says so. If you get 409 order_locked after a request that also changed other blocks, load the order with GET /orders/{orderId} before you send anything again.
  • 409 stock_locked: a running stocktake locks the stock. Retry later.
  • 404 not_found: unknown order number, deleted order, or an order of another shop.

All codes are listed in the error codes.

When the status could not be changed

The status is changed last, after all other changes of the request are saved. If that step fails with an unexpected error, the answer is still 200: the other changes are saved, the order shows its old status, and warnings contains status_not_changed with a reference that identifies the case in our log. Send order_status_id alone again to retry, or pass the reference to the shop operator.

Sending a request again

Sending the current state again changes nothing and answers 200; no history entry is written. This is not true for items.add: sending the same add twice adds the items twice.

To retry safely after a timeout, send your own unique key in the header Idempotency-Key (at most 191 characters, for example a UUID) and send exactly the same body again with the same key. The comparison is byte by byte, so send the body exactly as you sent it the first time, not a newly serialised copy with a different key order or spacing. Within 24 hours you get the stored answer, marked with Idempotent-Replayed: true, and nothing is changed a second time. The same key with a different body answers 422 idempotency_key_reused; use a new key for every new change. If the first request is still running, the second waits a few seconds and may answer 409 conflict; retry it. Answers with status 5xx and 409 stock_locked are not stored, so a retry with the same key runs again. All other answers are stored for 24 hours, also errors such as 422 validation_failed or 409 order_locked: sending the same key again returns the same error. After you correct the request, send it with a new key. See also Retries and duplicates.