Sending orders
Send your store's orders, keep them up to date, and see what YouSendIt records from them.
Send your store’s orders to YouSendIt so you can see revenue from your emails, count purchases as conversions, and use them in segments and flows. Your server sends each order to POST/orders when it is placed, and sends it again whenever it changes.
Before you start
- Create an API key with Orders → Full access (
orders:write) under Transactional → API keys. See Authentication and Permissions. - Call the API from your server, never from a web page: a request from a browser is refused.
1. Send an order when it is placed
The body is a JSON list of up to 25 orders. Amounts are decimals as strings ("24.00"), times are ISO 8601 with a time zone.
curl -X POST https://yousendit.io/api/v1/orders \
-H "Authorization: Bearer $YOUSENDIT_API_KEY" \
-H "Content-Type: application/json" \
-d '[{
"external_id": "1042",
"name": "#1042",
"email": "sam@example.com",
"currency": "USD",
"total": "29.00",
"subtotal": "24.00",
"shipping": "5.00",
"placed_at": "2026-11-28T10:04:02Z",
"updated_at": "2026-11-28T10:04:02Z",
"items": [
{ "external_id": "1042-1", "product_external_id": "mug-1", "title": "Mug", "sku": "MUG-BLUE", "quantity": 2, "price": "12.00" }
]
}]'The order’s fields
| Field | What it is |
|---|---|
| external_idRequired | Your id for the order. Send the same one to update it. |
| totalRequired | What the customer paid, as a decimal string. This is the order's value in reports and conversions. |
| placed_atRequired | When the order was placed. |
The buyer’s email. The order is matched to the contact with this address (or send profile_id). | |
| profile_id | The contact’s id, when you have it (from Create or update profile). It wins over email. |
| currency | Three letters, like USD. Send it: amounts are never converted between currencies. |
| name | How the order is shown, like #1042. |
| subtotal, tax, discounts, shipping | Parts of the total, as decimal strings. |
| items | The order’s lines (below). Send the complete list each time: a line left out is removed. Leave the field out to keep the lines as they are. |
| fulfilled_at, cancelled_at | When the order shipped, or was cancelled. |
| refunds | Every refund so far: { "id": "r1", "amount": "12.00", "at": "…" }. |
| financial_status, fulfillment_status | Your own status words (paid, shipped), shown with the order. |
| updated_at | When the order last changed in your system. Lets an older copy never overwrite a newer one (see below). |
Each line in items:
| Field | What it is |
|---|---|
| external_idRequired | Your id for the line. Keep it the same when you send the order again. |
| quantity | How many (default 1). |
| price | The unit price, as a decimal string. |
| title, variant_title, sku | What was bought. Used in emails and as filters ("Ordered Product where sku is MUG-BLUE"). |
| product_external_id, variant_external_id | Your product’s id, the same as in your product catalogue. |
2. Read the answer
The answer is always 200, with one result per order in the same order as you sent them, so one bad order never fails the others:
{
"written": 1, "stale": 0, "failed": 0,
"results": [
{ "index": 0, "status": "created", "id": "8c1f…", "profile_id": "2b7e…", "code": null, "param": null, "message": null }
]
}createdorupdated: stored.profile_idis the contact it was matched to, ornullwhen nobody has that email yet.stale: a newer copy is already stored (byupdated_at). Nothing changed.failed:code,paramandmessagesay what to fix. See Errors and limits.
3. Send it again when it changes
Send the whole order again with the same external_id whenever something changes. Each change records its own activity once, however often you resend:
| Activity | Counts when | Value |
|---|---|---|
| Shipped | Add fulfilled_at. Records Fulfilled Order. | None |
| Cancelled | Add cancelled_at. Records Cancelled Order. | Order total |
| Refunded | Add the refund to refunds (keep the earlier ones). Records Refunded Order per refund. | Refund amount |
| Edited | Change the total or the lines. The order's activity is corrected, not counted again. | New total |
updated_at (or never). With it, a copy that arrives late never replaces a newer one. A copy without updated_at never replaces one that has it.What YouSendIt records
From each order, YouSendIt records the activity you can use in conversions, segments and flows. You never send these yourself, and they do not count against your monthly event allowance.
| Activity | Counts when | Value |
|---|---|---|
| Placed Order | Once per order, at placed_at | Order total |
| Ordered Product | Once per line, at placed_at | Line total |
| Fulfilled Order | When fulfilled_at is set | None |
| Cancelled Order | When cancelled_at is set | Order total |
| Refunded Order | Once per refund | Refund amount |
Matching orders to contacts
- An order goes to the contact with its
profile_id, or else the contact with itsemail. - Orders never create contacts. If nobody has that email yet, the order is kept and matched when the contact is added (by a sign-up, an import, an event, or the profiles API); its activity is recorded then.
- Having an order does not subscribe anyone to your emails.
Sending past orders
You can send your order history. Anything that happened more than 48 hours before you first sent the order is stored as past activity: it shows on the contact and in reports, but never starts a flow, and a conversion counts it only with Include past activity turned on.
Reading orders back
List orders (newest first, filter by contact or dates) and Retrieve order (with its lines) need orders:read.