Skip to main content

Update Sales Credit

PUT 

/api/sales-credits/:sales_credit

Updates a sales credit including its lines. Lines array replaces all existing lines when provided; omit lines to leave them unchanged.

Required scope: orders:write

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

Authentication: Requires Bearer token.

Fields:

  • sales_credit_number (optional, max 255): Custom credit number
  • credit_date (optional, date): Credit date
  • store_id (optional): Store ID
  • to_warehouse_id (optional): Return destination warehouse ID
  • customer_id (optional): Customer ID
  • sales_credit_note (optional): Free-form note
  • currency_id (optional): Currency ID
  • currency_code (optional): Currency code
  • tax_rate_id (optional): Tax rate ID
  • is_tax_included (optional, boolean): Whether prices include tax
  • is_product (optional, boolean): Whether this is a product return
  • tax_lines (optional): Array of tax line objects
  • sales_credit_lines (optional): Array of credit lines to sync

A credit that records a refund made through PayPal (is_paypal_refund: true) is read-only: a request that changes anything other than sales_credit_note returns 422 with the reason. The note stays editable.

Line quantities: sales_credit_lines.*.quantity must be greater than 0 and accepts whole numbers or decimals with up to six decimal places (e.g. 0.5 or 1.25), so fractional credits round-trip unchanged.

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. The error is reported under sales_order_line_id with code quantity_exceeds_remaining_creditable and data holding sales_order_line_id, attempted_quantity, remaining_quantity, ordered_quantity and already_credited_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.

Line nominal_code_id and tax_rate_id may be null (the default nominal code applies), as on create.

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. On update this applies to new lines and to lines re-pointed at another order's line; a line already saved against another order can be re-sent unchanged.

Request​

Responses​

OK

Response Headers
    Content-Type