Creates a sales return against a sales order.

POST /accounting/sales-returns

Group: Accounting › Sales Returns · Operation ID: createAccountingSalesReturn

Open in the interactive reference

Parameters

Name In Type Required Description
Api-Version header "v1" yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.

Request body

Required, application/json: createAccountingSalesReturnInput.

Field Type Required Description
salesOrderId string yes The sales order to return against. The order must be partially or fully invoiced. See id on GET accounting/sales-orders/:id.
returnType string yes The resolution path for the return. Accepted values: 'credit', 'replacement'. It cannot be changed once the return moves past 'draft'.
returnDate string yes The transaction date for the return. Use format YYYY-MM-DD.
reasonCode string no The header-level reason for the return. Accepted values: 'defectiveItem', 'wrongItemShipped', 'damagedInTransit', 'customerRequest', 'duplicateOrder', 'notAsDescribed', 'other'.
lines array of object yes The return lines. At least one line with a quantity above 0 is required.
lines[].salesOrderProductLineId string yes The sales order product line being returned.
lines[].quantity string (decimal) yes The quantity to return. It must be above 0 and not exceed what remains returnable on the line.
lines[].reasonCode string no The reason for this line. Accepted values: 'defectiveItem', 'wrongItemShipped', 'damagedInTransit', 'customerRequest', 'duplicateOrder', 'notAsDescribed', 'other'.
lines[].returnFeeAmount string (decimal) no The fee deducted from the customer refund for this line, such as a restocking fee, in the sales order's currency. Credit returns only.
notes string no Free-form notes for the return.
shippingRefundAmount string (decimal) no The shipping charge to refund to the customer, in the sales order's currency. Credit returns only. Requires shippingSalesOrderProductLineId.
shippingSalesOrderProductLineId string no The shipping sales order product line whose charge is refunded. Its product has product type 'shipping'.

Example:

{
  "salesOrderId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "returnType": "<returnType>",
  "returnDate": "<returnDate>",
  "reasonCode": "<reasonCode>",
  "lines": [
    {
      "salesOrderProductLineId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "quantity": "19.99",
      "reasonCode": "<reasonCode>",
      "returnFeeAmount": "19.99"
    }
  ],
  "notes": "<notes>",
  "shippingRefundAmount": "19.99",
  "shippingSalesOrderProductLineId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}

Response

200 Success

Under data (createAccountingSalesReturnOutput):

Field Type Required Description
id string yes The unique identifier for the created sales return.

Response headers

Errors

Code Status
SALES_ORDER_NOT_FOUND 400
SALES_ORDER_PRODUCT_LINE_NOT_FOUND 400
LINES_REQUIRED 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses