Server API
An order cancelled or refunded in your admin panel never happens in a shopper's browser. Your server tells us, through one door:
POST https://api.tocadule.com/v1/eventsFor now this door takes order cancellations only (purchase_cancelled). Any other
event is refused with the server API takes purchase_cancelled only for now. A
purchase_cancelled can only come through here (or from Shopify, or Toca's
upload), never from the browser.
API keys
Create a key in Settings › Data › API keys. Give it a name you'll recognise
later ("ERP", "agency sync"). The key (tdk_live_…) is shown once — copy it
then and store it like a password, on your server only. We keep only a hash of it.
- A key can only send events to its own workspace. It can't read any data.
- Each key shows who created it and when it was last used (or "never used").
- Revoke stops a key at once. A workspace can have up to 20 active keys.
Keys don't expire. To rotate one without downtime: create a new key, put it on your server, then revoke the old one.
Never put an API key in a web page, an app bundle or a public repository. Anyone with the key can send events as your store. If one leaks, revoke it and create a new one.
Sending a cancellation
Send the key as a bearer token (Authorization: Bearer tdk_live_YOUR_KEY).
curl -X POST https://api.tocadule.com/v1/events \
-H "Authorization: Bearer tdk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "purchase_cancelled",
"event_id": "cancel-1001",
"properties": { "order_id": "1001", "reason": "cancelled" }
}'| Field | |
|---|---|
event | Required. purchase_cancelled (or a name of yours you mapped onto it in the data centre). |
properties.order_id | Required. The same order id your purchase event sent. Without it the event is refused. |
properties.reason | cancelled (the default), rejected or refunded. |
properties.amount | The refunded money, a number. Required when reason is refunded. |
properties.refund_id | Your refund's id. Send it (or event_id) with every refund. |
properties.cancelled_at | When it was cancelled or refunded, an ISO 8601 time with its zone (2026-10-01T14:30:00+03:00, or …Z). Without it, the day it reached us. A time without a zone is refused. |
event_id | Recommended. Your own id for this event: a retry with the same id is safe. |
Several at once: { "events": [ … ] }: up to 100 events per request, body up
to 256 KB.
What happens to the order
We look for the order's purchase among the purchases we stored, by order_id
(exactly as your purchase sent it).
- The purchase is there: the order is reversed.
cancelledorrejected: the whole order is reversed: what is left of its total after any earlier partial refunds. An order is reversed in full once, whichever way it arrives (this door, Shopify, Toca's upload); a second one does nothing.refundedwith anamount: a partial refund of that amount, its own row. When the refunds reach the order's total, it is the order's full reversal.- Your revenue and the credit of the campaign, automation or popup the order was
credited to lose the same money. The cancellation takes the consent of the purchase
it reverses, and goes to the destinations that map
purchase_cancelled.
- No purchase with that
order_id(yet): the cancellation is kept, marked "no matching order" (not counted, not sent), and applied exactly as above when the order arrives.
The answer
One result per event, in the order you sent them. We check each event and answer at once;
a valid one is accepted: queued, then stored and forwarded within seconds. A retry with
the same event_id is still stored only once.
{ "data": { "results": [
{ "status": "accepted" },
{ "status": "invalid", "why": "order_id is required for purchase_cancelled" }
] } }| Status | Meaning |
|---|---|
accepted | Valid and received: it is stored (and forwarded to the destinations that map it) within seconds. A duplicate of an earlier event_id, or a cancellation of an order already reversed, is accepted and then does nothing; one for an order we have not recorded yet is kept until the order arrives. |
invalid | The event was rejected; why says what's wrong. Nothing is stored. |
Treat accepted as success; retry only on a network error or a 5xx (with the same event_id).
The request is 200 when at least one event was valid, 400 when none was, and
401 when the key is missing, unknown or revoked.