Developers / Events API
Events API
Report what happened in your system — an order is ready, it shipped — and the business's Setloop assistant tells the customer on WhatsApp. Your system never sends message text: it sends the event, Setloop applies the business's rules, and the assistant writes the message.
Quick start
- 01
Get a test key
The business creates it in Setloop, under Integrations → Your system (API), and gives it to you. It looks likesl_test_followed by 32 letters and digits. A test key runs every check but never sends anything to customers. - 02
Send an event
POST /api/v1/integrations/eventscurl -X POST https://integrations.setloop.ai/api/v1/integrations/events \ -H "Authorization: Bearer $SETLOOP_KEY" \ -H "Content-Type: application/json" \ -d '{ "event_id": "evt_000123", "type": "order.status_changed", "occurred_at": "2026-11-26T13:30:00Z", "data": { "order_id": "PED-1042", "status": "ready_for_pickup", "customer": { "whatsapp": "+5511999990000", "name": "Ana" }, "details": { "pickup_address": "Rua das Flores, 120" } } }'ResponseHTTP/1.1 202 Accepted { "event_id": "evt_000123", "status": "RECEIVED", "reason": null, "test": true, "received_at": "2026-11-26T13:30:01Z", "processed_at": null, "message_text": null } - 03
Read the result
Within a few seconds the event is processed. With a test key, the result shows what the assistant would have sent.GET /api/v1/integrations/events/{event_id}curl https://integrations.setloop.ai/api/v1/integrations/events/evt_000123 \ -H "Authorization: Bearer $SETLOOP_KEY"
Response{ "event_id": "evt_000123", "status": "TESTED", "reason": null, "test": true, "received_at": "2026-11-26T13:30:01Z", "processed_at": "2026-11-26T13:30:04Z", "message_text": "Oi Ana, o seu pedido PED-1042 está pronto. Pode retirar na Rua das Flores, 120." }
Authentication
Send the key in the Authorization header: Authorization: Bearer sl_live_…. The key decides which business the event belongs to; nothing in the body can name another one. Any key of a business can read any of its events.
Keep keys on your server, never in a browser or a mobile app. Setloop shows a key once, when it is created, and stores only a fingerprint of it. A revoked key stops working at once.
The event
One JSON object per request. Unknown fields are refused, so a typo is reported instead of ignored.
event_idstring, required
Your id for this event, unique within the business: 1–200 letters, digits and . _ : -. Use your own event or log id.
typestring, required
"order.status_changed". The only type for now; new types will be added without changing this one.
occurred_atstring, required
When the change happened in your system, ISO 8601 with a time zone: "2026-11-26T13:30:00Z" or "2026-11-26T10:30:00-03:00".
data.order_idstring, required
The order's id as the customer would recognise it, up to 200 characters.
data.statusstring, required
The new status exactly as your system names it, lowercase: letters, digits and _ . -, up to 64. Matched exactly against the statuses the business set up in Setloop.
data.customer.whatsappstring, required
The customer's WhatsApp number in international format (E.164), like +5511999990000. For a Brazilian mobile either form works, with or without the ninth digit.
data.customer.namestring, optional
How to greet the customer, up to 120 characters.
data.detailsobject, optional
Anything else the update may mention: pickup_address, tracking_url, delivery_date… Up to 30 keys (lowercase, digits, _), string values up to 500 characters. Format dates and amounts the way the customer should read them.
The response
The same shape answers POST (the event just saved, or the first copy of a repeat) and GET /api/v1/integrations/events/{event_id}.
| Field | Description |
|---|---|
| event_id | Your event's id. |
| status | RECEIVED, SENT, SKIPPED, FAILED or TESTED (see Results and reasons). |
| reason | Why it was skipped or failed, or why a test event would not have been sent; otherwise null. |
| test | True when the event was sent with a test key. |
| received_at | When Setloop saved the event. |
| processed_at | When it reached its final status; null while RECEIVED. |
| message_text | What the assistant sent (SENT) or would have sent (TESTED), or the fixed template text it waits for (NEEDS_TEMPLATE); otherwise null. |
What happens to an event
Setloop checks the following, in order. The first one that applies decides the result. Processing starts within seconds; SENTappears once the assistant's message has been delivered, which can take a little longer: the assistant writes and sends like a person would.
- 1A newer event about the same order was already receivedNEWER_EVENT
- 2The business has not switched this status onNO_MESSAGE_FOR_STATUS
- 3The customer has no WhatsApp conversation with the businessNO_CONVERSATION
- 4The business's assistant is off for that WhatsApp numberASSISTANT_OFF
- 5Someone on the business's team is handling the conversationPERSON_HANDLING
- 6The customer last wrote more than 24 hours agoNEEDS_TEMPLATE · MISSING_FIELD · OUTSIDE_REPLY_WINDOW
- 7The business's plan has no AI replies leftUSAGE_LIMIT
- 8Otherwise the assistant writes the update and it is deliveredSENT
Inside the 24-hour window the assistant uses only the event's facts and what it knows about the business. If the customer is waiting for an answer at that moment, they get one message that answers them and includes the update. Outside the window the update will go as a WhatsApp template with the business's fixed text; until templates are available it ends as NEEDS_TEMPLATE.
Results and reasons
| Status | Meaning |
|---|---|
| RECEIVED | Saved, not finished yet: being processed, or waiting for the assistant's message to be delivered. |
| SENT | The assistant's message with the update was delivered to the customer. |
| SKIPPED | Nothing was sent; see reason. Sending the same event again will not change it. |
| FAILED | Sending failed; see reason. |
| TESTED | Test key: message_text is what the assistant would have sent, or reason says why it would not have sent anything. |
| Reason | Meaning |
|---|---|
| NEWER_EVENT | A newer event about the same order was already received. |
| NO_MESSAGE_FOR_STATUS | The business has not switched this status on. |
| NO_CONVERSATION | This customer has never written to the business on WhatsApp. |
| ASSISTANT_OFF | The business's assistant is off for this WhatsApp number. Nothing is sent without it. |
| PERSON_HANDLING | Someone on the business's team is handling the conversation; they see a note instead. |
| OUTSIDE_REPLY_WINDOW | The customer last wrote more than 24 hours ago and the business has no fixed text for this status. |
| NEEDS_TEMPLATE | The customer last wrote more than 24 hours ago; the update needs a WhatsApp template, not available yet. message_text shows the fixed text it would use. |
| MISSING_FIELD | Outside the 24-hour window, the business's fixed text uses a blank this event has no value for. |
| USAGE_LIMIT | The business's plan has no AI replies left. |
| ASSISTANT_DECLINED | The assistant's message with the update did not go out, after retries. |
| UPDATES_SWITCHED_OFF | The business switched updates off after the event was received. |
| CHANNEL_DISCONNECTED | The business's WhatsApp is not connected to Setloop. |
| SEND_FAILED | WhatsApp refused the message, or it kept failing. |
HTTP responses
| Code | error | Meaning |
|---|---|---|
| 202 | — | Saved; it will be processed. |
| 200 | — | This event_id was already received. Nothing new was saved or sent; the body is the first copy's status. |
| 400 | invalid_body | Not valid JSON, or a field is missing, invalid or unknown. field names it. |
| 401 | unauthorized | No key, or the key is unknown or revoked. |
| 409 | updates_switched_off | The business switched updates off in Setloop. The event was not saved. |
| 413 | payload_too_large | The body is larger than 64 KB. |
| 422 | unsupported_event_type | The type is not one Setloop understands. |
| 429 | rate_limited · daily_limit_reached | A limit was reached. Wait the seconds in Retry-After, then retry. |
| 5xx | — | Setloop could not save the event. Retry with the same event_id. |
HTTP/1.1 400 Bad Request
{
"error": "invalid_body",
"message": "data.customer.whatsapp must be a number in international format, like +5511999990000.",
"field": "data.customer.whatsapp"
}error is a stable code to act on; message is for people, in English — do not parse it.
Retries and duplicates
Retries are safe. Retry on a timeout, a network error or a 5xx with the same event_id and the same body: Setloop keeps the first copy, answers 200 with its status, and never sends twice. A repeat of an event_id is not read again, even if its body changed — every new change needs a new event_id.
Suggested schedule: after 10 s, 1 min, 5 min, 30 min and 2 h. Stop retrying on a 4xx other than 429.
Order of events
Set occurred_at to when the change happened in your system, not when you send it. If an event arrives after a newer one about the same order, it is skipped as NEWER_EVENT, so a late delivery never tells the customer an old status.
Limits
| Limit | Value |
|---|---|
| Body | 64 KB |
| Per key | 120 requests a minute |
| Per business | 10,000 events a day (UTC) |
| Event history | 90 days |
Over a limit the answer is 429 with a Retry-After header in seconds.
Test and live keys
| Test key (sl_test_…) | Live key (sl_live_…) | |
|---|---|---|
| Checks | Every check, with real customers and conversations | Every check |
| The assistant | Writes the update | Writes the update |
| Sent to the customer | Never | Yes, when every check passes |
| Counted on the plan | No | Yes, as an AI reply |
| Result | TESTED, with the text or the reason | SENT, SKIPPED or FAILED |
| Business switch | Ignored | Off → 409 |
Send events only for customers who agreed to receive updates on WhatsApp. That is Meta's rule for WhatsApp business messages; Setloop cannot check it for you.