Skip to content

Raise a Return

Raise a new return (RMA) request for one item of one of the customer's orders. The item must be return-eligible — check it with GET /api/shop/returnable-items first. The requested quantity (rma_qty) is capped server-side by the quantity the customer is actually allowed to return. The return starts in a Pending status.

Endpoint

POST /api/shop/returns

Authentication

This endpoint requires an authenticated customer — send the storefront key and a customer Bearer token. See the Authentication page.

Request Headers

HeaderRequiredDescription
Content-TypeYesapplication/json
X-STOREFRONT-KEYYesYour storefront API key
AuthorizationYesBearer token (customer login required)

Request Body

json
{
  "order_id": 45,
  "order_item_id": 78,
  "rma_qty": 1,
  "resolution_type": "return",
  "rma_reason_id": 2,
  "information": "Item arrived damaged.",
  "package_condition": "open",
  "custom_attributes": {
    "1": "INV-9921",
    "2": "morning"
  },
  "agreement": true
}

Request Parameters

ParameterTypeRequiredDescription
order_idintegerYesId of the order the item belongs to.
order_item_idintegerYesId of the order item being returned — the orderItemId from returnable-items. This is the order line id, not the product id.
rma_qtyintegerYesQuantity to return. Capped server-side by the returnable quantity.
resolution_typestringYesreturn or cancel_items.
rma_reason_idintegerYesId of the chosen return reason — from return-reasons.
informationstringNoFree-text note about the return.
package_conditionstringNoReported package condition — open or packed. Any other value is rejected.
custom_attributesobjectConditionalAnswers to the return form's custom fields, keyed by field id — see List Return Custom Fields. Required when the store has custom fields marked isRequired.
agreementbooleanYesMust be true to confirm the return terms.

Custom Fields

The store can configure additional questions the shopper answers while raising a return. Fetch them with GET /api/shop/return-custom-fields and send the answers in custom_attributes, keyed by the field id:

  • every field with isRequired: true must be answered, otherwise the request is rejected
  • select and radio answers must be one of the field's option values
  • multiselect and checkbox answers take a list of option values
  • the stored answers come back on the return as customAttributes

Attaching Images

To attach evidence images, send the same fields as multipart/form-data with an images[] file field instead of a JSON body:

bash
curl -X POST https://your-store.com/api/shop/returns \
  -H "X-STOREFRONT-KEY: pk_storefront_..." \
  -H "Authorization: Bearer <customer-token>" \
  -F "order_id=45" \
  -F "order_item_id=78" \
  -F "rma_qty=1" \
  -F "resolution_type=return" \
  -F "rma_reason_id=2" \
  -F "package_condition=open" \
  -F "agreement=1" \
  -F "custom_attributes[1]=INV-9921" \
  -F "images[][email protected]" \
  -F "images[][email protected]"

Each file is checked against the mime types the store allows for returns (admin → Settings → RMA → Allowed file extension); an unsupported file rejects the whole request with 400. Images can only be attached while raising the return — there is no separate upload endpoint — and file uploads are REST-only, since a JSON GraphQL request cannot carry a file.

Response Fields (201 Created)

FieldTypeDescription
idintegerReturn ID.
orderIdintegerId of the order the item belongs to.
orderIncrementIdstringHuman-readable order number.
statusIdintegerNumeric status id — 1 (Pending) for a fresh return.
statusTitlestringStatus label.
statusColorstringHex color for the status badge.
packageConditionstringReported package condition.
informationstringThe note supplied when raising the return.
canClosebooleanWhether the return can be closed.
canReopenbooleanWhether the return can be reopened.
isExpiredbooleanWhether the return is past its action window.
itemobjectThe returned item — id, order_item_id, sku, name, quantity, resolution, reason_id, reason, variant_id.
imagesarrayAttached images (id, path, url). Empty when no files were sent.
customAttributesarrayAnswers to the return's custom fields — field_id, code, label, type, value. Empty when the store has no custom fields.
messagesCountintegerNumber of conversation messages — 0 for a fresh return.
createdAtstringISO 8601 creation timestamp.
updatedAtstringISO 8601 last update timestamp.

Status Codes

StatusMeaning
201 CreatedReturn raised; status is Pending.
400 Bad RequestItem not eligible, invalid quantity, agreement not true, unknown package_condition, an unanswered required custom field, a value outside a field's options, or an unsupported image type.
401 UnauthorizedMissing or invalid storefront key.
403 ForbiddenMissing or invalid customer Bearer token.
404 Not FoundThe order does not exist or is not the customer's.

Released under the MIT License.