Atomically apply one or more edits to an existing order
Inserts items and / or adds general-purpose adjustments to an order
in a single DB transaction. After the operations run, the eight
current_* totals on the order are recalculated and an order-edit
audit record is written per operation.
On success, the order_edited lifecycle event fires so subscribed
webhooks receive the post-edit payload.
editor_type and editor_id are derived from the authenticated
credential — droplet installations land as ("droplet", handle),
admin user_company tokens as ("admin", user_company.id), other
tokens as ("system", auth_type). The payload itself never
carries these fields.
A typical use case is a droplet-driven free-gift flow: insert
a X credit adjustment in one block; the
order’s current_amount is unchanged, but the audit log captures
both operations and webhook subscribers see the updated state.
Authorizations
Bearer token authentication. Accepts company tokens, partner tokens,
public tokens, droplet installation tokens, and user_company tokens.
The authenticated credential determines editor_type and editor_id
on the resulting order-edit audit records — the payload never carries
either field.
Headers
Optional client-generated key (UUID recommended) that the server
uses to deduplicate retries. The first request with a given key
executes normally; subsequent requests with the same key return
the cached response with X-Idempotent-Replayed: true for 24
hours. A concurrent retry while the first is still in flight
returns HTTP 409. The cache is scoped to the authenticated
company.
255Path Parameters
Primary-key id of the order to edit. Must belong to the authenticated company; an unknown id or an order owned by another company returns 404.
Body
One or more edit operations to apply atomically. The whole transaction commits or rolls back together.
1- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
Optional optimistic-concurrency guard. When provided, the
server compares against the order's current updated_at
before applying any operations and returns HTTP 409 with
the current value on mismatch. Pass the ISO-8601 string
received in a prior order response verbatim. Callers that
don't load the order first can omit this and bypass the
check.
Response
Edit applied successfully. Returns the updated order.
Order response wrapper. The order object includes the eight
recalculated current_* totals plus the adjustments array.
Edit history is not exposed through this API.