Exchange Sales Order
POST/api/sales-orders/:salesOrder/exchange
Creates an exchange order for an existing order (e.g. swapping returned items), linked to the original order or to a sales credit, and returns the new order's full detail.
orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
The new order is a copy of the original with:
- order number
{original}-E-{YYYYMMDD}and order date set to now - only the requested lines, at the requested quantities, keeping the original line prices
- a sales-credit payment automatically recorded for the new order's total (the exchange is paid by credit), and the order is approved immediately
- an exchange link to the sales credit when
sales_credit_idis provided, otherwise to the original order
Authentication: Requires Bearer token.
Request body fields:
- sales_order_lines (array, optional): Lines to exchange. Each item: id (integer, required — must be a line of this order), quantity (number, required).
- sales_credit_id (integer, optional): Existing sales credit to link the exchange order to.
Path parameters:
- salesOrder (required): Sales order ID to exchange from.
Requires permission: sales_orders.update
Request
Responses
- 200
- 401
- 403
- 404
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Not found — no record with the given identifier (or the route does not exist). Verify the ID before retrying.
Unprocessable Entity
Response Headers
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.