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.

Base URL https://integrations.setloop.aiContract OpenAPI 3.1How it works for the business

Quick start

  1. 01

    Get a test key

    The business creates it in Setloop, under Integrations → Your system (API), and gives it to you. It looks like sl_test_ followed by 32 letters and digits. A test key runs every check but never sends anything to customers.
  2. 02

    Send an event

    POST /api/v1/integrations/events
    curl -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" }
        }
      }'
    Response
    HTTP/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
    }
  3. 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_id

string, required

Your id for this event, unique within the business: 1–200 letters, digits and . _ : -. Use your own event or log id.

type

string, required

"order.status_changed". The only type for now; new types will be added without changing this one.

occurred_at

string, 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_id

string, required

The order's id as the customer would recognise it, up to 200 characters.

data.status

string, 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.whatsapp

string, 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.name

string, optional

How to greet the customer, up to 120 characters.

data.details

object, 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}.

FieldDescription
event_idYour event's id.
statusRECEIVED, SENT, SKIPPED, FAILED or TESTED (see Results and reasons).
reasonWhy it was skipped or failed, or why a test event would not have been sent; otherwise null.
testTrue when the event was sent with a test key.
received_atWhen Setloop saved the event.
processed_atWhen it reached its final status; null while RECEIVED.
message_textWhat 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.

  1. 1A newer event about the same order was already receivedNEWER_EVENT
  2. 2The business has not switched this status onNO_MESSAGE_FOR_STATUS
  3. 3The customer has no WhatsApp conversation with the businessNO_CONVERSATION
  4. 4The business's assistant is off for that WhatsApp numberASSISTANT_OFF
  5. 5Someone on the business's team is handling the conversationPERSON_HANDLING
  6. 6The customer last wrote more than 24 hours agoNEEDS_TEMPLATE · MISSING_FIELD · OUTSIDE_REPLY_WINDOW
  7. 7The business's plan has no AI replies leftUSAGE_LIMIT
  8. 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

StatusMeaning
RECEIVEDSaved, not finished yet: being processed, or waiting for the assistant's message to be delivered.
SENTThe assistant's message with the update was delivered to the customer.
SKIPPEDNothing was sent; see reason. Sending the same event again will not change it.
FAILEDSending failed; see reason.
TESTEDTest key: message_text is what the assistant would have sent, or reason says why it would not have sent anything.
ReasonMeaning
NEWER_EVENTA newer event about the same order was already received.
NO_MESSAGE_FOR_STATUSThe business has not switched this status on.
NO_CONVERSATIONThis customer has never written to the business on WhatsApp.
ASSISTANT_OFFThe business's assistant is off for this WhatsApp number. Nothing is sent without it.
PERSON_HANDLINGSomeone on the business's team is handling the conversation; they see a note instead.
OUTSIDE_REPLY_WINDOWThe customer last wrote more than 24 hours ago and the business has no fixed text for this status.
NEEDS_TEMPLATEThe 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_FIELDOutside the 24-hour window, the business's fixed text uses a blank this event has no value for.
USAGE_LIMITThe business's plan has no AI replies left.
ASSISTANT_DECLINEDThe assistant's message with the update did not go out, after retries.
UPDATES_SWITCHED_OFFThe business switched updates off after the event was received.
CHANNEL_DISCONNECTEDThe business's WhatsApp is not connected to Setloop.
SEND_FAILEDWhatsApp refused the message, or it kept failing.

HTTP responses

CodeerrorMeaning
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.
400invalid_bodyNot valid JSON, or a field is missing, invalid or unknown. field names it.
401unauthorizedNo key, or the key is unknown or revoked.
409updates_switched_offThe business switched updates off in Setloop. The event was not saved.
413payload_too_largeThe body is larger than 64 KB.
422unsupported_event_typeThe type is not one Setloop understands.
429rate_limited · daily_limit_reachedA limit was reached. Wait the seconds in Retry-After, then retry.
5xx—Setloop could not save the event. Retry with the same event_id.
Error body
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

LimitValue
Body64 KB
Per key120 requests a minute
Per business10,000 events a day (UTC)
Event history90 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_…)
ChecksEvery check, with real customers and conversationsEvery check
The assistantWrites the updateWrites the update
Sent to the customerNeverYes, when every check passes
Counted on the planNoYes, as an AI reply
ResultTESTED, with the text or the reasonSENT, SKIPPED or FAILED
Business switchIgnoredOff → 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.

Reference

The full contract is an OpenAPI 3.1 file. Import it into Postman, Insomnia or any OpenAPI tool, or generate a client from it.