Skip to content

Returns / RMA

A customer requests a return against an order; a merchant moves it through an approval and intake state machine. Receipt and refund processing coordinate restock, money, and customer-notification work through separate durable boundaries. Examples reuse the api() helper.

Customer factual responses

The current staging API contract provides eight /facts operations across public, account and action-token routes. They keep the existing commands and authorization boundaries, with factual customer responses. New integrations use the authenticated by-reference operations. The three public companions below serve email-gated compatibility callers; they are deprecated along with their original public routes.

These are contract migration instructions, not confirmation of availability or adoption in every deployment. Check the API reference and schema identity for the environment you use.

All paths are relative to /api/v1. Supply x-organization-slug and actual storefront origin context: browsers send Origin; server transports forward x-storefront-origin. Domains selects Live or Sandbox data from that origin, including for token-only requests. x-commerce-environment is an optional consistency assertion, not a selector or fallback. Missing/malformed origin context can return 400; unverified, conflicting or wrong-tenant context can return 403.

Public email-gated compatibility

On this family, the order id plus the email used at checkout is the credential; no CustomerSession is required. This does not grant access to the separate authenticated account API.

OperationRequestSuccess response
POST /public/orders/{orderId}/returns/factsRequired CreateReturnDto: customerEmail and items; optional customerName and reason201, one PublicReturnFactsDto
GET /public/orders/{orderId}/returns/factsRequired email query; no body200, bare PublicReturnFactsDto[], newest first
POST /public/orders/{orderId}/returns/{returnId}/cancel/factsRequired CancelReturnDto body containing customerEmail200, one PublicReturnFactsDto

If the order exists but the supplied email does not match, the public return flow deliberately returns 403 instead of a neutral 404. This is the narrow issue #1475 UX/security exception: it helps legitimate customers correct which email they used at checkout, while tenant scoping, public rate limiting, and a non-detail error body limit probing value.

// Compatibility request: 201, a single factual Return (no data wrapper).
await api(`/public/orders/${orderId}/returns/facts`, {
  method: "POST",
  storefrontOrigin, // actual verified storefront origin for server transport
  body: JSON.stringify({
    customerEmail: "dana@example.com",      // must match the order
    items: [{ orderItemId: "…", quantity: 1 }], // 1–50 lines; qty ≤ unreturned qty
    reason: "Wrong size",                    // optional, ≤4000
  }),
});
 
// 200, a bare array; encode the actual email query value.
await api(`/public/orders/${orderId}/returns/facts?email=${encodeURIComponent(customerEmail)}`, {
  storefrontOrigin,
});
 
// Cancel (allowed while REQUESTED or APPROVED)
await api(`/public/orders/${orderId}/returns/${returnId}/cancel/facts`, {
  method: "POST", storefrontOrigin,
  body: JSON.stringify({ customerEmail: "dana@example.com" }),
});

The server limits requests to eligible handed-off physical units minus active Return claims. REJECTED and CANCELLED claims do not reserve that quantity. Public create does not accept a reviewedEstimate; it does not capture a monetary acknowledgement. Customer cancellation remains limited to REQUESTED or APPROVED. The factual companions also declare 503 when money-facts dependencies are unavailable; that refusal occurs before reading or changing the order/Return. Keep validation, not-found and rate-limit handling; never fall back to the old draft-bearing money fields after a refusal.

Reading money without exposing drafts

All four factual Return schemas require money, physical and nonStripeCompletion. The latter two can be null. Factual responses omit the legacy top-level refundAmountInCents, refundState, amountOwedInCents and refundCurrency; do not merge those fields back into the result or treat a private merchant draft as customer money.

FactHow to interpret it
money.requestedImmutable evidence of what the customer deliberately submitted. AVAILABLE includes a proven 0; UNAVAILABLE has null amount/currency and an unavailableReason. NOT_CAPTURED means no evidence was captured, including submissions without an acknowledgement. Never backfill from current prices, settings or drafts.
money.approvalA published customer commitment, separate from payment. current is present only while an approval is in effect. history retains each effective revision and its own comparison; cancellation after approval clears current but preserves that history. Prepared drafts and status alone do not prove approval money.
money.comparisonApproved total minus requested total, available only when both are known in the same historical currency. 0 proves equality; unavailable is not equality. Each historical revision also carries its own comparison.
money.refundThis Return's actual refund evidence, not an order-wide refund total. PROCESSING is pending, NOT_ISSUED means the attempt moved no money, and ISSUED records confirmed issuance. Read a later correction separately: it preserves the original issue while explaining the current amount owed.

