APIOrder

Bulk update orders

POST
/public/v1/orders/bulk-update

Set the same values on up to 20 sales orders in one call, and get back one result per order. Send the order IDs in order_ids and the fields to set in changes: the customer and its billing and shipping locations, the owner, the notes, the status and custom fields. To change line items, charges or dates, use POST /public/v1/orders on each order.

changes is sparse: a field you omit is left unchanged on every order, and a field sent as null is cleared, except company_id and status, which can't be null. custom_data itself can't be null: only the custom fields you list change, and a field sent as null is cleared. Changing the customer (company_id) needs billing_location_id and shipping_location_id too (null allowed), since the old ones belong to the old customer.

The request is checked as a whole first. It is refused, and no order is changed, when order_ids is empty, has more than 20 entries, lists an ID that doesn't exist for your company (404) or that your team can't see (403), or when changes is empty or invalid (an unknown status, an unknown custom field, a value of the wrong type, clearing a required custom field, a customer change without both locations, a customer that doesn't exist for your company or that your team can't see, a location that is neither your company's nor one of your customers', an owner you can't assign). With Distru Commerce, a customer change is also refused when the orders were placed on your menu by more than one buyer: each order would link the new customer to its own buyer. A repeated ID gets one result, but each entry counts toward the limit.

Then each order is saved on its own, as an update through POST /public/v1/orders or the Distru app's order form, with four exceptions: an order missing a value for a required custom field still saves, line prices stay as they are (price tiers are not applied again, even after a customer change), charges and taxes keep their amounts, and invoices and shipments are not updated. One order failing doesn't stop the others, and the ones saved stay saved. The 200 response lists every order in the order sent, each with a status: • UPDATED: saved. Also returned when the order already had these values. • FAILED: refused by a save rule, such as a status the order can't move to yet, a customer change on an order with returns, a merged order, a location that isn't the order's customer's, or a custom validation rule your company has set up. message says why.

Each saved order has the same effects as a single update: a status change reserves, commits or releases inventory as the status field on the order describes, webhooks fire, and the order's invoices already in QuickBooks Online are queued for resync when their QuickBooks Online data changed. Point-of-sale and LeafLink syncs run as for a single update. Each order's syncs start when that order saves and finish in the background, possibly after the response, so poll the other system to observe them.

Invoices and shipments keep their details. Moving an order to CANCELED still voids all its invoices, and moving it out of CANCELED un-voids them.

Each order takes a few seconds to save, so a full request can take over a minute. If it times out, some orders may already be saved, and the rest may still be saving. Wait a couple of minutes before sending it again: a resend sets the same values again, overwriting any change made to these orders since.

Required permission: orders_permissions_edit, plus access to every listed order under team restrictions.

Authorization

Bearer
headerAuthorizationBearer <token>

API token generated in Distru (Settings → Distru API). Send it on every request as Authorization: Bearer YOUR_API_TOKEN.

Request Body

The orders and the changes

application/json
  1. body
changes*

The fields to set on every listed order. Omit a field to leave it unchanged; send null to clear it, where the field allows it.

order_ids*array<string>

The IDs of the orders to update, 1 to 20 entries, repeats included. Every one must be an order of your company that your team can see. A repeated ID gets one result.

Response Body

One result per order

*/*
  1. response
data*array<>

One result per order, in the order the IDs were sent.

Example Request
curl -X POST 'https://app.distru.com/public/v1/orders/bulk-update' \  -H 'Content-Type: application/json' \  -d '{  "changes": {    "billing_location_id": "00000000-0000-0000-0000-000000000420",    "company_id": "00000000-0000-0000-0000-000000000611",    "custom_data": {      "109": "X"    },    "external_notes": "E",    "internal_notes": "N",    "owner_id": "00000000-0000-0000-0000-0000000013c7",    "shipping_location_id": "00000000-0000-0000-0000-000000000420"  },  "order_ids": [    "7c016cf8-0ff8-4d48-9d27-2f11680401a0",    "38e66923-5b6a-4732-9ef4-193acdc319aa",    "7057e7e2-a97f-4bae-9351-f2e22bd338c3",    "7c016cf8-0ff8-4d48-9d27-2f11680401a0"  ]}'
Example Response
{  "data": [    {      "message": null,      "order_id": "7c016cf8-0ff8-4d48-9d27-2f11680401a0",      "status": "UPDATED"    },    {      "message": null,      "order_id": "38e66923-5b6a-4732-9ef4-193acdc319aa",      "status": "UPDATED"    },    {      "message": "Cannot change the customer on orders with associated returns",      "order_id": "7057e7e2-a97f-4bae-9351-f2e22bd338c3",      "status": "FAILED"    }  ]}