Insights · Automation

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.

The flow

Six steps to automate, in order

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Published API facts

What Shopify and Stripe expose for returns

Two platforms as examples; other shop and payment platforms have equivalents, so check their own documentation.

StepShopify (GraphQL Admin API)Stripe
Find what can be returnedreturnableFulfillments query—
Customer request, needs approvalreturnRequest creates a return in REQUESTED status; returnApproveRequest or returnDeclineRequest—
Merchant-created returnreturnCreate creates it directly in OPEN status, with a reverse fulfillment order—
Preview the moneyreturnCalculate and suggestedFinancialOutcome (refund, taxes, shipping)—
Restock and refundreturnProcess: issues the refund and sets the disposition, e.g. RESTOCKEDRefunds API on the PaymentIntent or charge; amount for a partial refund
Events to listen toreturns/request, returns/approve, returns/decline, returns/process, returns/close…refund.created, refund.updated, refund.failed, charge.refunded
Accessread_returns and write_returns scopes; returns are managed only through the GraphQL Admin APISecret API key; verify webhook signatures
EU rules your automation must respect

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.

RuleWhat the Directive saysWhat it means for the automation
Withdrawal period14 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 informationIf 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 deadlineAll 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 goodsThe 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 backThe 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

About this article

Written by the Takat AI team from the projects we build and run. Facts about third-party services are checked against their official documentation on the date shown; figures come from the sources listed. Last reviewed .

FAQ

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.