Draft Returns API
The Draft Returns API lets you build a complete return-creation flow by managing draft returns through a state machine. Endpoints allow you to initialize a draft, add or remove items, set customer and address details, finalize selections, and submit the completed return.Response structure
Each successful response includes:draft_return— the draft return and shopper detailscontext— data needed to fill action payloads_links— available actions, keyed by relation name, each with anhref_templates— action descriptors keyed by name, withmethod,title,contentType, andpropertiesclient_application— how the client should identify itself on later requestserrors— any errors from processing
Content-Type: application/prs.hal-forms+json. Request bodies use
Content-Type: application/json. Authenticate with the X-Authorization API key header.
State machine
- created — add items and set customer information
- items-finalized — choose credit type, processing type, and return method
- submitted / cancelled / expired — terminal;
_templatesand_linksare empty
Return type
Each returning item has its ownset-returning-item-return-type template. The values you can
send depend on the item, so send only a value from that template’s options. A return type the
item does not allow is rejected with action-validation-failed.
exchangeis not offered when the item’s return policy turns exchanges off, even if Shop Now is on.inline-exchangecovers a same-product exchange, to another variant or to the purchased variant. Show a same-product choice only wheninline-exchangeis offered. Loop saves it asexchange. It is not offered when a workflow excludes inline exchanges, unless the order is allowlisted.exchangealone still covers Advanced Exchange. See Set Returning Item Return Type for when Loop offersinline-exchange.replaceis offered for warranty replacements. Loop saves it asexchange. Likeinline-exchange, it is not offered when a workflow excludes inline exchanges, unless the order is allowlisted.- On a warranty claim, only the outcomes the warranty allows are offered, even when the item is still within its return window.
- On a warranty claim,
exchangeandreplaceare not offered for an item with no catalog product or variant, such as a deleted product or a custom line item. If that leaves the warranty with no outcome, the item is not eligible for the warranty claim.
User input
Each unanswered merchant question on a returning item has its ownadd-returning-item-user-input
template. Its title is the question.
A yes/no template can include systemMessage, the merchant’s “Response if yes” message in the
draft return’s language, or the merchant’s first configured message when that language has no
translation. It may contain HTML. It is only present when the merchant turned that response on.
systemMessage when the shopper answers Yes. If the merchant’s rule rejects the item on
Yes, the item is removed from the draft return and the next response does not include the
message. Keep it from the template before you submit the answer, show it, then return the shopper
to item selection.
See Add Returning Item User Input.
Processing type
processing_type is regular or instant. Every draft return starts as regular.
In the items-finalized state, _embedded.processing_type_options shows which processing types
you can use:
The amounts and day counts are set only on an available
instant option. They are null
otherwise.
When the draft has an exchange item, Instant runs as Instant Exchange. It stays available even
when the credit type is refund.
To change the processing type, use the set-processing-type template and send only a value from
its options. See Set Processing Type.
Instant reset
While the draft is initems-finalized, Loop checks on every request (including GET and
submit) whether Instant is still available. If it is not, Loop:
- sets
processing_typetoregular - removes the payment intent, so
payment_intentisnull
processing_type and payment_intent in the latest response. If you
still want Instant and it is available again, set it again and attach a new payment intent.
Payment
A draft return can require a payment, for example when the shopper owes money after exchanging into a pricier item, or whenprocessing_type is instant. Loop collects it through the shop’s
Stripe connection.
- If the shop has a usable Stripe connection, the
add-payment-intenttemplate is offered and marked required. Call Create Payment Intent before you submit. - If the shop has no usable Stripe connection, Loop cannot collect the payment. The
add-payment-intenttemplate is not offered andrequires_uncollectible_paymentistrue. The draft return cannot be submitted. To continue, change the draft so no payment is needed, for example by changing items or the return method.
processing_type to regular and removes the
payment intent, so payment_intent comes back null. Check processing_type and
payment_intent before you submit. If a payment is still needed, add-payment-intent is offered
again.