Use each fact's recorded currency, including the refund/correction record's own denomination. Never substitute today's store currency, convert different currencies for a comparison, or publish an amount whose currency is unavailable. Requested item contributions cover the original requested quantities; do not prorate them to later approved units. Complete itemOutcomes distinguish explicit refusal (null approved amount) from a genuine zero-value approval. Legacy/unsupported outcomes can be null with an explanation; missing detail is not a reconstructed decision.

breakdownStatus is independent of the total: INCOMPLETE can retain a known requested amount with only some components, and UNAVAILABLE supplies no components. Do not divide totals into invented item/tax/discount allocations. An empty refund itemAmounts array can mean no exact split was recorded. COMPLETED_WITHOUT_PROVIDER_REFUND does not establish zero owed or payment by another method; UNAVAILABLE does not mean no refund happened. State/reason catalogs marked x-extensible-enum are open: apply their documented unavailable or unresolved fallback for unknown values.

Physical facts and genuine-zero completion

physical.version: 1, its receipt versions, and nonStripeCompletion.version: 1 are independent of lifecycle/publication version 3. Do not use one version as support for another.

  • physical: null means legacy, unsupported, missing exact mapping or a publication withheld before lifecycle approval. It proves neither all-kept goods, zero arrivals nor settlement.
  • requiredLines is the exact current required-back subset. keepPromises preserves irrevocable published grants even after reduction, refusal or cancellation; lineage quantities are not additional units to sum. Neither field grants shipping/document access or proves goods remain with the customer.
  • receiptCoverage concerns ordinary receipt only. Empty arrivedLines with unavailable coverage does not prove zero arrival. ordinaryReceipt and protectedArrival retain their own exact allocations, conditions and original inventory results. Later completion or cancellation does not invent a receipt; actual protected arrival does not reopen shipping or move money.
  • refundReadiness: QUALIFIED is necessary qualification, not a promise to refund or command authority. Source, capacity and authorization checks remain.
  • A present nonStripeCompletion records the separate deliberate ZERO_CASH completion: amount 0, historical currency, approval revision and original completion time. The command moves no money and does not establish manual payment or credit/exchange settlement. A null receipt does not deny legacy or Stripe completion and does not prove zero. Actual issued/corrected money remains in money.refund.

See the account and token flow for the other five factual operations, response wrappers and deliberate same-token replay.

Legacy compatibility and lifecycle

The original public create/list/cancel routes without /facts remain compatibility operations; adding /facts does not silently change their scalar meanings or nullability. Account lists, by-reference create/cancel and action consumption also retain their original response families. Those legacy money scalars can expose private drafts and are not a safe fallback for a factual consumer. The public /facts companions remain deprecated email-gated retirement targets themselves; new clients use owned reference addressing.

This guidance sets no announcement, removal date or sunset clock. Replacement delivery, public notice and verified consumer migration remain subject to the API lifecycle policy. The full reference JSON is the current documentation contract; compare its full canonical schema identity as described in Environments & schema identity. The committed document uses info.version: "unstamped"; publication derives the full canonical digest into the served copy's info.version. Source-file, stamped-copy, archive and subset hashes verify their respective bytes; they are not interchangeable with that full schema identity. A historical packet's stamped identity cannot identify a later full API build. Even matching reference/runtime identities do not prove successful operations or consumer adoption.

Retained contract snapshot

The immutable snapshot below is pinned to source d3e8606dd5e1 on 2026-11-24. It includes all eight factual operations, their request/response closure and transport rules. Use its own manifest and checksums when comparing these files; the historical packet is a different artifact.

The ZIP's SHA-256 is 432645faf489c56a5b2fadd3dec3a0c430a70483913cb025723c1d8f6ba64dca. Its full-document canonical schema identity is sha256:bc74c459bddd6abb7a0e008bfcc798f772dc777a78b6f035fa422f2426a62ae8. The ZIP contains both the committed unstamped full document and a stamped offline candidate; neither the subset nor ZIP hash is a runtime identity. Later full references can differ even while these eight operations are unchanged. Use the current full reference for current contract comparison; never use this snapshot's digest to identify a later full API build. Retained source files do not establish publication, served-version/operational proof, consumer adoption or legacy retirement.

