Edit sale lines

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 needs id. You can send quantity, item_price, item_tax, item_discount, item_discount_reason and metadata. Set delete to true to hard-delete the line along with its metadata and tags; don't combine delete with other fields on that line. Quantity can't be 0 (use delete) 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:

GroupPermission
SalesCreate, edit and delete sales; manage = create sales and change their staff member or customer (includes view)
Path Params
int64
required

ID of the sale.

Body Params
lines
array of objects

Changes to existing lines. Each entry needs id. Omitted fields stay unchanged.

lines
add
array of objects

Lines to add, in the same shape as Add lines to a sale.

add
metadata
object

Metadata to merge, grouped by namespace and then key. Keys are added or updated, never deleted.

Responses

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json