Edits, deletes or adds lines on an unpaid or part-paid sale, and can merge metadata onto the sale. Omitted fields stay unchanged. Promoted lines can be edited too.
You can also use this on an unpaid return (a sale with a negative total, no payments and no linked return lines — usually stored as overpaid). A sale that's a return or refund, or that has had lines returned, can't be edited this way.
Send an object with any of these keys:
lines— changes to existing lines. Each entry needsid. You can sendquantity,item_price,item_tax,item_discount,item_discount_reasonandmetadata. Setdeletetotrueto hard-delete the line along with its metadata and tags; don't combinedeletewith other fields on that line. Quantity can't be0(usedelete) or negative (returns can't be created by editing).add— new lines, in the same shape as Add lines to a sale.metadata— sale-level metadata to merge. To change only sale metadata, send just this key; there isn't a separate metadata endpoint.
Line and sale metadata are merge-only: keys are added or updated, never deleted. Each value's type is int or string, and each value can be at most 1024 bytes. Sending item_discount as 0 clears the discount reason.
Totals are recalculated from the line changes. Shipping tax and sale-level loyalty are kept.
The response is the updated sale, in the same shape as Get a sale. A request that changes nothing still returns 200 and fires no hooks.
When the request changes the sale, a sale_update hook fires with {before, after}. If lines were added, sale_lines_add fires as well (same payload as Add lines to a sale), and giftcard_create fires for each added gift card line. If the sale becomes paid, each Inactive fulfillment is opened and a fulfillment_status_change hook fires with {before, after} for that fulfillment.
Required permission:
| Group | Permission |
|---|---|
| Sales | Create, edit and delete sales; manage = create sales and change their staff member or customer (includes view) |