Merchant side

Reads (GET /merchant/returns, /:id) are open to any member. Status + notes mutations require returns:operate; Owner/Admin retain broad access, and Staff needs that group.

First approval uses POST /merchant/returns/:id/first-approval with an x-idempotency-key and expectedCurrentRevision set to currentRevisionNumber from GET /merchant/returns/:id/approval-publication. Choose PUBLISH_COMPLETE and provide a publication with its approved total and complete itemOutcomes for every requested line, including explicit refusals. Each approved item has positive units and an explicit amount; a refused item has zero approved units and a null amount. Use REJECTED when every item is refused. Required customer explanations and the selected refund support are validated before approval. Alternatively, CONFIRM_CURRENT deliberately reuses the expected complete version 2 revision, without a publication body.

The command binds publication, approval and one notification intent atomically; it does not issue a refund. A complete revision may also be published separately through POST /merchant/returns/:id/complete-approval-publication/revisions. The deprecated aggregate publication route continues to publish version 1 history during migration, but that history cannot authorize first approval. Complete commands return 503 DATABASE_ERROR with details.reason = RETURN_COMPLETE_APPROVAL_SCHEMA_NOT_READY until their database migration is available.

Sending status: "APPROVED" to the status-only endpoint returns 409 RESOURCE_CONFLICT with details.reason = RETURN_FIRST_APPROVAL_COMMAND_REQUIRED and changes nothing. Existing approved returns continue through intake and completion.

// Reject a requested return
await api(`/merchant/returns/${id}/status`, { method: "PATCH", token,
  body: JSON.stringify({ status: "REJECTED" }) });
 
await api(`/merchant/returns/${id}/notes`, { method: "PATCH", token,
  body: JSON.stringify({ notes: "Inspected — resaleable" }) });

State machine

The complete first-approval command owns REQUESTED → APPROVED. The status-only endpoint supports:

REQUESTED → {REJECTED, CANCELLED}
APPROVED → {IN_TRANSIT, CANCELLED}
IN_TRANSIT → {RECEIVED, CANCELLED}
RECEIVED → COMPLETED

COMPLETED, REJECTED, and CANCELLED are terminal.

Receipt, refund, and completion

  • On RECEIVED — item intake outcomes are applied and resaleable units are restocked inside the transition transaction. Use PATCH /merchant/returns/:id/intake before receipt, or send the same item outcomes with the RECEIVED status transition to apply both atomically. The status transition requires a non-empty reason, captured with the condition and restock audit evidence.
  • Refund amount — PATCH /merchant/returns/:id/refund-amount records the intended cash amount, bounded by the refundable cap. Send allocations with non-empty per-Return-item amounts that sum exactly to every positive refund; send [] when the amount is 0. Setting 0 records that this Return will not issue a cash refund; the endpoint itself never moves money.
  • Requesting COMPLETED — for a positive cash refund, HTTP 200 acknowledges the command, not necessarily terminal completion. The canonical Return can remain RECEIVED while its refund generation is processing. Always consume the returned status and merchant-safe refundWorkflow instead of inferring success from the HTTP response.

The merchant workflow reports one of these high-level states:

  • READY / PROCESSING — eligible or actively processing; do not start a parallel refund.
  • NEEDS_ATTENTION — inspect problemCode. A retry is available only when retryAvailable is true, which means the prior generation has durable provider no-money proof and its processing event is acknowledged. Ambiguous or unavailable provider truth remains fail-closed.
  • SUCCEEDED — the exact refund and Return completion evidence agree.
  • REFUND_REVERSED_NEEDS_REIMBURSEMENT — the provider later reversed a refund that had already succeeded; the customer is still owed the exposed amount.
  • REFUND_REVERSAL_RECONCILIATION_REQUIRED — later provider observations conflict or remain unsafe to act on. No new refund or remediation closure is implied.
  • RESOLUTION_PENDING / RESOLVED — the reimbursement amount is covered, then the independent notification/tax obligations are pending or complete.

