E-commerce returns automation: how to automate returns with APIs.
To automate e-commerce returns with APIs, connect four systems through their events: the shop platform records the return request and checks it against your policy, the carrier issues the label, the warehouse marks the item as received and restocked, and the payment API issues the refund — with a person only for the exceptions. Below: the steps, the real API calls on Shopify and Stripe, the EU legal deadlines your rules must respect, an example flow and the pitfalls.
Returns automation
- Shop side
- Return request, approval, restock (e.g. Shopify GraphQL Admin API)
- Money side
- Refund API and refund events (e.g. Stripe)
- EU withdrawal
- 14 days from delivery, no reason needed
- EU refund
- Within 14 days, may wait for the goods
- Keep human
- Damage, disputes, out-of-policy requests
What returns automation means
A return is a chain of small decisions: is this order still returnable, which items, refund or exchange, who pays the postage, has the parcel arrived, can the item be resold, how much goes back to the customer. Returns automation means each of those decisions is taken by a rule in software, triggered by an event from the system that knows the answer, instead of by someone reading an e-mail and copying data between tabs.
APIs are what make it possible. Your shop platform, your carrier and your payment provider each expose the step they own; an automation (your own code, a workflow tool such as n8n, or an AI agent in front of the customer) listens to their events and calls the next one.
Six steps to automate, in order
- 01
1. Take the request where the customer is
A returns page on the site, an e-mail, or a chat on WhatsApp. The customer gives the order number and the items; the system looks the order up rather than asking them to describe it.
- 02
2. Check eligibility against your policy
Delivery date versus your return window, item category (personalised or perishable goods can be excluded under EU law), quantity already returned. Clear yes and clear no are automatic; the rest goes to a person.
- 03
3. Approve and send the label
Approval creates the return record and the carrier label; the customer receives it in the same channel they asked in, with the address and the deadline to send the parcel.
- 04
4. Receive and inspect
When the warehouse scans the parcel, the item is marked received and given a disposition — back to stock, or not resellable. This is the step to keep a human eye on.
- 05
5. Refund through the payment API
The refund is issued by API on the original payment, full or partial, and the customer is told it is on its way.
- 06
6. Close and report
The return is closed, the reason is recorded, and the reasons are reviewed: a product that keeps coming back for the same reason is a listing or sizing problem, not a returns problem.
What Shopify and Stripe expose for returns
Two platforms as examples; other shop and payment platforms have equivalents, so check their own documentation.
| Step | Shopify (GraphQL Admin API) | Stripe |
|---|---|---|
| Find what can be returned | returnableFulfillments query | — |
| Customer request, needs approval | returnRequest creates a return in REQUESTED status; returnApproveRequest or returnDeclineRequest | — |
| Merchant-created return | returnCreate creates it directly in OPEN status, with a reverse fulfillment order | — |
| Preview the money | returnCalculate and suggestedFinancialOutcome (refund, taxes, shipping) | — |
| Restock and refund | returnProcess: issues the refund and sets the disposition, e.g. RESTOCKED | Refunds API on the PaymentIntent or charge; amount for a partial refund |
| Events to listen to | returns/request, returns/approve, returns/decline, returns/process, returns/close… | refund.created, refund.updated, refund.failed, charge.refunded |
| Access | read_returns and write_returns scopes; returns are managed only through the GraphQL Admin API | Secret API key; verify webhook signatures |
Deadlines from the Consumer Rights Directive
For online sales to consumers in the EU (Directive 2011/83/EU). Your return window can be longer; it cannot be shorter.
| Rule | What the Directive says | What it means for the automation |
|---|---|---|
| Withdrawal period | 14 days, starting when the consumer (or a person they name, other than the carrier) takes physical possession of the goods (Art. 9) | Compute the window from the delivery date, not the order date |
| Missing information | If the trader did not inform the consumer of the right, the period ends 12 months after the initial period (Art. 10) | Make sure the confirmation e-mail carries the withdrawal information |
| Refund deadline | All payments refunded within 14 days of being informed of the withdrawal, with the same means of payment (Art. 13) | Refund on the original payment; Stripe can only refund to the original payment method anyway |
| Waiting for the goods | The trader may withhold the refund until the goods are back or the consumer shows proof of sending them (Art. 13) | Trigger the refund on the carrier or warehouse event, and alert someone before the deadline |
| Sending back | The consumer sends the goods back within 14 days and bears only the direct cost of return, unless the trader agreed to pay it (Art. 14) | State who pays the label in the approval message |
An example: a return handled on WhatsApp
A customer writes to the shop's WhatsApp number: “The jacket is too small, can I send it back?” The agent asks for the order number, looks the order up through the shop API, sees it was delivered within the return window and that jackets are returnable, and replies with the two options the policy allows — a refund or the next size. The customer picks the refund; the agent creates the return, sends the label and says who pays the postage.
Days later the warehouse scans the parcel and marks the jacket as back in stock. That event triggers the refund on the original payment, and the agent sends: “Your jacket has arrived and your refund is on its way to the card you paid with.” If the jacket arrives damaged, nothing is refunded automatically: the case goes to a person with the photos and the order history attached.
This is the kind of agent we build on the official platform — see WhatsApp AI agents — and the shops we build, such as the custom shop with Stripe checkout we run for a sports equipment brand in France, are listed under retail and e-commerce.
Pitfalls to avoid
- Refunding at label creation. The EU rules let you wait for the goods or proof of sending; refunding before the parcel exists invites abuse.
- Not watching for failed refunds. A refund can fail (closed account, lost card). Stripe returns the money to your balance — which can take up to 30 days — and sends refund.failed; someone must then pay the customer another way.
- Refunding while a dispute is open. Stripe flags the case where a customer disputes a charge while the refund is pending; on bank debits it warns of a risk of double refund. Check for disputes before refunding.
- Telling customers “refunded” as if the money had arrived. Stripe says a card refund shows as a credit about 5–10 business days later, depending on the bank; say “on its way” and share the reference when the provider gives one.
- Letting an AI agent improvise the policy. The agent should read the return rules and the order data, never decide exceptions on its own — that is what the human queue is for.
Sources
- Shopify Developers — Apps in returns — return mutations, statuses, webhook topics, GraphQL Admin API only — checked 8 November 2026
- Shopify Developers — Build return management — returnableFulfillments, returnCreate, returnProcess, dispositions, access scopes — checked 8 November 2026
- Stripe Docs — Refund and cancel payments — Refunds API, partial refunds, original payment method, failed refunds, timing, refund events — checked 8 November 2026
- EUR-Lex — Directive 2011/83/EU on consumer rights — Articles 9, 10, 13 and 14: withdrawal period, refund deadline, return of goods — checked 8 November 2026
Related
Frequently asked questions
How do I automate e-commerce returns with an API?
Connect the systems that own each step through their events: the shop platform records the return request and checks it against your policy, the carrier issues the label, the warehouse marks the item received and restocked, and the payment API issues the refund. A person handles damaged items and requests outside the policy.
Can Shopify returns be managed through the API?
Yes. Shopify's documentation says returns can be managed only through the GraphQL Admin API, with mutations such as returnRequest, returnApproveRequest, returnCreate and returnProcess, webhook topics such as returns/request and returns/process, and the read_returns and write_returns access scopes.
How do I issue a refund automatically with Stripe?
Create a refund through the Refunds API with the PaymentIntent or charge ID, adding an amount for a partial refund, and listen to the refund.created, refund.updated and refund.failed events. Refunds go back only to the original payment method.
How long do I have to refund a returned online order in the EU?
Under Directive 2011/83/EU, the trader refunds all payments within 14 days of being informed of the withdrawal, with the same means of payment, and may withhold the refund until the goods are back or the consumer shows proof of sending them.
Should an AI agent approve returns on its own?
Only the clear cases your written policy already decides, such as an eligible item inside the return window. Damaged goods, disputes and exceptions should go to a person, with the order history attached.
Returns eating your support time?
We connect your shop, carrier and payment provider and put an agent in front of the customer.