Create Sales Order Discount
POST/api/sales-orders/:salesOrder/discounts
Adds a discount to a sales order and recalculates the order's discount totals.
orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Authentication: Requires Bearer token.
Request body fields:
- scope (string, required):
line(applies to one product line or charge line) ororder(applies to the whole order). - type (string, required):
percentageorfixed_amount. - rate (number, required when type is
percentage): Percentage rate, 0-100. - amount (number, required when type is
fixed_amount): Discount amount in the order currency, minimum 0. Defaults to 0 when omitted. - name (string, required, max 255): Display label.
- sales_order_line_id (integer, required when scope is
line): Existing product line on the order the discount applies to. - financial_line_id (integer, optional): Existing charge line (e.g. shipping) the discount applies to instead of a product line.
- source_type (string, optional, max 50): Origin of the discount. Defaults to
manual. - source_reference (string, optional, max 255): External reference such as a coupon code.
- apply_before_tax (boolean, optional, default true): Whether the discount applies before tax is calculated.
- sequence (integer, optional, min 0, default 0): Application order — lower values apply first.
Behavior:
- Creating a discount immediately recalculates the order: per-line discount totals, proportional allocation of order-level discounts across product lines (any rounding remainder goes to the largest line), and the order's denormalized discount totals.
- For percentage discounts the effective
amountis computed during this recalculation and returned in the response. - Order-level percentage discounts are based on the order subtotal after line discounts; tax is included in the base when the order is configured to discount the grand total.
The response is the created discount object (no envelope), returned with status 201.
Path parameters:
- salesOrder (required): Sales order ID.
Requires permission: sales_orders.update
Request
Responses
- 201
- 401
- 403
- 404
- 422
- 429
Created
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.