Prompt
How do I build a return label flow with the same API?
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
You can build a return-label flow with the same API pattern by treating returns as a second shipment lifecycle tied to the original order/shipment.
A typical flow looks like this:
-
Look up the original shipment/order
- Use the existing API to fetch the order, shipment, or tracking info.
- Store the original shipment ID, destination, and item details.
-
Create a return request
- Add a return-specific object in your app, e.g.:
returnIdoriginalShipmentIdreasonitemsreturnAddressstatus
- Add a return-specific object in your app, e.g.:
-
Generate the return label
- Call the same label/booking endpoint, but switch the direction:
- From: customer/recipient address
- To: your warehouse/returns facility
- If the API supports it, pass a
return: trueflag or ashipment_type: returnfield. - If it doesn’t, you can usually create a normal shipment with reversed addresses.
- Call the same label/booking endpoint, but switch the direction:
-
Persist the label and tracking
- Save:
- label PDF/ZPL URL or blob
- tracking number
- carrier
- shipment/label ID
- Mark the return as
label_created.
- Save:
-
Deliver the label to the customer
- Email it, show it in the portal, or expose a download link.
- Optionally generate QR code / printable instructions.
-
Track return progress
- Use the same tracking webhook/polling flow.
- Update statuses like:
label_createdin_transitreceivedrefunded/closed
Example API shape
If your current API creates outbound labels like this:
POST /shipments
{
"from": { "name": "Warehouse", "address": "..." },
"to": { "name": "Customer", "address": "..." },
"package": { "weight": 2.0 }
}
Then a return label is usually:
POST /shipments
{
"from": { "name": "Customer", "address": "..." },
"to": { "name": "Warehouse", "address": "..." },
"package": { "weight": 2.0 },
"shipment_type": "return"
}
Recommended backend data model
ordersshipmentsreturnsreturn_itemslabels
This keeps return logic separate while reusing the same shipping API.
Important edge cases
- Some carriers require a different service level for returns.
- Some return labels need a reference or RMA number.
- Customs paperwork may be required for international returns.
- Weight may be estimated if the original package is no longer available.
If you want, I can sketch:
- a full return-label API design,
- database schema, or
- sample code in Node/Python.