The initial completion notification is admitted only after exact refund success. A deterministic provider rejection before success keeps the Return at RECEIVED; it does not send success copy.

When a successful refund is later reversed

A signature-verified Stripe refund.failed (or equivalent terminal evidence) can arrive after the exact Refund was already recorded as succeeded. In that case cartonium does not delete or rewind the original success:

  1. The signed provider event is persisted and revalidated against the exact tenant, connected account, Refund, PaymentIntent, amount, currency, Return, and refund attempt.
  2. An append-only REFUND_REVERSAL ledger transaction restores effective payment truth while preserving the historical refund.
  3. The Return remains COMPLETED, but a tenant-scoped refund exception becomes operator-visible. Public/customer reads change to correction truth rather than continuing to claim the refund arrived.
  4. A correction notification obligation is created, and any affected tax reversal is suppressed, compensated, or held for reconciliation through its own durable state machine.
  5. Ordinary and grouped card-refund paths remain fenced while the exception or a later provider-reconciliation hold is active, preventing an automatic second refund.

This exception does not change shipping, fulfillment, Return intake, or inventory state. It corrects money and customer-notification truth after the goods workflow has already completed.

Customer-facing refund state

Legacy responses without /facts include required refundState and nullable amountOwedInCents fields. Relevant legacy values are:

  • NOT_APPLICABLE — the Return was rejected or cancelled, or no cash refund applies.
  • PROCESSING / ISSUED — the ordinary refund path is pending or complete.
  • REIMBURSEMENT_PENDING — a post-success reversal exists and amountOwedInCents is still positive.
  • RECONCILIATION_REQUIRED — provider truth is contradictory or incomplete; no payment outcome should be inferred.
  • REIMBURSEMENT_RECORDED — alternative reimbursement covers the amount, but all independent resolution obligations are not yet terminal.
  • RESOLVED — the exception has closed.

amountOwedInCents is null when no post-success correction exists and never goes below zero. Factual responses instead expose money.refund and its separate correction; they do not carry these top-level legacy fields.

Claim and record remediation

Owner/Admin retain broad access throughout this workflow; Staff needs returns:operate to claim the exception:

await api(`/merchant/returns/${id}/refund-exception/claim`, {
  method: "POST",
  token,
});

Claiming assigns ownership only. It changes no ledger, Return, notification, provider, tax, shipping, fulfillment, or inventory state.

After the merchant has already reimbursed the customer through a non-card method, record that observed money movement with the high-risk remediation command. Staff recording requires both returns:operate and shared-commerce:manual-payments. The command is also gated by the shared_commerce.manual_payment_record high-risk action:

await api(`/merchant/returns/${id}/refund-exception/reimbursements`, {
  method: "POST",
  token,
  headers: { "x-idempotency-key": operationKey },
  body: JSON.stringify({
    amountInCents: 4200,
    method: "BANK_TRANSFER", // CASH | CHECK | BANK_TRANSFER | STORE_CREDIT | OTHER
    currency: "usd",
    occurredAt: new Date().toISOString(),
    reference: "merchant receipt 4815",
    reason: "Customer confirmed the replacement reimbursement.",
  }),
});

This command records completed alternative reimbursement; it cannot send money and performs no provider call. It appends an ordinary Sales refund, reserves the corresponding tax-reversal intent, and is idempotent for the same operation key and facts. Partial reimbursement leaves the remaining balance visible. Exact full coverage can advance notification resolution only after the independent ledger, tax, and delivery evidence permits it.

Correction and resolution notifications

The merchant detail exposes the exception's notification rows as CORRECTION, RESOLUTION, or a superseding COMBINED notice, each with an independent status. PROVIDER_ACCEPTED means the provider accepted the request, not that the customer's inbox received it. BLOCKED, READY, and PROVIDER_IN_FLIGHT likewise are not proof the customer received the message. DEFINITIVELY_NOT_ACCEPTED proves the provider did not accept that notice, while SUPERSEDED means a later combined notice owns its obligation; neither is delivery proof. A resolution notice cannot overtake an unconsumed or ambiguous correction obligation, and exact retries do not create a second notice.

The ordinary APPROVED, RECEIVED, and REJECTED lifecycle notifications continue through the outbox. Logged-in customer session auth is separate from today's public email-match flow.