Skip to main content

Create Sales Credit

POST 

/api/sales-credits

Creates a new sales credit. Must be linked to either a sales_order_id or a customer_id.

Required scope: orders:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Authentication: Requires Bearer token.

Fields:

  • sales_order_id (required if no customer_id): Sales order ID to credit against
  • customer_id (required if no sales_order_id): Customer ID for non-order credits
  • sales_credit_number (optional, max 255): Custom credit number (auto-generated if omitted)
  • credit_date (optional, date): Credit date
  • store_id (optional): Store ID
  • to_warehouse_id (optional): Return destination warehouse ID
  • sales_credit_note (optional): Free-form note
  • currency_id (optional): Currency ID (defaults to account default)
  • currency_code (optional): Currency code (alternative to currency_id)
  • tax_rate_id (optional): Tax rate ID
  • is_tax_included (optional, boolean): Whether prices include tax. Default: false
  • is_product (optional, boolean): Whether this is a product return. Default: false
  • tax_lines (optional): Array of tax line objects
  • sales_credit_lines (optional): Array of credit lines — each with sales_order_line_id, quantity, and price

Quantity limit: a line linked to a sales order line (sales_order_line_id) may credit at most what is still creditable on that line — its ordered quantity (cancelled and returned units are part of the ordered quantity, not extra) less what other sales credits already claim. A larger quantity is refused with 422 and nothing is saved; the message names the line and states the remaining, ordered and already-credited counts. Validation error key: sales_credit_lines.{index}.quantity. Lines of the same credit that point at the same sales order line (or the same fee line) are capped together: two lines of 8 on a 10-unit line are refused with the same 422.

A credit can only credit lines of its own sales order. A line whose sales_order_line_id belongs to another order is refused with a 422 naming the line and both orders.

Request​

Responses​

OK

Response Headers
    Content-Type