API & webhooks
Everything your AI agent does, available to your own systems. Build and edit an agent, teach it what your business knows, ask for a channel to be connected — and receive every new lead in your CRM the second the conversation produces one.
Overview
The API is REST over HTTPS, JSON in and out, and scoped to a single agent by the key you present. There are two halves and you will normally use both:
| Half | Direction | Use it for |
|---|---|---|
| Chat API | You ↔ the agent | Talk to the agent from your own app: open a chat, send the customer's messages, get replies, read the transcript back. |
| REST API | You → EverySecond | Create and edit agents, upload knowledge, request channel connections, pull leads and transcripts. |
| Webhooks | EverySecond → you | Be told the moment a lead arrives, a lead is scored or flagged, knowledge changes, or a channel connects. |
Base URL for everything below:
https://everysecond.ai/api/v1
Authentication
Every request carries an API key, made on the Integration screen in the dashboard (sidebar → Integration). There are two kinds:
| Key | Looks like | Reaches |
|---|---|---|
| Custom key (recommended) | esk_… | The agents you chose (one, several, or all of them) and only the permissions you gave it — see Custom keys & permissions. |
| Agent key | es_… | One agent, every endpoint. It also runs the website widget, so it is in the page source of any site that embeds it; on the Integration screen you can keep it for the widget only. |
A key on one agent is that agent: no request takes an agent id, and a key can never read or write another agent's data.
curl https://everysecond.ai/api/v1/agent \
-H "Authorization: Bearer es_your_project_key"
# or, if a Bearer header is awkward in your stack:
curl https://everysecond.ai/api/v1/agent -H "X-Api-Key: es_your_project_key"
Custom keys & permissions
Make one key per system (your website, your CRM, Zapier…), each with only what that system needs. A key has a name,
the agents it works on, and per area Read (GET requests) or Read & write
(everything); an area it was not given answers 403 permission_denied. You can switch a key off and on,
change its agents or permissions (applies at once), rotate it or delete it. The key is shown once, when it is made
or rotated — only a fingerprint of it is stored.
| Area | Endpoints |
|---|---|
chats | /api/v1/chats/* — talk to the agent, the basket |
leads | /api/v1/leads, /leads/{id}, conversation, notes, flags, /api/v1/team |
inbox | /api/v1/leads/{id}/replies, /pause, /resume, /api/v1/tickets/* — your team answers customers |
whatsapp | /api/v1/whatsapp/* — templates, campaigns, sends (spends WhatsApp credit) |
agent | /api/v1/agent/* — settings, instructions, knowledge, channel connections |
orders | /api/v1/orders/* — orders, carts, the menu by your product ids |
reservations | /api/v1/reservations/* |
webhooks | /api/v1/webhooks/* |
A key on several agents says which agent each request is about with the X-Agent-Id
header (the agent's id, shown on the Integration screen). Without it the answer is 400 agent_required
with the list of the key's agents; an agent the key was not given is 403 agent_not_allowed. A key on one
agent needs no header. "All agents" includes agents you make later.
curl https://everysecond.ai/api/v1/leads \ -H "Authorization: Bearer esk_your_key" \ -H "X-Agent-Id: 775" # What may this key do? (any working key) curl https://everysecond.ai/api/v1/key -H "Authorization: Bearer esk_your_key" # 200 { "key": { "type": "custom", "name": "Pharmacy website", "hint": "esk_Ab12…wxyz", "active": true, "all_agents": false, "agents": [ { "id": 775, "name": "healthcare" } ], "permissions": { "chats": "write", "leads": "read", "inbox": "none", "whatsapp": "none", "agent": "none", "orders": "none", "reservations": "none", "webhooks": "none" }, "expires_at": null }, "agent": { "id": 775, "name": "healthcare" } }
/api/v1/key
Describes the key on the request: its agents, its permission per area, and the agent this request resolved to
(null for a key on several agents called without X-Agent-Id). An agent key answers
type: "agent" with every area at write. expires_at is set when you call it with
the old key of a rotation that is still in its grace period.
| Answer | Code | When |
|---|---|---|
| 401 | key_rotated | The key was rotated and its grace period is over — use the new one. |
| 403 | key_paused | The key is switched off on the Integration screen. |
| 403 | permission_denied | The key was not given this area (or only Read, for a write); required says which, e.g. leads:write. |
| 400 | agent_required | A key on several agents sent no X-Agent-Id; agents lists them. |
| 403 | agent_not_allowed | X-Agent-Id names an agent the key does not work on. |
| 403 | no_agents | Every agent of the key was deleted or moved to another account. |
| 403 | key_widget_only | An agent key kept for the website widget only. |
Rotating gives a new key and keeps the old one working for 24 hours, so you can deploy the new one first; "rotate immediately" stops the old one at once (a leaked key). Both share one rate-limit allowance.
Errors, rate limits and conventions
| Status | Means |
|---|---|
200 / 201 | Done. 201 when something was created. |
401 | Missing or unknown API key. |
403 | The plan does not allow this (e.g. taking an agent live). |
404 | No such record on this agent. |
409 | Already in that state — e.g. requesting a channel that is connected. |
422 | Validation failed. code: "validation_failed"; errors names the fields. |
429 | Rate limited. Retry-After says how long to wait (code: "rate_limited"). |
502 / 503 | A service behind us (the knowledge index) was unreachable. Safe to retry. |
Every answer under /api/v1 is JSON — whatever Accept header you send (sending
Accept: application/json is harmless, just no longer needed). Errors always carry an
error message, so one handler covers them all; many add a machine-readable code:
{ "error": "That code is not valid." }
# 422 when a field breaks its rule — message + errors as well, keyed by field:
{ "error": "The instruction field must be at least 3 characters.",
"code": "validation_failed",
"message": "The instruction field must be at least 3 characters.",
"errors": { "instruction": ["The instruction field must be at least 3 characters."] } }
The wording of validation messages follows the platform's language (Arabic by default) — branch on
code and on the field names in errors, never on the text.
Rate limit: 120 requests per minute per key, shared by every /api/v1 endpoint.
Once the key is recognised, every response — success, 4xx and 429 alike —
carries X-RateLimit-Limit and X-RateLimit-Remaining; a 429 adds
Retry-After (seconds) and X-RateLimit-Reset (unix time the window resets).
Requests with a missing or wrong key are counted per calling IP address instead: a 401 carries
that allowance (X-RateLimit-Limit: 60), and once an address spends it, further attempts with a missing or wrong key
get 429 for the rest of the minute. A valid key is always served, whichever address it comes
from — a working integration never fails authentication, so it never touches this allowance.
Timestamps are ISO-8601 with an offset; ids are integers unless stated.
+ means "space" in a query string, so
?since=2026-09-04T10:00:00+02:00 arrives broken unless URL-encoded
(%2B02:00). We repair that specific case rather than reject it, but encoding it
properly is still the right habit.
Chat — talk to the agent from your software
The chat API is how your own app, backend, kiosk or mobile client holds a conversation with the agent.
A chat is one customer: open it once, keep its id, send every message of
that customer through it, and read the transcript back whenever you need it. Behind the id the agent
runs the very same pipeline a WhatsApp or Messenger customer gets — memory across turns, lead capture
and scoring, flags, orders, reservations, tickets and every lead.* webhook — so a person
who arrives through your app is a first-class lead on the Leads screen, in GET /leads, and
in your CRM feed.
| Step | Call | You get |
|---|---|---|
| Open | POST /chats | a chat.id — keep it per customer |
| Talk | POST /chats/{id}/messages | the agent's reply, synchronously |
| Read | GET /chats/{id}/messages | the full transcript, both sides, paged |
| Manage | GET /chats · GET /chats/{id} · DELETE /chats/{id} | list, inspect (with the lead), close |
POST /embed/{key}/chat
is stateless — the browser carries the last few turns and nothing is kept, which is right for a
drop-in bubble and wrong for an integration. (Agents that take orders are the exception: their widget
runs on the chat API — see below.) If you need history, a lead, or to resume a conversation
later, use the chat API. Both count toward the plan's message quota the same way.
Open a chat
https://everysecond.ai/api/v1/chats| Field | Type | Notes |
|---|---|---|
external_id | string ≤191 | Optional but recommended: your own id for this customer (user id, session id, phone). Unique per agent — creating again with the same value returns the same chat (200, created: false) instead of a second one. |
name | string ≤120 | Optional. How the agent addresses the customer and how the chat is labelled on the Tracking screen. |
phone | string ≤40 | Optional. Stored on the chat and copied onto the chat's lead (contact.phone, read in the business's country: 01… → +201…) — the lead starts with it, so lead.created carries it and the agent doesn't ask for a number you already gave. Sending a new one later (create again with the same external_id) updates the lead too, unless the customer typed a different number in the chat or a teammate changed it: those are never overwritten. A name sent later reaches the lead the same way. |
metadata | object | Optional, yours: anything you want echoed back (plan, page, locale…). Not shown to the agent. |
POST https://everysecond.ai/api/v1/chats
{ "external_id": "user-42", "name": "Mona", "metadata": { "source": "ios-app" } }
# 201 Created
{
"chat": {
"id": 17, "external_id": "user-42", "name": "Mona", "phone": null,
"metadata": { "source": "ios-app" },
"message_count": 0, "last_message_at": null, "created_at": "2026-09-22T10:00:00+03:00"
},
"created": true
}
Send a message, get the reply
https://everysecond.ai/api/v1/chats/{id}/messagesOne customer message in, one agent reply out. The call blocks while the agent thinks (typically 2–8 s; allow a 60 s client timeout). Send messages one at a time per chat — the agent reads them in order.
POST https://everysecond.ai/api/v1/chats/17/messages
{ "message": "Do you deliver to Maadi?" }
# 200 OK
{
"chat_id": 17,
"status": "replied",
"reply": "Yes — delivery to Maadi is 40 EGP and takes two days. Shall I take your order?",
"message_id": 5120, # the customer's row in the transcript
"reply_id": 5121, # the agent's row
"sent_at": "2026-09-22T10:00:04+03:00",
"lead_id": 903, # present once the conversation has produced a lead
"products": [ … ], # product cards — see below; [] when the reply recommends none
"cart": { … }, # ordering agents: the basket after this turn — see below; null when empty
"order": null, # ordering agents: the order this turn placed or changed
"image": { "name": "Menu", "url": "https://…/storage/…/menu.jpg" }, # only when the agent sent a picture
"welcome": [ "Hello Sara, welcome to …", … ] # only on a customer's first message, when the agent has welcome messages: sent before reply, one message each
}
status | Meaning | reply |
|---|---|---|
replied | The agent answered. | the text |
handoff | A person has taken over this conversation — on the Tracking screen, or from your own dashboard (POST /leads/{id}/replies, POST /leads/{id}/pause); the AI stays silent. Keep polling the transcript — their replies appear there. | null |
held / media_ticket | The message was routed to a human ticket (e.g. it followed a photo). No AI reply. | null |
no_answer / silent | The agent chose not to answer (empty or unanswerable input). | null |
error | The agent could not process it; a ticket was opened for the team. HTTP 502. | null |
| Status | When |
|---|---|
403 plan_ended | The subscription behind the agent has ended. Same rule as every other channel: nothing automated goes out until it is renewed. |
403 quota_reached | The plan's message quota for this cycle is used up. error carries the limit. |
429 chat_rate_limited | Loop protection: this one chat sent more than 120 messages within an hour — far more than a person types, so almost always a script answering the agent in a loop. The chat is paused until its hour is over (Retry-After / retry_after seconds); the message is not recorded and nothing is charged. Your other chats are not affected. |
404 | No such chat on this agent (a chat id from another key is a 404, never a 403). |
422 | message missing or longer than 4 000 characters, both message and audio sent, or audio is not a recording (code: invalid_audio). |
Product cards
When the agent sells (Orders module on) and its Product photos setting is
“Product cards with every recommendation” (agent screen → Orders agent), every reply that
recommends specific products carries them in products: up to 5 cards, in the order the agent
presents them. Everything on a card comes from the agent's menu — never from the model — so prices and
photos are always the real ones. It is the same data the website widget draws in its slider; render it
however your app likes (a carousel under the message works best). With the setting on
“Only when the customer asks”, products is always [].
"products": [
{
"menu_item_id": 2469,
"external_id": "cetaphil-oily-skin-cleanser-118", # your own product id, when synced
"branch_id": 177,
"name": "Cetaphil Oily Skin Cleanser 118 Ml", # Arabic name when the customer writes Arabic and one is set
"description": "Gentle daily cleanser for oily skin…", # ≤ 140 chars, or null
"category": "Skin care",
"price": 75.0, # what the customer pays today
"original_price": 85.0, # the list price when on offer, else null
"offer_name": "Summer deal", # or null
"currency": "QAR",
"price_text": "75.00 QAR", # ready to show, in the customer's language
"image_url": "https://…/storage/menu-items/cards/…jpg", # 600×600 square, white background
"image_full_url": "https://…/storage/menu-items/…jpg", # the original photo
"product_url": "https://your-store.com/p/…", # or null — the widget opens it from the photo and the name
"buy_url": "https://your-store.com/cart/4401:1", # or null — "Buy now": the store's cart / checkout link (e-commerce flow)
"orderable": true, # false = no "add to order" (a link-only store) — show View product / Buy now instead
"in_stock": true,
"options": { "size": "118 ml" } # or null
}
]
An “add to order” button only needs to send the customer's wish as the next message — e.g.
{ "message": "Add Cetaphil Oily Skin Cleanser 118 Ml to my order" }; the agent puts it in the
basket. The cards are part of the reply: they are stored on the reply's row (media: [{ "type":
"products", "items": [ … ] }] in the transcript) and count as one message,
together with the text. Cards are not repeated when the next reply talks about the same products, and a
reply that places or changes an order carries none.
The basket and the order
For an agent that takes orders, every reply also says where the sale stands, so your app never has to parse the text:
cart— the customer's basket as it is after this turn: what the agent has put in it so far, with each line'smenu_item_id,external_id,name,unit_price,qtyandline_total, plusitems_totaland your system's lastmerchant_quote.nullwhen there is no basket — including right after it became an order.order— when this turn placed, changed or cancelled an order: the full order, the same object as GET /orders/{id} and theorder.*webhooks (id, status, items, totals,merchant_ref,payment_url…).nullotherwise.
{
"reply": "Added the Cetaphil cleanser — anything else, or shall we arrange delivery?",
"products": [],
"cart": {
"id": 4, "status": "active", "branch_id": 177,
"items": [
{ "line_id": "item:2469", "menu_item_id": 2469, "external_id": "cetaphil-oily-skin-cleanser-118ml", "name": "Cetaphil Oily Skin Cleanser 118 Ml",
"unit_price": 75.0, "qty": 1, "line_total": 75.0 }
],
"items_total": 75.0,
"merchant_quote": { "stage": "quote", "ok": true, "delivery_fee": 5.0, "total": 80.0 },
…
},
"order": null
}
The same basket reaches your server without polling through the cart.item_added,
cart.item_removed, cart.updated and cart.converted webhooks, and
GET /orders/carts lists every open basket. Agents without orders get neither field.
Write the basket from your own cart
https://everysecond.ai/api/v1/chats/{id}/carthttps://everysecond.ai/api/v1/chats/{id}/carthttps://everysecond.ai/api/v1/chats/{id}/cartIf your website or app has a cart of its own, keep the two in step in both directions. What the customer picked on your site becomes the chat basket, and the agent works from it on its next reply — the customer never starts over. A basket they paid for on your site is closed here, so it is not offered again in the chat and is not left open as an abandoned basket.
PUT https://everysecond.ai/api/v1/chats/17/cart
{ "items": [ { "external_id": "SKU-1042", "qty": 2 }, { "menu_item_id": 2469, "qty": 1 } ] }
# 200
{
"cart": { "id": 4, "status": "active", "changed_by": "api", "items": [ … ], "items_total": 231.0, … },
"skipped": [ { "external_id": "SKU-77", "qty": 1, "reason": "not_found" } ],
"adjusted": [ { "external_id": "SKU-1042", "requested_qty": 5, "qty": 2, "reason": "max_qty_per_order" } ]
}
itemsreplaces the basket's lines — send the whole basket each time. Each line namesexternal_id(your SKU, as in the menu API),menu_item_idorbundle_id, plusqty(1–999)."items": []empties it.- Lines are priced from the menu (offers applied) and follow the chat's ordering rules exactly as if the
agent had added them. Nothing is dropped silently: a line that cannot go in is listed under
skippedwith its reason (not_found,unavailable,not_orderable_in_chat), a capped quantity underadjusted. If none of the lines can go in, the answer is422and the basket is left as it was. branch_idis only needed when the agent sells from more than one branch and the chat has no basket yet.- The store's last quote (
merchant_quote) is cleared when your change moves the basket — it priced a basket that no longer exists.
DELETE https://everysecond.ai/api/v1/chats/17/cart
{ "reason": "paid_on_website" } # optional, up to 100 characters (also accepted as ?reason=)
# 200 { "closed": true, "cart": { "status": "closed", "closed_at": "…", "closed_reason": "paid_on_website", … } }
# 200 { "closed": false, "cart": null } # there was no open basket — safe to repeat
A closed basket is not an order and fires cart.closed, not cart.converted. It stays
closed: if the customer starts shopping again — in the chat or through another PUT — a
new basket opens with a new id (the same holds after a basket becomes an order). A customer
has at most one open basket.
The basket is the source of truth. The agent is shown the basket as it is now on every reply,
including your changes, and is told what your system removed and which basket you closed. The platform also
enforces it: an item your system removed, or one that was in a basket you closed, is not put back by the agent,
neither in the basket nor in an order, unless the customer names that product in the message being answered
("رجّعلي الـ Cetaphil"). If the agent's reply tries anyway, it is asked once more; if it still does, the item is
left out and the customer is told why. Every cart.* webhook says who made the change
(source: agent or api), so your system can skip its own changes.
409 on an agent without orders, 404 for a chat that is not this agent's.
Voice notes
Send what the customer said instead of what they typed: post the recording as
multipart/form-data in an audio field, in place of message. The agent
treats it exactly like a WhatsApp or Messenger voice note — it is transcribed (Egyptian and Gulf dialects,
English, mixed), the transcript is answered like any typed message with the same lead, memory, flags,
orders and bookings behind it, and the recording is kept on the transcript so the Tracking screen and
the history can play it back.
curl -X POST https://everysecond.ai/api/v1/chats/17/messages \ -H "Authorization: Bearer es_your_key" \ -F "audio=@voice-note.ogg" # 200 OK { "chat_id": 17, "status": "replied", "transcript": "بتوصلوا المعادي؟ والتوصيل بكام؟", # what the agent heard "reply": "أيوه، التوصيل للمعادي 40 جنيه ويوصل في يومين.", "message_id": 5122, "reply_id": 5123, "audio": { "url": "https://…/storage/inbound-media/…/….ogg", "mime": "audio/ogg", "size": 18422 } }
| Field | Type | Notes |
|---|---|---|
audio | file ≤ 25 MB | ogg/opus (WhatsApp's own format), m4a/aac, mp3, wav, webm, mp4 audio. Checked by content, not by name — a photo or PDF is refused with 422 invalid_audio. |
language | string, optional | ISO-639-1 hint (ar, en, …) when you know what the customer speaks. Leave it out otherwise — detection is automatic and just as accurate. |
The response carries transcript and audio on top of the usual fields. When nothing
intelligible can be made out of the recording, the agent does not guess: status is
media_ticket, transcript and reply are null, and a ticket is
opened for your team — the same hand-off a WhatsApp voice note gets. In the transcript such a message reads
[audio], with the recording in media.
Read the transcript
https://everysecond.ai/api/v1/chats/{id}/messages| Query | Default | Notes |
|---|---|---|
limit | 100 | 1–500 messages per call. |
before | — | A message id: the page of messages older than it. Walk back through a long chat by passing the first id of the previous page. |
after | — | A message id: only messages newer than it. Poll with the last id you have seen to pick up a human reply typed on the Tracking screen. |
GET https://everysecond.ai/api/v1/chats/17/messages?after=5121
{
"chat_id": 17,
"messages": [
{ "id": 5120, "direction": "inbound", "author": "customer", "text": "Do you deliver to Maadi?", "media": null, "sent_at": "…" },
{ "id": 5121, "direction": "outbound", "author": "agent", "text": "Yes — 40 EGP, two days.", "media": null, "sent_at": "…" }
],
"has_more": false,
"total": 2
}
Messages are oldest-first. media lists a picture the agent sent
([{ "type": "image", "url": "…", "name": "…" }]), the customer's
voice note ([{ "type": "audio", "url": "…", "mime": "audio/ogg" }], with the
transcript in text), or is null.
List, inspect and close
https://everysecond.ai/api/v1/chats?per_page=25&page=1&external_id=user-42https://everysecond.ai/api/v1/chats/{id}https://everysecond.ai/api/v1/chats/{id}
The list is most-recently-active first and paginated (total, per_page,
current_page, last_page). GET /chats/{id} adds lead: the
lead object this chat has produced so far, or null before the customer
has said anything. Closing a chat removes the handle only — the transcript and the lead are the customer's
record and stay; a later POST /chats with the same external_id starts a fresh
conversation with no memory of the old one.
handoff status above) and type replies your app picks up by polling with after=.
Practice runs never leak: the Training Yard is a separate data set.
The website widget
https://everysecond.ai/embed/{api_key}/launcherhttps://everysecond.ai/embed/{api_key}https://everysecond.ai/embed/{api_key}/chat
The drop-in chat bubble. Paste the launcher script before </body> on any site
(ready-made snippets for HTML, WordPress, Shopify and easyOrders are on the agent screen); it injects a
floating button that opens the widget page in an iframe. Requires the widget to be enabled on
the agent screen, and the agent key travels in the URL — this is the one endpoint meant to be called from a browser.
Because that key is then readable in your site's page source, give your servers a custom key and keep the agent key
for the widget only (Integration screen → the agent → "Also works on the API" off); the widget keeps working.
POST https://everysecond.ai/embed/es_your_key/chat
{ "message": "Hello", "messages": [ { "role": "user", "content": "…" }, { "role": "assistant", "content": "…" } ] }
# 200 { "reply": "Hi! How can I help?" }
# 200 plan ended or message quota used up: { "reply": "Thanks for reaching out. Automatic replies are unavailable right now — our team will get back to you shortly." }
# 403 { "error": "Widget not found or disabled." } — widget switched off or key invalid
# 429 { "error": "Rate limit exceeded. Please slow down." } + Retry-After — more than 30 messages/minute from this visitor, or 600/minute on the whole key
# A voice note: multipart, audio instead of message (history as a JSON string)
curl -X POST https://everysecond.ai/embed/es_your_key/chat -F "audio=@note.webm" -F 'messages=[]'
# 200 { "reply": "…", "transcript": "what the visitor said" }
# 422 { "code": "voice_unreadable" } nothing could be made out · { "code": "invalid_audio" } not a recording
The widget itself has a microphone button: visitors record a voice note (up to two minutes), see what the
agent heard under their bubble, and get the reply as text — the same way a voice note works on WhatsApp.
Voice notes are limited to 10 MB and 10 per minute per visitor. The launcher already grants the iframe
microphone access; if you frame /embed/{api_key} yourself, add allow="microphone".
messages (optional, up to 20) is the recent history the browser keeps; nothing is stored
server-side beyond usage counting and a lead once a phone number is mentioned. Need more than that — a
durable chat, the lead, the transcript — use the chat API above.
| Situation | Launcher /launcher | Widget page | POST /chat |
|---|---|---|---|
| Widget switched off, or unknown key | 404, body /* Widget not found or disabled */ (JavaScript, so the host page keeps working) | 403 (HTML error page) | 403 {"error": "Widget not found or disabled."} |
| Plan ended, or the plan's message quota used up | 200 — the bubble still shows | 200 | 200 with a polite holding line as reply (Arabic or English, following the conversation) — replies pause, they do not error |
| Too many messages | — | — | 429 + Retry-After: 30 messages/minute per visitor (the visitor_id the widget sends, else the IP), 600/minute across the whole key |
Agents that take orders: the widget runs on the chat API itself. Send a
visitor_id (16–64 letters, digits, - or _; the widget keeps one per
browser) and the visitor gets one durable chat — memory, basket and orders — and the response adds
products (the product cards, drawn by the widget as a slider under
the reply) and visitor_id. messages is then ignored: the server keeps the history.
Read the agent
https://everysecond.ai/api/v1/agentIts configuration, its industry, and which channels it currently answers on.
{
"agent": {
"id": 700,
"name": "Sara",
"status": "live",
"industry_id": 1,
"identity": "Sara, Restaurant assistant",
"tone": "Friendly and warm",
"instructions": [
"Confirm the delivery area before quoting a delivery fee.",
"Never quote a price that is not on the menu."
],
"reply_verbosity": "balanced",
"disable_emojis": false,
"comment_reply": "Thanks! We sent you the details in a private message.",
"human_takeover_hours": 6,
"reply_dialect": "auto",
"ticket_notice": "agent",
"phone_request": "once",
"business_country": null,
"channels": { "facebook": true, "instagram": true, "whatsapp": true, "widget": true },
"updated_at": "2026-09-04T01:20:11+00:00"
},
"industry": { "id": 9, "name": "Restaurant", "slug": "restaurant-full", "category": { "id": 1, "name": "Restaurant & Café", "slug": "restaurant" } },
"connections": {
"facebook": { "connected": true, "name": "Nile Foods", "external_id": "1027…", "connect_url": "…" },
"instagram": { "connected": false, "name": null, "external_id": null, "connect_url": "…" },
"whatsapp": { "connected": false, "name": null, "external_id": null, "connect_url": "…" },
"widget": { "connected": true, "name": null, "external_id": null, "connect_url": "…" }
}
}
Edit the agent
https://everysecond.ai/api/v1/agentA partial update: only the keys you send are touched. This matters — an integration that syncs one field must not blank the rest by omitting them.
| Field | Type | Notes |
|---|---|---|
name | string | 2–120 chars. What the agent is called. |
identity | string | Dropped verbatim into the model's prompt as “You are …”. Include the agent's name here. Up to 255 characters (same in the dashboard). |
tone | string | The voice every reply is written in, e.g. “Friendly and warm”. |
instructions | string[] | Replaces the whole list. Blank entries are dropped. Up to 200 lines, each up to 40,000 characters, 60,000 in all — the same limits as the dashboard. Nothing is cut before the model reads it. |
reply_verbosity | enum | short · balanced · detailed (concise, the dashboard's name for short, is accepted too; reads back as short) |
disable_emojis | bool | Strips emoji from every reply. |
comment_reply | string | The canned public reply to social comments. Part of the agent object, so it reads back (null when unset). |
human_takeover_hours | int 0–168 | How long the agent stays quiet in a Messenger, Instagram or WhatsApp conversation after a person replies in it — from Meta Business Suite, the Instagram or WhatsApp Business app, or the EverySecond inbox. Default 6; 0 = never pause automatically. A longer pause already running is never shortened. |
reply_dialect | enum | The Arabic dialect of replies. auto (default): the customer's own dialect, read from their messages — and while it isn't clear yet (a bare «السلام عليكم»), the dialect of business_country. mirror_neutral: the customer's, else neutral Arabic. Or one fixed dialect: gulf · levantine · egyptian · msa (فصحى). Instructions that set a dialect rule are followed. |
ticket_notice | enum | When the agent opens a ticket: agent (default) — it tells the customer in its own words, in their dialect, that the team will follow up; silent — nothing is said. No fixed sentence is ever added to a reply. A customer has at most one open ticket: a new request while one is open is added to it. |
phone_request | enum | When the agent may ask a customer for their phone or WhatsApp number: once (default) — at most once per conversation, at the first clear buying interest; agent — the platform adds no rule and the agent's instructions decide; never. In every mode the agent is told how many times it has already asked; a WhatsApp customer, whose number is known, is never asked. |
business_country | string|null | Where the business is, e.g. "United Arab Emirates" (the country names of the phone list). Reads local numbers a customer types (0501234567 → +971501234567) and sets the default dialect. null = detected (order currency for ordering agents › WhatsApp number › the owner's country). |
industry_id | int | From the industries offered in setup. |
status | enum | draft · testing · live · archived. Going live needs a paid plan (else 403). |
curl -X PATCH https://everysecond.ai/api/v1/agent \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{ "tone": "Professional and precise", "reply_verbosity": "short" }'
Answers with the updated agent object. agent.updated fires with
changes naming the fields whose value actually changed (a key sent with its current value
is not a change; a PATCH that changes nothing fires nothing) and source: "api". The same
event fires, with source: "dashboard", when someone edits the agent in the dashboard.
Append one instruction
https://everysecond.ai/api/v1/agent/instructions
Adds a single rule without sending the whole list back. Prefer this in automations: the
read-modify-write you would otherwise do is a lost-update race against anyone editing the
agent in the dashboard at the same moment.
Same per-line and total limits as above (422 past them).
curl -X POST https://everysecond.ai/api/v1/agent/instructions \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{ "instruction": "Never promise a delivery time before asking for the district." }'
Teach it — knowledge
Knowledge is what the agent answers from. Everything you add here is indexed and used on every channel within seconds. Three kinds, one endpoint.
https://everysecond.ai/api/v1/agent/knowledgeA block of text
curl -X POST https://everysecond.ai/api/v1/agent/knowledge \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{
"type": "text",
"title": "Delivery policy",
"text": "We deliver inside Cairo for 40 EGP within 2 days. Giza is 55 EGP…"
}'
A file
PDF, DOCX, XLSX, XLS or TXT — a price list, a menu, a company profile. Send it as multipart:
curl -X POST https://everysecond.ai/api/v1/agent/knowledge \ -H "Authorization: Bearer es_your_project_key" \ -F "type=file" \ -F "file=@price-list-september.pdf"
A page on your site
curl -X POST https://everysecond.ai/api/v1/agent/knowledge \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{ "type": "url", "url": "https://example.com/shipping" }'
All three answer 201 with the stored document:
{ "document": { "id": "api_66d…", "type": "text", "title": "Delivery policy", "chars": 812 } }
A text block's title (optional, up to 120 characters) is kept and shown in the listing below
and on the agent screen. knowledge.added fires with the same document object and
source: "api"; knowledge added in the dashboard fires it too, with
source: "dashboard".
task_id and the document becomes answerable once indexing finishes (usually
seconds). Text is available immediately.
List and remove
https://everysecond.ai/api/v1/agent/knowledgehttps://everysecond.ai/api/v1/agent/knowledge/{document_id}{
"documents": [
{ "id": "api_66d…", "type": "Manual Text", "title": "Delivery policy",
"name": "Delivery policy", "excerpt": "We deliver inside Cairo for 40 EGP…" },
{ "id": "pdf_66e…", "type": "price-list-september.pdf", "title": "Margherita 120 EGP · Pepperoni 140 EGP · Four Che",
"name": "Margherita 120 EGP · Pepperoni 140 EGP · Four Che", "excerpt": "Margherita 120 EGP…" }
],
"total": 2
}
One row per document, and total counts documents. id is what DELETE
takes. type is how the index groups the document: Manual Text for text, the file
name for a file, URL: … for a page. title (and name) is the title you
gave a text block when you added it; without one, it is the index's own label — the first 50 characters of
the document. The list is always flat, whatever the mix.
Keeping a price list current is the common job: delete the old document and post the new file in the same script, and the agent stops quoting last month's prices the moment it finishes.
Channels & requesting a Meta connection
https://everysecond.ai/api/v1/agent/connectionshttps://everysecond.ai/api/v1/agent/connections/metahttps://everysecond.ai/api/v1/agent/connections/whatsapphttps://everysecond.ai/api/v1/agent/connections/{id}connection.requested so your tooling
can chase it, hands back the URL the owner has to open, and closes itself
automatically the moment that channel appears on the agent.
curl -X POST https://everysecond.ai/api/v1/agent/connections/meta \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{ "note": "Connect the Nile Foods page, please." }'
# → 201
{
"connection": {
"id": 12,
"channel": "meta",
"status": "pending",
"note": "Connect the Nile Foods page, please.",
"connect_url": "https://everysecond.ai/facebook/login/700",
"requires_login": true,
"requested_at": "2026-09-04T01:31:00+00:00",
"completed_at": null
}
}
Send connect_url to the account owner — they must be signed in to the dashboard
when they open it. Instagram rides the same Facebook grant, so one connection covers both.
Asking twice returns the open request (already_open: true) rather than piling
up duplicates; asking for a channel that is already connected answers 409.
The leads feed
https://everysecond.ai/api/v1/leads
Every person the agent has spoken to. This is the pull side of the lead.* webhooks
and serves the identical payload, so your CRM mapper is written once and used
by both: webhooks keep you current, the feed backfills what happened while your endpoint was
down and seeds the first import.
| Query | Type | Notes |
|---|---|---|
since / until | ISO-8601 | Filter on creation time. URL-encode the +. |
channel | enum | facebook · instagram · whatsapp · website |
min_score | int | Only leads at or above this score. |
flag | string | Exact flag name. An unknown name matches nothing, never everything. |
has_phone | bool | Only leads with a number you could actually dial. |
search | string | Matches name or phone. |
order | enum | asc (default, oldest first) or desc. |
per_page / page | int | Up to 200 per page. |
created_at of the last lead you
stored and pass it as since on the next run, with the default
order=asc. Because the feed is ordered oldest-first, you can walk forward through
pages and never skip a row, even while new leads are arriving.
curl "https://everysecond.ai/api/v1/leads?since=2026-09-01T00:00:00%2B02:00&min_score=20&has_phone=1&per_page=100" \
-H "Authorization: Bearer es_your_project_key"
{
"leads": [ /* see below */ ],
"pagination": { "page": 1, "per_page": 100, "total": 248, "total_pages": 3, "has_more": true }
}
The lead object
Deliberately grouped the way a CRM thinks: who they are, where they came from, what the agent
worked out. Every key is always present — an absent value is null
rather than a missing key, because a disappearing key breaks naive field mappings.
{
"id": 90210,
"created_at": "2026-09-04T01:12:03+00:00",
"updated_at": "2026-09-04T01:20:44+00:00",
"contact": {
"name": "Mona Adel",
"first_name": "Mona",
"last_name": "Adel",
"phone": "01001234567",
"phone_e164": "+201001234567",
"email": null,
"language": "ar",
"external_id": " the channel's own id for this person — stable, use it to dedupe"
},
"attribution": {
"source": "everysecond",
"channel": "whatsapp",
"channel_code": "wp",
"agent_id": 700,
"agent_name": "Sara"
},
"crm": {
"status": "qualified",
"assigned_to": 1234,
"source": "chat",
"next_follow_up": "2026-10-01T10:00:00+03:00"
},
"qualification": {
"score": 42,
"score_reason": "Asked for a price and gave a delivery address",
"summary": "Wants 2 large pizzas delivered to Maadi this evening.",
"inquiry": "Delivery to Maadi",
"flags": ["Hot", "Wants a quote"]
},
"links": {
"conversation": "https://everysecond.ai/api/v1/leads/90210/conversation",
"dashboard": "https://everysecond.ai/leads/90210"
}
}
phone_e164 is the field to deduplicate on — it is the format every CRM stores.
Local Egyptian numbers (01…) are converted to +20…; a number we cannot
confidently place is null rather than a guess. score rises as the
conversation shows intent, so a lead you already imported can become interesting later — see
lead.updated.
CRM field mapping
Starting points for the usual destinations:
| EverySecond | HubSpot | Salesforce | Zoho CRM |
|---|---|---|---|
contact.first_name | firstname | FirstName | First_Name |
contact.last_name | lastname | LastName | Last_Name |
contact.phone_e164 | phone | Phone / MobilePhone | Phone |
contact.external_id | a custom “EverySecond ID” property | External Id (unique) | a custom field |
attribution.channel | hs_analytics_source_data_1 | LeadSource | Lead_Source |
qualification.score | hubspotscore | Rating / a custom score | a custom field |
qualification.summary | a note on the contact | Description | Description |
qualification.flags | multi-checkbox property | multi-select picklist | multi-select |
crm.status | Lead status | Lead Status | Stage |
links.dashboard | a URL property | a URL field | a URL field |
Map the flag vocabulary once by reading
GET https://everysecond.ai/api/v1/leads/flags, which lists each flag with its description and
whether it is assigned manually, by keyword, or by the AI.
Conversations
https://everysecond.ai/api/v1/leads/{id}/conversationThe transcript behind a lead. A score without the conversation is not much use to the person picking the lead up — they need to read what was actually said before calling. Only this agent's own channels are read: a customer who also talks to another business on EverySecond never brings that conversation with them.
| Query | Type | Notes |
|---|---|---|
limit | int | 1–500 messages per page, default 200. |
before | int | A message id: return the page of messages older than it. Pass the previous page's meta.next_before. |
curl "https://everysecond.ai/api/v1/leads/90210/conversation?limit=3" -H "Authorization: Bearer es_your_project_key"
{
"lead": { /* the same lead object */ },
"messages": [
{ "id": 50114, "direction": "inbound", "author": "contact", "text": "[image]", "media": [
{ "type": "image", "mime": "image/jpeg", "size": 81406,
"url": "https://everysecond.ai/storage/inbound-media/42/Xq7r2LmB9wTz4KcVn8sPdYhG3aF6eJ0uQiR5oN1t.jpg" } ], "sent_at": "…" },
{ "id": 50115, "direction": "outbound", "author": "agent", "text": "Yes — 40 EGP, two days.", "media": [], "sent_at": "…" },
{ "id": 50131, "direction": "outbound", "author": "human", "author_name": "Ahmed", "text": "Hi, Ahmed here — 30 EGP today.", "media": [], "sent_at": "…" }
],
"total": 3,
"meta": { "limit": 3, "has_more": true, "next_before": 50114 }
}
The first call returns the newest messages; inside a page they read oldest to newest.
To read further back, call again with before= the meta.next_before you got —
it is null (and has_more false) once you have reached the start. total
is the number of messages in this page.
author is contact for the person, agent for what the business sent
automatically (the AI's replies, pictures it sent, order-status updates, follow-ups, campaign templates) and
human for a reply a teammate typed (Tracking, the WhatsApp inbox, the Comments screen, or your own
dashboard through POST /leads/{id}/replies). author_name is the
teammate's name when it was given (the author of a reply sent through the API), otherwise
null. Messages recorded before July 2026 carry fewer markers, so an old automatic message can
occasionally show as human.
Media. Every message carries media, a list ([] when there is none) in the
same shape as the chat transcript and message.received: photos, videos, voice
notes, documents and stickers the customer sent on WhatsApp, Messenger or Instagram, and pictures the agent sent.
text keeps the [image]-style marker or the caption (a voice note's text is
its transcript).
| Entry | Meaning |
|---|---|
{ "type", "url", "mime", "size", "name"? } | Stored. type = image · video · audio · document · sticker; name is the file name when the customer's app sent one. |
{ "type", "pending": true } | Still being downloaded from Meta, usually for a few seconds. Read the conversation again. |
{ "type", "failed": true, "name"? } | Meta never handed the file over (an expired link, or over 25 MB). It will not appear later. |
{ "type": "products", "items": [ … ] } | Product cards an ordering agent showed on the chat API / widget (see product cards). |
The urls are on https://everysecond.ai/storage/… (allow that origin in
img-src / media-src). They need no API key — each is an unguessable random path — so they work
directly in <img>, <video> and <audio>. They do not expire:
the file stays as long as the conversation does (deleted with the account's data under the
data-retention policy). Treat them like the transcript itself and do not publish them. WhatsApp voice notes are
audio/ogg (Opus), which some browsers cannot play inline; offer the link as a download too.
Update a lead — write the CRM fields back
https://everysecond.ai/api/v1/leads/{id}
A partial update, the way PATCH /agent works: send only what changes, grouped as in the lead
object. Everything is written in one save, so one lead.updated names every field
that moved, with "source": "api" — that is how your system recognises its own writes coming
back and skips them. Each change also lands on the lead's timeline on the Leads screen, by author.
| Field | Type | Notes |
|---|---|---|
crm.status | enum | new · contacted · qualified · proposal · won · lost. |
crm.assigned_to | int | null | A team member id from GET /team: the account owner or a moderator of this agent (anyone else → 422 not_assignable). null unassigns. |
crm.next_follow_up | ISO-8601 | null | When to call next. Send an offset (2026-11-05T12:00:00+02:00); a time without one is read as UTC. Stored and returned in UTC. null clears it. |
contact.name | string ≤255 | Cannot be empty. |
contact.phone | string | null | Read in the business's country (01… → +201…); null removes it. |
contact.email | email | null | Stored lower-case. |
author | string ≤120 | Optional: the person on your side making the change. The timeline shows “Ahmed (API)”; without it, “API”. |
PATCH https://everysecond.ai/api/v1/leads/90210
{
"crm": { "status": "qualified", "assigned_to": 1234, "next_follow_up": "2026-11-05T12:00:00+02:00" },
"author": "Ahmed"
}
# 200
{
"lead": { /* the lead object, crm.next_follow_up = "2026-11-05T10:00:00+00:00" */ },
"changes": ["crm.status", "crm.assigned_to", "crm.next_follow_up"]
}
changes lists what actually moved; sending values the lead already has returns
"changes": [] and fires nothing. Errors are 422 with a code:
nothing_to_update (no crm / contact fields — a flat
{"status": …} is the usual cause), invalid_status, not_assignable,
invalid_phone, validation_failed. A lead of another agent is 404.
Notes
https://everysecond.ai/api/v1/leads/{id}/noteshttps://everysecond.ai/api/v1/leads/{id}/notes
The notes on a lead's timeline — the ones your team types on the Leads screen and the ones you add from your
own system (“called, no answer — try after 6”). A note added here shows on the screen by its
author; a note typed on the screen reaches you as lead.note_added
with "source": "dashboard".
POST https://everysecond.ai/api/v1/leads/90210/notes
{ "text": "Called — no answer, try after 6.", "author": "Ahmed" }
# 201
{
"note": {
"id": 5512,
"text": "Called — no answer, try after 6.",
"author": { "team_member_id": null, "name": "Ahmed" },
"source": "api",
"created_at": "2026-11-03T14:20:11+00:00"
}
}
GET https://everysecond.ai/api/v1/leads/90210/notes?limit=50
{
"notes": [ /* newest first; a note typed on the screen has author.team_member_id = the teammate's id (GET /team) */ ],
"meta": { "limit": 50, "has_more": false, "next_before": null }
}
text is required, up to 2,000 characters; author optional, up to 120.
GET takes limit (1–200, default 100) and before (a note id —
pass meta.next_before to page back). Only notes are listed; status moves and hand-offs stay on the
Leads screen's timeline.
The team
https://everysecond.ai/api/v1/team
The people who can hold this agent's leads, so you can show who has each customer and offer an assignee picker.
id is what crm.assigned_to holds, in the lead object and in PATCH.
{
"members": [
{ "id": 1201, "name": "Omar Hassan", "email": "omar@example.com", "role": "owner", "can_be_assigned": true, "assigned_leads": 12 },
{ "id": 1234, "name": "Mariam Adel", "email": "mariam@example.com", "role": "moderator", "can_be_assigned": true, "assigned_leads": 40 },
{ "id": 1188, "name": "Fady Samir", "email": "fady@example.com", "role": "moderator", "can_be_assigned": false, "assigned_leads": 3 }
]
}
The owner first, then this agent's moderators by name. Someone who still holds leads of this agent but is no
longer on it (moved to another agent, say) is listed with can_be_assigned: false, so every
assigned_to you meet resolves to a name. Moderators are added to an agent on the Human Team screen.
Two-way CRM sync
Keeping your own admin and the Leads screen showing the same pipeline:
- Subscribe an endpoint to
lead.created,lead.updatedandlead.note_added; upsert on the leadid. - When your team changes a lead,
PATCH /leads/{id}; when they log a call,POST /leads/{id}/notes. - On every event, skip
"source": "api"— that is your own write coming back. Applydashboard(a person on the EverySecond screens) andagent(the conversation: score, summary, a phone the customer typed). - Read
GET /teamonce (and when an unknownassigned_toappears) to map ids to people.
Answer as a person
https://everysecond.ai/api/v1/leads/{id}/replies
Your team answers a customer from your own dashboard, and it behaves exactly like a reply
typed on the Tracking screen: it reaches the customer on their channel — WhatsApp, Messenger, Instagram or the
chat API — it is on the transcript as author: "human", and the agent steps back in that
conversation. JSON for text; multipart/form-data to attach a picture or a file.
| Field | Type | Notes |
|---|---|---|
text | string ≤4000 | The reply. Required unless you send a file. **bold** is sent as WhatsApp bold. |
file | file (multipart) | Optional: a JPEG or PNG picture (up to 5 MB, WhatsApp's limit), or a PDF, Word, Excel, PowerPoint, text or CSV document (up to 16 MB). The type is read from the bytes, not the name. |
author | string ≤120 | Optional: the teammate's name. It is the transcript's author_name, the pause's by and what the dashboard shows (“Dr. Mona replied from your own system (API) — the agent paused for 6h”). |
pause | bool | Default true: pause the agent in this conversation, as Tracking does. false sends without pausing. |
curl -X POST https://everysecond.ai/api/v1/leads/90210/replies \
-H "Authorization: Bearer es_your_project_key" \
-F "text=Your prescription is ready — pick it up after 5 pm." \
-F "author=Dr. Mona" \
-F "file=@invoice.pdf"
# 201
{
"reply": {
"id": 50140, "direction": "outbound", "author": "human", "author_name": "Dr. Mona",
"text": "Your prescription is ready — pick it up after 5 pm.",
"media": [ { "type": "document", "mime": "application/pdf", "size": 48211, "name": "invoice.pdf",
"url": "https://everysecond.ai/storage/inbound-media/42/…pdf" } ],
"sent_at": "2026-11-10T15:02:11+00:00"
},
"conversation": {
"channel": "whatsapp", "channel_id": "1098765432",
"customer": { "id": "97455123456", "name": "Noor" },
"lead_id": 90210, "chat_id": null
},
"pause": {
"active": true, "until": "2026-11-10T21:02:11+00:00", "reason": "api_reply", "by": "Dr. Mona",
"hours": 6, "automatic": true, "label": { "ar": "…", "en": "Dr. Mona replied from your own system (API) — the agent paused for 6h" }
}
}
- Delivery. Messenger / Instagram / WhatsApp: sent by Meta, and recorded only once Meta accepted it.
The reply goes to the channel the customer last wrote on. A chat-API conversation has nothing
to deliver through: the reply is on the chat's transcript for your app to show
(
GET /chats/{id}/messages?after=, ormessage.sent), exactly like a Tracking reply. - With a file. On WhatsApp the text travels as the file's caption (when it is 1024 characters or fewer);
on Messenger and Instagram the text goes first, then the file. The transcript holds it as one message, with
mediain the usual shape. If the text went but the file was refused, you still get201, the text is on the transcript, andwarningsays why ({ "code": "file_not_sent", "error": "…" }). - The pause lasts the agent's human-takeover hours (default 6; 0 turns it off — the same setting
PATCH /agentwrites ashuman_takeover_hours), the same as a reply from the inbox, and never shortens a longer pause already running. It applies to chat-API conversations too: there,POST /chats/{id}/messagesanswersstatus: "handoff"until it ends or you resume.conversation.pausedfires withreason: "api_reply",message.sentwithauthor: "human". - 24-hour window. Meta lets a business answer freely only within 24 hours of the customer's last message. On Messenger / Instagram a later reply is retried once as a person's reply (Meta's Human Agent tag, up to 7 days); on WhatsApp a later reply needs an approved template (WhatsApp messaging).
Errors: 422 with a code — nothing_to_send, unsupported_file,
file_too_large, outside_window, channel_disconnected,
recipient_unavailable, send_refused (Meta's own words in error),
no_answer (Meta did not answer in time: read the conversation before sending again);
409 no_conversation (no WhatsApp / Messenger / Instagram / chat-API conversation to answer —
a classic website-widget visitor, for one) or chat_closed (the lead's chat was deleted);
404 for a lead of another agent. Nothing is sent or recorded on an error.
Take over and hand back
https://everysecond.ai/api/v1/leads/{id}/pausehttps://everysecond.ai/api/v1/leads/{id}/pausehttps://everysecond.ai/api/v1/leads/{id}/resume
The Tracking screen's Hand off and Resume, for one conversation. While it is paused the agent answers
nothing there — your team does (the customer's messages are still recorded on the transcript). GET says whether it is paused, why and until when
(whoever paused it: a teammate in your dashboard or on EverySecond, a reply typed outside EverySecond, or a reply
through this API).
| Field | Type | Notes |
|---|---|---|
hours | number | POST /pause: 0.25 – 8760. Default 168 (a week, as the Hand off button). Replaces any pause running. |
author | string ≤120 | Optional, both: who did it. On the lead's timeline and in the webhook's by. |
POST https://everysecond.ai/api/v1/leads/90210/pause
{ "hours": 2, "author": "Dr. Mona" }
# 200
{
"conversation": { "channel": "whatsapp", "channel_id": "1098765432", "customer": { "id": "97455123456", "name": "Noor" }, "lead_id": 90210, "chat_id": null },
"pause": { "active": true, "until": "2026-11-10T17:05:00+00:00", "reason": "manual", "by": "Dr. Mona", "hours": 2, "automatic": false, "label": { "ar": "…", "en": "Handed off to the team by Dr. Mona — the agent is paused" } }
}
POST https://everysecond.ai/api/v1/leads/90210/resume
{ "author": "Dr. Mona" }
# 200 — was_paused: false when it was not paused (harmless)
{ "conversation": { … }, "pause": { "active": false, "until": null, "reason": null, … }, "was_paused": true }
conversation.paused / conversation.resumed fire as for the dashboard. A pause ends by itself
at until (no event marks that moment). 409 / 404 as for
replies.
Tickets
https://everysecond.ai/api/v1/ticketshttps://everysecond.ai/api/v1/tickets/{id}https://everysecond.ai/api/v1/tickets/{id}/closehttps://everysecond.ai/api/v1/tickets/{id}/reopenThe conversations the agent handed to a person — the same tickets as the Tickets screen, for this agent. Close one once your team has answered; it leaves the screen's open queue too.
| Query | Type | Notes |
|---|---|---|
status | enum | open (default) · closed · all. |
lead_id / chat_id | int | Only this lead's / chat's tickets. |
since | ISO-8601 | Opened at or after. URL-encode the +. |
order | enum | desc (default, newest first) or asc. |
per_page / page | int | Up to 100 per page, default 50. |
curl "https://everysecond.ai/api/v1/tickets?status=open" -H "Authorization: Bearer es_your_project_key"
{
"tickets": [
{
"id": 311, "number": "TCK-2026-7Q2MZK4D", "status": "open",
"reason": "photo",
"reason_text": "[image] Customer sent a photo — needs human follow-up",
"last_message": "[IMAGE] (image only)",
"lead_id": 90210, "chat_id": null,
"conversation": { "channel": "whatsapp", "channel_id": "1098765432", "customer": { "id": "97455123456", "name": "Noor" } },
"assigned_to": null,
"opened_at": "2026-11-10T14:58:40+00:00", "updated_at": "2026-11-10T14:58:41+00:00", "closed_at": null
}
],
"pagination": { "page": 1, "per_page": 50, "total": 1, "total_pages": 1, "has_more": false },
"counts": { "open": 1, "closed": 87 }
}
reason | Opened because… |
|---|---|
handoff | The agent handed the conversation over — the customer asked for a person, or it could not help. reason_text is the agent's own reason. |
photo · video · document · sticker | The customer sent one; a person looks at media. |
voice_note | A voice note nobody could make out. |
media | The customer sent media together with a question. |
error | The agent could not process the message. |
When the agent hands a conversation over again while its ticket is still open, the new reason is added to that
ticket's reason_text instead of opening another (reason follows the first). last_message is the customer's latest words on it.
conversation is where the customer last wrote; chat_id is set for a chat-API customer.
POST /close and /reopen answer { "ticket": { … }, "changed": true }
(false when it already was) — closing does not resume the agent; resume does.
Recipe: your own human inbox
- List what needs a person:
GET /tickets?status=open(poll), plusconversation.pausedfor chats a person already took over. - Show the conversation:
GET /leads/{id}/conversation(orGET /chats/{id}/messages), live throughmessage.received/message.sent. - Take it over (
POST /leads/{id}/pause) and answer (POST /leads/{id}/replies, withauthor) — or just answer: a reply pauses the agent by itself. - Done:
POST /tickets/{id}/close, thenPOST /leads/{id}/resumeto hand the conversation back to the agent (or let the pause run out).
Reservations — bookings & availability
The same bookings as the dashboard calendar and the AI agent, with the same rules — a booking made here holds
its slot for the agent and the dashboard, and one the agent makes in a chat appears here and on your webhooks.
Needs the account's Reservations add-on (free, Finance → Bookings & orders). Every agent
books one way — GET /reservations/setup says which:
| type | A booking is… | Send |
|---|---|---|
general | a slot on a branch's calendar, inside its hours, one at a time | branch_id, start_at, end_at |
medical | a doctor's slot, inside the doctor's weekly timetable (doctors never block each other) | doctor_id (or resource_id), start_at — the end is one slot |
hotel | a room for whole nights, check-in 12:00 → check-out 12:00 local | room_id (or resource_id), check_in (YYYY-MM-DD), nights |
tourism | seats on a dated departure of a trip program; when the travelers don't fit (capacity = maximum travelers) the booking waits on the departure's waiting list and is promoted, in line order, as seats free up | departure_id, party_size (travelers), allow_waitlist (default true) |
| Method | Path | Notes |
|---|---|---|
| GET | https://everysecond.ai/api/v1/reservations/setup | type, timezone, branches + hours + the hotel's photos, specialties → clinics → doctors (timetable, slot length), rooms (+ photos), trip programs (+ photos, upcoming departures with seats) |
| GET | https://everysecond.ai/api/v1/reservations/availability | date (+ branch_id / doctor_id / specialty_id, duration) → slots · hotels: check_in, nights, room_type, guests → rooms free for the whole stay · tourism: from / to, program_id, party_size → departures with booked, seats_left, waitlist, fits |
| GET | https://everysecond.ai/api/v1/reservations | from / to (local days) or updated_since (sync), status (incl. waitlisted), branch_id, resource_id, departure_id, source (ai · dashboard · api), phone, per_page ≤ 200 |
| POST | https://everysecond.ai/api/v1/reservations | customer_name, customer_phone, title, notes, status (pending · confirmed, default confirmed), external_ref (your id, unique per agent), lead_id + the fields of the type above |
| GET | https://everysecond.ai/api/v1/reservations/{id} · /reservations/ref/{external_ref} | one booking |
| PATCH | https://everysecond.ai/api/v1/reservations/{id} | move (start_at / end_at, resource_id, check_in / nights, departure_id / party_size) → status rescheduled, or edit details |
| POST | https://everysecond.ai/api/v1/reservations/{id}/confirm · /cancel | confirm (time for an AI day request; a waiting booking is promoted when its seats are free) · cancel (frees seats: the waiting list moves up) |
Tourism seats. A booking holds seats while the travelers of its departure's pending, confirmed and
rescheduled bookings fit in the capacity; otherwise it is created waitlisted with a
waitlist_position (201 either way; allow_waitlist: false → 409 full). When seats
free up — a cancellation, a bigger capacity, a smaller or moved booking — waiting bookings are promoted in line order
when they fit (a group that doesn't fit is skipped, a smaller one behind it may go) and the customer is told in
their chat when the channel allows it. A booking that holds seats never loses them: a move or a bigger party that
doesn't fit is refused with 409 full (details.seats_left).
Photos. Hotels, rooms and trip programs carry photos[]
({id, url, width, height, mime, sort_order}, cover first) — the agent sends them in chat when a customer
asks to see the hotel, a room or a trip.
Times in: an ISO string with an offset is converted; a bare 2026-10-12 10:30 is business-local.
Times out are local with their offset. Refusals: 409 clash (with details.conflicts),
409 duplicate_external_ref, 422 outside_hours · resource_required ·
resource_not_found · past · invalid_nights · invalid_range ·
validation_failed, 403 reservations_disabled; tourism: 422 departure_required ·
departure_not_found · party_too_large · invalid_party, 409 full ·
no_seats.
curl -X POST "https://everysecond.ai/api/v1/reservations" \
-H "Authorization: Bearer es_your_project_key" -H "Content-Type: application/json" \
-d '{"doctor_id": 12, "start_at": "2026-10-12 10:30", "customer_name": "Ahmed Samir",
"customer_phone": "01012345678", "external_ref": "HIS-88421"}'
Keeping your system in sync
- Push: subscribe to
reservation.created,reservation.updated,reservation.confirmed,reservation.cancelled,reservation.waitlisted,reservation.promoted. They fire for every booking — made by the agent in a chat, by staff in the dashboard, or through this API — withchanged_by(ai · dashboard · api, orsystemfor an automatic promotion, with atrigger{reason, by}), the full reservation, andpreviousvalues on a move. - Setup:
reservation_resource.created/.updated/.deleted(specialties, clinics, doctors, rooms, trip programs —change: created · edited · activated · deactivated · photos · deleted),departure.created/.updated/.deleted,departure.full/departure.reopened(its last seat went / a seat is free again) andreservation_setup.updated(the business type changed, a hotel's gallery, or its booking settings). - Pull: poll
GET /reservations?updated_since=…— every change after that moment, cancellations included, oldest first; storemeta.next_updated_sinceas the next cursor. This also backfills anything missed while your endpoint was down. - Your ids: send
external_refwhen you book; read it back on every payload and look a booking up withGET /reservations/ref/{external_ref}.
Webhooks — register an endpoint
Endpoints can be registered by hand on the Integration screen (sidebar → Integration → your agent → Webhooks: add, edit, test, rotate the secret, read the delivery log) or from code with the calls below. Both manage the same endpoints.
https://everysecond.ai/api/v1/webhookshttps://everysecond.ai/api/v1/webhookshttps://everysecond.ai/api/v1/webhooks/{id}https://everysecond.ai/api/v1/webhooks/{id}https://everysecond.ai/api/v1/webhooks/{id}/test · /rotatecurl -X POST https://everysecond.ai/api/v1/webhooks \
-H "Authorization: Bearer es_your_project_key" \
-H "Content-Type: application/json" \
-d '{
"name": "CRM sync",
"url": "https://crm.example.com/hooks/everysecond",
"events": ["lead.created", "lead.updated", "lead.flagged"]
}'
# → 201. The secret is shown ONCE — store it now. Every endpoint answer is wrapped in "data".
{ "data": { "id": 4, "url": "…", "events": [...], "is_active": true, "previous_secret_expires_at": null, "secret": "whsec_…" },
"note": "Store the secret now — …" }
POST /webhooks/{id}/test sends a real, signed webhook.test delivery so
you can point your handler at something before a customer ever messages the agent.
Rotating the secret has a 24-hour overlap. POST /webhooks/{id}/rotate (and the
Integration screen's Rotate secret) returns the new secret once, plus
previous_secret_expires_at. Until then every delivery — new events, retries and redeliveries of
older ones — is signed with both secrets (one v1 each, see
verifying), so a receiver that has not deployed the new secret yet keeps verifying.
Afterwards only the new one signs. Send {"immediate": true} to drop the old secret at once
(previous_secret_expires_at: null). Rotating again inside the window retires the older secret
for good. Your receiver decides which secrets it accepts: remove the old one from its config as soon as the
new one is live — straight away if it leaked.
Event catalogue
Leads
| Event | Fires when |
|---|---|
lead.created |
A person the agent has never spoken to before sends a first message — on any channel. |
lead.updated |
The name, phone, email, score, score reason, summary, inquiry, CRM status, assignee or next follow-up changed. `changes` names the fields by their place in the lead object: contact.name, contact.phone, contact.email, qualification.score, qualification.score_reason, qualification.summary, qualification.inquiry, crm.status, crm.assigned_to, crm.next_follow_up. `source` says who: api (your key — PATCH /leads/{id}, or a phone / name given to POST /chats), dashboard (a person on the EverySecond screens) or agent (the conversation and automatic routing). |
lead.flagged |
One or more flags were newly attached. `source` says by whom: ai (the agent judged it), keyword (a message matched — a flag listed with assigned_by keywords) or manual (a person ticked it on the Leads screen, whatever the flag's mode). `flags` lists only the new ones. |
lead.note_added |
A note was added to a lead — typed on the Leads screen (one lead or in bulk; `source`: dashboard) or through POST /leads/{id}/notes (`source`: api). `note` = {id, text, author {team_member_id, name}, source, created_at}. |
Agent
| Event | Fires when |
|---|---|
agent.updated |
The agent's settings changed — through the API or in the dashboard (`source`: api or dashboard). `changes` names the agent-object fields that moved (name, tone, identity, instructions, comment_reply, status, channels.facebook…). |
knowledge.added |
A document (text, file or URL) was added to the agent's knowledge — through the API or in the dashboard (`source`: api or dashboard). |
knowledge.deleted |
A knowledge document was removed — through the API or in the dashboard (`source`: api or dashboard). |
Channels
| Event | Fires when |
|---|---|
connection.requested |
An integration asked for a channel to be connected through the API (`source`: api; in the dashboard the owner connects directly, which fires channel.connected). |
channel.connected |
A Facebook page, Instagram account or WhatsApp number finished connecting. `channel` = {channel, id, name, display_phone_number, agent}; `reconnect` is true when this page / account / number was connected before (a re-login, or a number Meta had cut off). |
channel.disconnected |
A channel stopped working for the agent. `reason`: owner_disconnected (the owner removed it in the dashboard or the app — `initiated_by`: owner) or meta_disconnected (Meta removed the partner / app, or our daily probe found the WhatsApp account gone — `initiated_by`: meta, `meta_reason` e.g. PRIMARY_INACTIVITY, `detected_by` meta_webhook or health_check). |
channel.restored |
A channel came back without a new login: the probe reaches a WhatsApp account Meta had cut off (`detected_by`: health_check, `previous_reason` = the old meta_reason), or a send works again after channel.needs_reauth (`detected_by`: send, `previous_reason`: token_invalid). A reconnect through the login is channel.connected with reconnect: true instead. |
channel.needs_reauth |
Meta rejected the channel's access token (Graph error 190 / 102) on an agent reply, a redelivery or a campaign send, and refreshing the page token did not help — the owner must reconnect. `error` = {code, subcode, type, message}; `detected_by`: reply, redelivery or campaign. Fires once until the channel works again. |
channel.quality_changed |
WhatsApp phone_number_quality_update: `event` (FLAGGED, UNFLAGGED, DOWNGRADE, UPGRADE, ONBOARDING…), `current_limit` / `previous_limit` (TIER_250 … TIER_UNLIMITED), `max_daily_conversations` when Meta sends it. |
WhatsApp templates
| Event | Fires when |
|---|---|
template.status_changed |
Meta's verdict on a WhatsApp template changed on one number: `status` approved | rejected | paused | disabled | pending, `previous_status`, `reason` (rejected / paused / disabled), `template` {id, name, language, category, meta_template_id}, `number` {phone_number_id, display_phone_number, waba_id}. Meta repeating the same verdict fires nothing. |
Conversations
| Event | Fires when |
|---|---|
message.received |
A customer sent a message on WhatsApp, Messenger, Instagram or the chat API (the ordering widget rides the chat API). `message` {id, text, media, created_at}, `conversation` {channel, channel_id, customer {id, name}, lead_id, chat (chat API only)}, `referral` {source, ad_id, post_id, headline, body, source_url, ref, ctwa_clid} when the message came from an ad, else null. lead_id is null for a brand-new customer's first message — lead.created follows. |
message.sent |
A reply reached the customer. `author`: agent (the AI: replies, product photos, follow-ups), human (a teammate in Tracking / the app inbox), human_outside (a person in Meta Business Suite or the Instagram / WhatsApp Business app — seen through Meta's echo) or system (order-status updates). A reply Meta refused first fires once redelivery lands; campaign template sends are not replies (the campaign API reports them). |
conversation.paused |
The agent stepped back in one conversation. `pause` = {reason: outside_reply | inbox_reply | api_reply | manual, label {ar, en}, by, hours, automatic, until, extended} — api_reply = a reply sent through POST /leads/{id}/replies. It resumes by itself at `until` — no event marks that moment. |
conversation.resumed |
A person switched the pause off before it ran out (Tracking / the app inbox). `resume` = {reason: manual, by, paused_reason}. |
Comments
| Event | Fires when |
|---|---|
comment.received |
A customer commented on a Facebook / Instagram post (live, from Meta's webhook). `comment` {id, meta_comment_id, text, post_id, created_at}, `channel`, `channel_id`, `commenter` {id, name}. |
comment.replied |
A public or private reply to a comment went out. `reply` = {id, kind: public | private, text, author: agent | human | human_outside, source: auto | manual | native, meta_reply_id, created_at} — agent = the canned public reply or the agent's DM, human = the Comments screen, human_outside = typed on Facebook / Instagram itself. |
Orders
| Event | Fires when |
|---|---|
order.created |
The agent took an order in chat. |
order.updated |
Items, address or fulfilment changed on an existing order. |
order.confirmed |
Staff confirmed the order. |
order.status_changed |
The order moved to another status. |
order.cancelled |
The order was cancelled. |
order.failed |
The order could not be placed. |
Carts
| Event | Fires when |
|---|---|
cart.updated |
The customer's in-progress cart changed. |
cart.item_added |
An item was added to a cart. |
cart.item_removed |
An item was removed from a cart. |
cart.converted |
A cart became a real order. |
cart.closed |
— |
Store & catalog
| Event | Fires when |
|---|---|
store.connected |
A store (Shopify, Salla, EasyOrders), product feed or product file was connected (Orders e-commerce flow). |
store.disconnected |
A store connection ended (`reason`: owner or uninstalled). |
store.needs_reauth |
The store refused our credentials — the owner must connect it again. |
store.order_received |
An order placed on the store itself arrived; order.created fires too. |
catalog.sync_completed |
A catalogue sync finished, with counts. |
catalog.sync_failed |
A catalogue sync failed; nothing was deleted. |
product.created |
A product was added (`source`: dashboard, api, csv, feed, shopify, salla, easyorders). |
product.updated |
A product changed (`changes`); stock taken by an order has `source: order`. |
product.deleted |
A product left the catalogue. |
Reservations
| Event | Fires when |
|---|---|
reservation.created |
A booking was made — by the AI in a chat, in the dashboard or through the API (`changed_by` says which). A tourism booking that does not fit is created `waitlisted` and also fires reservation.waitlisted. |
reservation.updated |
A booking moved (time, doctor, room, stay dates or departure — change: rescheduled) or its details changed (change: edited); `previous` holds the old values. |
reservation.confirmed |
A booking was confirmed. |
reservation.cancelled |
A booking was cancelled (a tourism cancellation frees its seats for the waiting list). |
reservation.waitlisted |
A tourism booking went onto its departure's waiting list — `reservation.waitlist_position` is its place in line. |
reservation.promoted |
A waiting booking got its seats: automatically when seats freed up (`changed_by: system`, `trigger` = {reason: cancellation · capacity · moved · resized · reopened, by}) or because staff promoted it. |
Reservation setup
| Event | Fires when |
|---|---|
reservation_resource.created |
A specialty, clinic, doctor, room or trip program was added (`resource.kind`). |
reservation_resource.updated |
One was changed — `change`: edited (with `changes` + `previous`), activated, deactivated or photos. |
reservation_resource.deleted |
One was deleted (`resource` is its last state). |
departure.created |
A tour departure was scheduled (a repeat creates one event per departure, sharing `departure.series`). |
departure.updated |
A departure's time, capacity, price, notes or switch changed (`changes` + `previous`). |
departure.deleted |
A departure without bookings was deleted. |
departure.full |
Its last seat was taken (`seats_left` 0). |
departure.reopened |
A full departure has a free seat again. |
reservation_setup.updated |
The agent's kind of business changed (`change: type`, `previous.type`), a hotel's gallery changed (`change: hotel_photos`, `branch_id`, `photos`) or its booking settings changed (`change: settings`, `settings`, `previous.settings` — checkout chat|website, links, weekend nights, extra guests). |
Order validation (your system answers)
| Event | Fires when |
|---|---|
order.validate |
Synchronous, optional: your system answers before an order is quoted and placed (see the Orders API docs). |
Conversation and channel payloads
Every conversation event names the chat the same way, so one handler can file them all; every
channel event carries the same channel object as channel.connected.
message.* is high-volume (one event per message) — subscribe only where you need it.
// message.received { "message": { "id": 98231, "text": "بكام ده؟", "media": [], "created_at": "2026-10-08T10:12:03+00:00" }, "conversation": { "channel": "whatsapp", "channel_id": "123456789012345", "customer": { "id": "201001234567", "name": "Karim" }, "lead_id": 512 }, "referral": { "source": "ad", "ad_id": "120211", "post_id": null, "headline": "Family box", "body": null, "source_url": "https://fb.me/…", "ref": null, "ctwa_clid": "ARAk…" } } // message.sent — same message / conversation, plus { "author": "agent" } // agent | human | human_outside | system // channel.disconnected { "channel": { "channel": "whatsapp", "id": "123456789012345", "name": "Koshary El Nil", "display_phone_number": "+20 100 000 0001", "agent": { /* the agent object */ } }, "reason": "meta_disconnected", "initiated_by": "meta", "meta_reason": "PRIMARY_INACTIVITY", "detected_by": "meta_webhook", "source": null }
message.received, but no message.sent follows: the agent answers from their
second message (if the chat is not paused). See the
WhatsApp API docs.
The envelope
Every delivery, of every event, has the same outer shape:
POST https://crm.example.com/hooks/everysecond X-EverySecond-Event: lead.created X-EverySecond-Event-Id: 0c2f… # same across retries AND replays — deduplicate on this X-EverySecond-Delivery: 918 # this delivery — unchanged on its automatic retries; a redeliver or test gets a new one X-EverySecond-Signature: t=1757000000,v1=9f86d081… { "id": "0c2f…", "event": "lead.created", "created_at": "2026-09-04T01:12:03+00:00", "project": { "id": 700, "name": "Sara" }, "data": { "lead": { /* the lead object */ } } }
Verifying signatures
The signature is t=<unix>,v1=<hex>, where the HMAC-SHA256 is taken over
"<unix>.<raw request body>" with your endpoint secret. The timestamp is
inside the hash, so a captured request cannot be replayed later with a fresh clock.
The header can carry more than one v1. For 24 hours after a
secret rotation every delivery is signed with the new and the previous secret:
t=<unix>,v1=<new>,v1=<old>,v1=<new> (the current signature first and
last, so a receiver still reading a single v1 keeps working). Accept the request when
any v1 matches a secret you hold — never assume a position or a count. The samples
below do exactly that.
PHP
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_EVERYSECOND_SIGNATURE'] ?? '';
$t = null; $signatures = [];
foreach (explode(',', $header) as $part) {
[$k, $v] = array_pad(explode('=', $part, 2), 2, '');
if ($k === 't') { $t = $v; }
if ($k === 'v1') { $signatures[] = $v; } // one per secret while a rotation overlaps
}
$expected = hash_hmac('sha256', $t . '.' . $raw, $secret);
$valid = false;
foreach ($signatures as $signature) {
$valid = hash_equals($expected, $signature) || $valid;
}
if ($t === null || ! $valid) { http_response_code(400); exit; }
if (abs(time() - (int) $t) > 300) { http_response_code(400); exit; } // stale
$event = json_decode($raw, true);
Node.js (Express)
const crypto = require('crypto');
// The raw body is required — register it before any JSON parser.
app.post('/hooks/everysecond', express.raw({ type: 'application/json' }), (req, res) => {
const pairs = (req.get('X-EverySecond-Signature') || '').split(',').map(p => p.split('='));
const t = (pairs.find(([k]) => k === 't') || [])[1];
const signatures = pairs.filter(([k]) => k === 'v1').map(([, v]) => v); // one per secret during a rotation
const expected = Buffer.from(crypto.createHmac('sha256', process.env.ES_WEBHOOK_SECRET)
.update(`${t}.${req.body}`)
.digest('hex'));
const ok = signatures.some(s => s.length === expected.length && crypto.timingSafeEqual(expected, Buffer.from(s)));
if (!ok || Math.abs(Date.now() / 1000 - Number(t)) > 300) return res.sendStatus(400);
const event = JSON.parse(req.body);
// ... hand off to a queue, then:
res.sendStatus(200);
});
Python (Flask)
import hmac, hashlib, time
@app.post("/hooks/everysecond")
def hook():
raw = request.get_data()
pairs = [p.split("=", 1) for p in request.headers.get("X-EverySecond-Signature", "").split(",") if "=" in p]
t = next((v for k, v in pairs if k == "t"), "")
signatures = [v for k, v in pairs if k == "v1"] # one per secret during a rotation
expected = hmac.new(SECRET.encode(), f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
if not any(hmac.compare_digest(expected, s) for s in signatures): return "", 400
if abs(time.time() - int(t or 0)) > 300: return "", 400
handle(request.get_json())
return "", 200
Retries, replay and idempotency
- Answer
2xxquickly. Anything else — or a timeout — counts as a failure. Acknowledge first, process afterwards. - Retries are automatic with a backoff (10 s, 1 min, 5 min, 30 min, 2 h — six attempts in all). They are the same delivery:
X-EverySecond-DeliveryandX-EverySecond-Event-Idstay the same, only the signature'stis fresh. A manual redeliver or a test is a new delivery with a newX-EverySecond-Delivery. - Deduplicate on
X-EverySecond-Event-Id, not on the delivery id — a manual replay from the dashboard reuses the event id too, deliberately. - An endpoint that keeps failing switches itself off after 20 consecutive failures, and the dashboard says why. Fix it and re-enable.
- Order is not guaranteed.
lead.updatedcan arrive before thelead.createdretry succeeds — usecreated_atand upsert on the lead id. - The delivery log (
GET /webhooks/{id}/deliveries) is newest first;?limit=defaults to 50 and is clamped to 1–200, never rejected.
curl https://everysecond.ai/api/v1/webhooks/4/deliveries \ -H "Authorization: Bearer es_your_project_key" curl -X POST https://everysecond.ai/api/v1/webhooks/deliveries/918/redeliver \ -H "Authorization: Bearer es_your_project_key"
WhatsApp messaging
Two directions, two places. Inbound WhatsApp — customers writing to your number — is
handled by the platform: connect the number once (agent screen, or
POST /agent/connections/meta) and the agent answers, captures the
lead, and fires the same lead.* and order.* webhooks documented above. There is
nothing to build. Outbound WhatsApp — messages you want sent from your own
backend (order confirmations, OTPs, campaigns) — is the WhatsApp Outbound API: approved templates only,
per-recipient delivery tracking, billed in credits.
| Method | Endpoint | Does |
|---|---|---|
| GET | https://everysecond.ai/api/v1/whatsapp/templates | Templates this agent can send (approved on at least one of its numbers) |
| GET | https://everysecond.ai/api/v1/whatsapp/templates/{id}/schema | What the template needs: body variables, media header, URL buttons, OTP |
| GET | https://everysecond.ai/api/v1/whatsapp/accounts | Connected numbers |
| GET | https://everysecond.ai/api/v1/whatsapp/credits | Credit balance |
| POST | https://everysecond.ai/api/v1/whatsapp/send | Create a campaign and dispatch it in one call (one recipient or many) |
| POST | https://everysecond.ai/api/v1/whatsapp/campaigns | Create a draft to review first |
| POST | https://everysecond.ai/api/v1/whatsapp/campaigns/{id}/send · /cancel | Dispatch or cancel a draft |
| GET | https://everysecond.ai/api/v1/whatsapp/campaigns/{id} | Status and counts |
| GET | https://everysecond.ai/api/v1/whatsapp/campaigns/{id}/recipients | Per-recipient status: queued → sent → delivered → read, or failed with Meta's reason |
Same key, same headers, same error shape. The full reference — template parameters, phone formats, delivery lifecycle, credits, error catalogue, code in four languages — is the WhatsApp Outbound API page.
Orders
When the Orders module is on, the agent takes orders and builds carts in chat. Read them with
GET https://everysecond.ai/api/v1/orders, /orders/{id}, /orders/carts,
/orders/branches, /orders/branches/{id}/menu; act on them with
POST /orders/{id}/confirm and /cancel; and subscribe to the
order.* / cart.* events in the catalogue. Details, payloads
and the cart lifecycle: Orders API & webhooks.
Recipes
Push every new lead into a CRM
// 1. Subscribe once, at install time. POST https://everysecond.ai/api/v1/webhooks { "name": "CRM", "url": "https://crm.example.com/hooks/everysecond", "events": ["lead.created", "lead.updated", "lead.flagged"] } // 2. On each delivery: verify, then upsert on contact.phone_e164 // (falling back to contact.external_id when there is no phone). // 3. Nightly, close any gap your endpoint missed: GET https://everysecond.ai/api/v1/leads?since=<last_created_at>&order=asc&per_page=200
Put the agent inside your own app
// On login (or first message): one chat per user, idempotent. POST https://everysecond.ai/api/v1/chats { "external_id": "user-42", "name": "Mona" } → chat.id // Every message the user types: POST https://everysecond.ai/api/v1/chats/17/messages { "message": "…" } → reply // Reopening the screen later: show the transcript, then poll for human replies. GET https://everysecond.ai/api/v1/chats/17/messages GET https://everysecond.ai/api/v1/chats/17/messages?after=<last id> # every few seconds while open
Keep the agent's price list current
GET https://everysecond.ai/api/v1/agent/knowledge # find the old document
DELETE https://everysecond.ai/api/v1/agent/knowledge/{old_id}
POST https://everysecond.ai/api/v1/agent/knowledge -F type=file -F file=@prices-october.pdf
Onboard a customer end to end, headless
PATCH https://everysecond.ai/api/v1/agent { "name": "Sara", "tone": "Friendly and warm",
"identity": "Sara, Restaurant assistant" }
POST https://everysecond.ai/api/v1/agent/knowledge { "type": "text", "text": "…everything about the business…" }
POST https://everysecond.ai/api/v1/agent/connections/meta { "note": "Connect the main page" }
# → send connection.connect_url to the owner; wait for channel.connected
