Lagbot API
Lagbot puts an AI salesperson, Nova, on a business's WhatsApp. Nova answers customers, quotes prices and closes orders. The Lagbot API lets your software work alongside Nova.
Keep the shop's catalogue in step with your POS or inventory system, keyed by your own product ids.
Read the orders Nova closes, with items, amounts in kobo, payment state and fulfilment details.
Read WhatsApp conversations and send replies inside WhatsApp's 24-hour window.
Pause Nova on one chat while a person handles it, then hand it back.
Receive signed HTTP calls when an order is created, paid or refunded, when a chat is handed off, and more.
It is built for POS and inventory systems, ordering apps, payment companies, and merchants with their own back office. Each API key belongs to one shop. The shop owner creates the key and gives it to you.
Base URL:
https://api.lagbot.app/v1
There is no sandbox or test mode yet. Test against your own shop. Every reply you send through the API is a real WhatsApp message to a real customer.
Money is in Nigerian naira, as whole kobo (₦1 = 100 kobo). Times are ISO 8601 strings.
Quickstart
-
Get a key
The shop owner signs in at web.lagbot.app, opens Developers, and creates an API key. They confirm with their PIN. The key starts with
lb_live_and is shown once. Store it in your server's secrets, never in a browser or mobile app. -
Make your first call
export LAGBOT_KEY="lb_live_..." curl https://api.lagbot.app/v1/shop \ -H "Authorization: Bearer $LAGBOT_KEY"{ "data": { "id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35", "name": "Ada Foods", "whatsapp": { "connected": true, "number": "2348012345678" }, "nova": { "on": true } } } -
Read the latest paid orders
curl "https://api.lagbot.app/v1/orders?status=paid&limit=10" \ -H "Authorization: Bearer $LAGBOT_KEY" -
Add your first webhook
On the same Developers page, add an https URL on your server. The owner confirms with their PIN. You get a signing secret that starts with
whsec_, shown once. Use Send test to receive a signedpingevent, then verify the signature on every call.Lagbot checks for changes about every 2 minutes, so events reach you a short time after they happen. See Webhooks.
Authentication and keys
Send the key as a bearer token on every request:
Authorization: Bearer lb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- The header must be exactly
Bearer, one space, then the key. - A key is
lb_live_followed by 43 characters fromA-Z a-z 0-9 _ -. Anything else is refused with401 invalid_api_key. - A missing, unknown or revoked key gets
401 invalid_api_key. - A key without the scope a route needs gets
403 insufficient_scope. The message names the missing scope. - Lagbot stores only a hash of the key. If it is lost, the owner creates a new one.
- A shop can have at most 10 active keys. The owner revokes a key on the Developers page. A revoked key can keep working for up to a minute while caches expire.
- Key names are 1 to 60 characters. Lagbot keeps each key's first 14 characters, its creation time and when it was last used, so the owner can tell keys apart.
Scopes
A key has all six scopes unless it was created with a narrower list.
| Scope | Allows |
|---|---|
shop:read | GET /v1/shop |
products:read | GET /v1/products, GET /v1/products/{id} |
products:write | PUT and DELETE /v1/products/by-ref/{external_id} |
orders:read | GET /v1/orders, GET /v1/orders/{code} |
conversations:read | GET /v1/conversations, GET /v1/conversations/{id}, GET /v1/conversations/{id}/messages |
conversations:write | POST /v1/conversations/{id}/messages, /take, /release |
Call the API from your server. Browsers block calls from other websites (CORS), and a key placed in a web page or app can be read by anyone.
Requests and responses
Envelope
Request bodies are JSON. Send Content-Type: application/json. A success answers {"data": ...}. A list adds next_cursor.
{ "data": { "conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f", "handled_by": "human" } }
A list (here, the last page)
{ "data": [], "next_cursor": null }
An error answers with an HTTP status and an error object. Branch on code. The message is for people and can change.
{ "error": { "code": "invalid_limit", "message": "limit must be a whole number from 1 to 100." } }
Money
Every amount is an integer in kobo, the smallest unit of the naira. 250000 is ₦2,500.00. Currency is always "NGN". An amount Lagbot does not know is null.
Times
Times are ISO 8601 strings with a UTC offset, for example 2026-11-24T09:12:44.512345+00:00 or 2026-11-24T09:12:44.512Z. Parse them as dates; do not compare them as strings.
Pagination
Lists are newest first. They take two query parameters:
| Parameter | Rules |
|---|---|
limit | Whole number from 1 to 100. Default 50. Otherwise 400 invalid_limit. |
cursor | The next_cursor from the previous page. Treat it as opaque. A malformed one gets 400 invalid_cursor. |
When next_cursor is null there are no more rows. Keep the other filters the same while you page.
curl "https://api.lagbot.app/v1/orders?limit=100&cursor=eyJhdCI6..." \
-H "Authorization: Bearer $LAGBOT_KEY"
Rate limits
- 300 requests per minute per shop, across all
/v1routes and all of the shop's keys. - 600 requests per minute per IP address, across all of Lagbot.
Over a limit you get HTTP 429. This answer comes from Lagbot's shared server layer, so its body is {"success": false, "error": "Too many requests. Please slow down."}, not the usual envelope. There is no Retry-After header. The window is one minute from the first request in it; wait, then retry with backoff.
Idempotency
Only replies (POST /v1/conversations/{id}/messages) accept an Idempotency-Key header. Use it so a network retry never sends the customer the same message twice. See Reply for the exact rules.
Caching
Every /v1 response carries Cache-Control: no-store. Do not cache responses in shared caches.
Errors
These are every error code the /v1 routes return.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_limit | limit is not a whole number from 1 to 100. |
| 400 | invalid_cursor | cursor is malformed. |
| 400 | invalid_status | status filter holds a value that is not an order status. |
| 400 | invalid_since | since is not an ISO date-time. |
| 400 | invalid_external_id | The external_id in the path is not 1 to 128 of A-Z a-z 0-9 . _ : -. |
| 400 | invalid_body | The product body is not a JSON object. |
| 400 | unknown_field | The product body has a field the API does not accept. |
| 400 | invalid_field | A product field breaks its rule, or name and price_kobo are missing on create. The message names the field. |
| 400 | invalid_text | Reply text is missing, blank, or longer than 4096 characters. |
| 400 | invalid_idempotency_key | Idempotency-Key is empty or longer than 255 characters. |
| 401 | invalid_api_key | Missing, malformed, unknown or revoked key. |
| 403 | insufficient_scope | The key lacks the scope this route needs. |
| 404 | not_found | No such resource in this shop. A resource from another shop is also not_found. |
| 409 | has_variants | The product has sizes or options with their own prices, or counts stock per size. Change that in the Lagbot app. |
| 409 | conflict | The product changed, or another request was writing it, at the same moment. Retry. |
| 409 | window_closed | The customer has not written in the last 24 hours, so WhatsApp will not deliver a reply. |
| 409 | idempotency_in_progress | A request with this Idempotency-Key is still running. |
| 409 | held | Someone else holds this chat. Reserved; the API acts as the shop owner, who can always take a chat. |
| 404 or 503 | send_refused | The reply was refused before sending: the chat was removed (404), or Lagbot could not open the chat or check the 24-hour window (503). Nothing was sent. |
| 422 | idempotency_key_reused | This Idempotency-Key was used for a different conversation or text. |
| 422 | recipient_refused | WhatsApp refused this recipient. |
| 502 | send_failed | WhatsApp did not accept the message. It was not sent. |
| 503 | unavailable | A temporary failure. Retry with backoff. On a reply, it can also mean WhatsApp did not confirm the send: the message may have gone. Check the conversation before sending again. |
A few answers come from Lagbot's shared server layer and use the shape {"success": false, "error": "..."} instead:
429when a rate limit is hit.404for a path that is not an API route.
If the API is switched off for the whole platform, every /v1 route answers 404 not_found.
Shop
The shop the key belongs to.
shop:read| Field | Type | Description |
|---|---|---|
id | uuid | The shop's id. |
name | string or null | The business name. |
whatsapp.connected | boolean | true when the shop's WhatsApp number is connected. |
whatsapp.number | string or null | The shop's WhatsApp number, or null if none. |
nova.on | boolean | true when Nova answers customers for this shop. |
curl https://api.lagbot.app/v1/shop \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": {
"id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35",
"name": "Ada Foods",
"whatsapp": { "connected": true, "number": "2348012345678" },
"nova": { "on": true }
}
}
Products
The shop's catalogue. Nova sells from it. You write products by your own id, the external_id, so you never need to store Lagbot's ids. Products the owner made in the Lagbot app have external_id: null, and the API cannot change them.
The product object
| Field | Type | Description |
|---|---|---|
id | uuid | Lagbot's id. |
external_id | string or null | Your id, when the product was written through the API. |
name | string | Product name. |
description | string or null | Description. |
price_kobo | integer or null | Price in kobo. |
currency | string | "NGN". |
category | string or null | Category. New API products default to "General". |
image_url | string or null | Image URL. |
in_stock | boolean | Whether Nova may sell it. |
stock_quantity | integer or null | Units in stock. null means stock is not counted. |
active | boolean | false when archived. Nova does not sell archived products. |
kind | string | "product" or "service". The API always creates "product". |
updated_at | string or null | Last change. |
List products
products:readNewest first, by creation time. Archived products are left out unless you ask for them.
| Query | Description |
|---|---|
limit | 1 to 100. Default 50. |
cursor | From the previous page's next_cursor. |
include_inactive | true to include archived products. Any other value is ignored. |
curl "https://api.lagbot.app/v1/products?limit=2" \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": [
{
"id": "8d3e2b1a-4c5f-4a6b-8e7d-9f0a1b2c3d4e",
"external_id": "sku-1042",
"name": "Jollof rice (large)",
"description": "Party jollof with chicken",
"price_kobo": 350000,
"currency": "NGN",
"category": "Rice",
"image_url": "https://cdn.example.com/jollof.jpg",
"in_stock": true,
"stock_quantity": 40,
"active": true,
"kind": "product",
"updated_at": "2026-11-24T08:01:12.204511+00:00"
},
{
"id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"external_id": null,
"name": "Small chops tray",
"description": null,
"price_kobo": 1500000,
"currency": "NGN",
"category": "General",
"image_url": null,
"in_stock": true,
"stock_quantity": null,
"active": true,
"kind": "product",
"updated_at": "2026-11-20T15:44:09.118207+00:00"
}
],
"next_cursor": "eyJhdCI6IjIwMjYtMTEtMjBUMTU6NDQ6MDkuMTE4MjA3KzAwOjAwIiwiaWQiOiIxYTJiM2M0ZC01ZTZmLTRhN2ItOGM5ZC0wZTFmMmEzYjRjNWQifQ"
}
Get a product
products:read{id} is Lagbot's uuid, not your external_id. Archived products are returned too. Unknown ids get 404 not_found.
curl https://api.lagbot.app/v1/products/8d3e2b1a-4c5f-4a6b-8e7d-9f0a1b2c3d4e \
-H "Authorization: Bearer $LAGBOT_KEY"
Answers {"data": <product>}.
Create or update by ref
products:writeCreates the product the first time you use an external_id, and updates it after that. Safe to repeat. Answers 201 with the product when it was created, 200 when it was updated (or already existed).
{external_id} is your id: 1 to 128 characters of A-Z a-z 0-9 . _ : -. It is unique within the shop. URL-encode : if your HTTP client needs it.
Body fields
Every field is optional on update. Send only what changed. Any field not listed here gets 400 unknown_field.
| Field | Rule |
|---|---|
name | String, 1 to 200 characters after trimming. Required on create. |
price_kobo | Integer from 0 to 100,000,000,000. Required on create. |
description | String of at most 2000 characters, or null. |
category | String, 1 to 80 characters after trimming. Cannot be null. Defaults to "General" on create. |
image_url | An https URL of at most 2048 characters, or null. |
in_stock | true or false. Defaults to true on create. |
stock_quantity | Whole number from 0 to 2,147,483,647, or null for "not counted". |
active | true or false. Defaults to true on create. Send true to bring back an archived product. |
Stock rules
- On create, if you send a number for
stock_quantity,in_stockis set tostock_quantity > 0, whateverin_stockyou sent. With no count,stock_quantityisnullandin_stockcomes from the body. - On update, a number for
stock_quantityalso setsin_stocktostock_quantity > 0, unless you sendin_stockin the same request, which then wins.
When an update is refused
409 has_variants: you changedprice_koboon a product that has sizes or options with their own prices, or you sentstock_quantityorin_stockfor a product that counts stock per size. Other fields still update. The owner changes prices and per-size stock in the Lagbot app.409 conflict: the product changed at the same moment. Retry.
If the owner deleted the product in the app, the next PUT for that external_id creates it again (201), so it needs name and price_kobo. The API cannot change kind, currency, sizes, options or extra images.
curl -X PUT https://api.lagbot.app/v1/products/by-ref/sku-1042 \
-H "Authorization: Bearer $LAGBOT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Jollof rice (large)",
"price_kobo": 350000,
"description": "Party jollof with chicken",
"category": "Rice",
"image_url": "https://cdn.example.com/jollof.jpg",
"stock_quantity": 40
}'
201 Created
{
"data": {
"id": "8d3e2b1a-4c5f-4a6b-8e7d-9f0a1b2c3d4e",
"external_id": "sku-1042",
"name": "Jollof rice (large)",
"description": "Party jollof with chicken",
"price_kobo": 350000,
"currency": "NGN",
"category": "Rice",
"image_url": "https://cdn.example.com/jollof.jpg",
"in_stock": true,
"stock_quantity": 40,
"active": true,
"kind": "product",
"updated_at": "2026-11-24T08:01:12.204511+00:00"
}
}
Update only the stock:
curl -X PUT https://api.lagbot.app/v1/products/by-ref/sku-1042 \
-H "Authorization: Bearer $LAGBOT_KEY" \
-H "Content-Type: application/json" \
-d '{ "stock_quantity": 0 }'
Answers 200 with the product, now "in_stock": false.
Archive by ref
products:writeSets active to false, so Nova stops selling it. Nothing is deleted, and past orders keep their lines. Answers 200 with the archived product. Repeating it is safe. An external_id you never wrote gets 404 not_found. To bring it back, PUT with {"active": true}.
curl -X DELETE https://api.lagbot.app/v1/products/by-ref/sku-1042 \
-H "Authorization: Bearer $LAGBOT_KEY"
Answers {"data": <product>} with "active": false.
Orders
Orders Nova takes in WhatsApp chats, plus orders from the shop's other sources. Orders are read-only in v1.
The order object
| Field | Type | Description |
|---|---|---|
id | uuid | Lagbot's id. |
code | string or null | Short order code the shop and customer see, for example K7F-2QX. A label, not a secret. |
status | string | One of the statuses below. |
refunded | boolean | true when money went back to the customer. |
refunded_at | string or null | When the refund was recorded. |
source | string | Where the order came from. "chat" for WhatsApp; other values are possible. |
created_at | string | When the order was created. |
paid_at | string or null | When payment was confirmed. |
customer.name | string or null | Customer name. |
customer.phone | string or null | Customer WhatsApp number, digits with country code. |
items[] | array | Order lines. Can be empty. |
items[].product_id | uuid or null | The product, when known. |
items[].name | string or null | Line name. |
items[].quantity | number | Quantity. Defaults to 1. |
items[].unit_price_kobo | integer or null | Unit price in kobo, when known. |
items[].size | string or null | Size or variant, when chosen. |
amounts.currency | string | "NGN". |
amounts.goods_kobo | integer or null | Goods total in kobo. |
amounts.delivery_kobo | integer or null | Delivery charged in kobo, or null. |
fulfilment.type | string or null | For example delivery, pickup, counter or appointment. |
fulfilment.status | string or null | The shop's fulfilment step, for example unfulfilled, ready_for_pickup, out_for_delivery, delivered, collected. Treat unknown values as "in progress". |
fulfilment.address | string or null | Delivery address. |
conversation_id | uuid or null | The WhatsApp conversation the order came from. |
Statuses
| Status | Meaning |
|---|---|
quoted | A price was given. The customer has not committed. |
pending | The customer agreed. Waiting for payment. |
paid | Payment confirmed. paid_at is set. |
rejected | The shop turned the order down. Reserved stock goes back. |
cancelled | The order was called off. |
expired | Not paid in time, so its stock was released. A late payment on its link can still turn it paid. |
Refunded is not a status. A refunded order stays paid (the goods may already have shipped) and gets "refunded": true and refunded_at. Always check refunded before you treat a paid order as money kept.
List orders
orders:readNewest first, by created_at.
| Query | Description |
|---|---|
status | Comma-separated statuses, for example paid,pending. Values: quoted, pending, paid, rejected, cancelled, expired. Anything else gets 400 invalid_status. |
since | ISO date-time. Only orders with created_at at or after it. Otherwise 400 invalid_since. |
limit | 1 to 100. Default 50. |
cursor | From the previous page's next_cursor. |
since filters by creation time, not by last change. To follow changes such as payments and refunds, use webhooks.
curl "https://api.lagbot.app/v1/orders?status=paid&since=2026-11-24T00:00:00Z&limit=1" \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": [
{
"id": "5b1f3c2e-8a4d-4e6b-9c1a-2f7d8e9a0b1c",
"code": "K7F-2QX",
"status": "paid",
"refunded": false,
"refunded_at": null,
"source": "chat",
"created_at": "2026-11-24T09:12:44.512345+00:00",
"paid_at": "2026-11-24T09:20:03.118902+00:00",
"customer": { "name": "Chidi Okeke", "phone": "2348031234567" },
"items": [
{
"product_id": "8d3e2b1a-4c5f-4a6b-8e7d-9f0a1b2c3d4e",
"name": "Jollof rice (large)",
"quantity": 2,
"unit_price_kobo": 350000,
"size": null
}
],
"amounts": { "currency": "NGN", "goods_kobo": 700000, "delivery_kobo": 150000 },
"fulfilment": { "type": "delivery", "status": "unfulfilled", "address": "12 Admiralty Way, Lekki, Lagos" },
"conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f"
}
],
"next_cursor": null
}
Get an order
orders:readBy the order code (1 to 32 of A-Z a-z 0-9 -), not the uuid. Unknown codes get 404 not_found.
curl https://api.lagbot.app/v1/orders/K7F-2QX \
-H "Authorization: Bearer $LAGBOT_KEY"
Answers {"data": <order>}.
Conversations and messages
One conversation per customer WhatsApp number. Nova handles it until a person takes it.
The conversation object
| Field | Type | Description |
|---|---|---|
id | uuid | Lagbot's id. |
customer.name | string or null | Customer name. |
customer.phone | string or null | Customer WhatsApp number. |
handled_by | string | "nova" when Nova answers, "human" when Nova is paused on this chat. |
handoff_reason | string or null | Why a person has it. "human_override" when someone took it in the app or through the API. Nova sets other reasons when it hands off. |
last_message_at | string or null | Time of the newest message. |
unread_count | integer | Messages the shop has not read. |
archived | boolean | true when the shop archived it. |
The message object
| Field | Type | Description |
|---|---|---|
id | uuid | Lagbot's id. |
direction | string | "inbound" from the customer, "outbound" to the customer. |
sender | string | Usually "customer", "nova" or "human". Treat any other value as a person at the shop. |
type | string | For example "text", "image", "audio". |
text | string | Message text. Empty string when there is none. |
created_at | string | When it was recorded. |
status | string or null | Delivery state of outbound messages, for example sent, delivered, read, failed. |
has_media | boolean | true when the message carries a stored picture, voice note or file. Media itself is not in v1. |
List conversations
conversations:readNewest activity first, by last_message_at. Conversations with no messages are left out. Archived ones are left out unless you ask.
| Query | Description |
|---|---|
archived | true to include archived conversations. |
limit | 1 to 100. Default 50. |
cursor | From the previous page's next_cursor. |
A new message moves a conversation to the top, so a long walk through pages can miss or repeat one that changed meanwhile.
curl "https://api.lagbot.app/v1/conversations?limit=1" \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": [
{
"id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
"customer": { "name": "Chidi Okeke", "phone": "2348031234567" },
"handled_by": "nova",
"handoff_reason": null,
"last_message_at": "2026-11-24T09:21:40.661204+00:00",
"unread_count": 0,
"archived": false
}
],
"next_cursor": "eyJhdCI6IjIwMjYtMTEtMjRUMDk6MjE6NDAuNjYxMjA0KzAwOjAwIiwiaWQiOiJjNGQ1ZTZmNy0xYTJiLTRjM2QtOGU5Zi0wYTFiMmMzZDRlNWYifQ"
}
Get a conversation
conversations:readThe conversation, plus reply_window: whether a reply can be delivered now.
| Field | Type | Description |
|---|---|---|
reply_window.open | boolean | true when the customer wrote in the last 24 hours, so a reply will be delivered. |
reply_window.last_inbound_at | string or null | Time of the customer's last message. |
curl https://api.lagbot.app/v1/conversations/c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": {
"id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
"customer": { "name": "Chidi Okeke", "phone": "2348031234567" },
"handled_by": "nova",
"handoff_reason": null,
"last_message_at": "2026-11-24T09:21:40.661204+00:00",
"unread_count": 0,
"archived": false,
"reply_window": { "open": true, "last_inbound_at": "2026-11-24T09:21:02.004118+00:00" }
}
}
List messages
conversations:readEvery message in the conversation, both directions, newest first. Takes limit and cursor.
curl "https://api.lagbot.app/v1/conversations/c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f/messages?limit=2" \
-H "Authorization: Bearer $LAGBOT_KEY"
{
"data": [
{
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"direction": "outbound",
"sender": "nova",
"type": "text",
"text": "Your order K7F-2QX is confirmed. Thank you!",
"created_at": "2026-11-24T09:21:40.661204+00:00",
"status": "delivered",
"has_media": false
},
{
"id": "a9b8c7d6-e5f4-4a3b-9c2d-1e0f9a8b7c6d",
"direction": "inbound",
"sender": "customer",
"type": "text",
"text": "I have paid",
"created_at": "2026-11-24T09:21:02.004118+00:00",
"status": null,
"has_media": false
}
],
"next_cursor": "eyJhdCI6IjIwMjYtMTEtMjRUMDk6MjE6MDIuMDA0MTE4KzAwOjAwIiwiaWQiOiJhOWI4YzdkNi1lNWY0LTRhM2ItOWMyZC0xZTBmOWE4YjdjNmQifQ"
}
Reply
conversations:writeSends a plain WhatsApp text to the customer, from the shop's number. It is recorded in the shop's inbox as sent by a person (sender: "human"), and an archived conversation is un-archived.
This is a real WhatsApp message. It is delivered only inside WhatsApp's 24-hour customer window: the customer must have written in the last 24 hours. Otherwise you get 409 window_closed and nothing is sent. Lagbot never sends paid template messages through the API. Check reply_window.open first.
Replying does not pause Nova. If you want a person to handle the chat, take it first.
| Body / header | Rule |
|---|---|
text | String, 1 to 4096 characters, not only spaces. Required. |
Idempotency-Key header | Optional, 1 to 255 characters. Strongly recommended. |
curl -X POST https://api.lagbot.app/v1/conversations/c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f/messages \
-H "Authorization: Bearer $LAGBOT_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: reply-7f3a9c" \
-d '{ "text": "Your rider is on the way. ETA 20 minutes." }'
201 Created
{
"data": {
"id": "0b9a8c7d-6e5f-4a3b-8c2d-1e0f9a8b7c6d",
"conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
"persisted": true
}
}
id is the new message's id. persisted is true when the message was also saved to the shop's inbox. false means WhatsApp accepted it, but Lagbot could not record it, so it may not appear in the message list.
Idempotency-Key rules
- Keys belong to the shop. Use a fresh random key for each new message and reuse it only to retry that message.
- The key is bound to the conversation id and the exact text. Reusing it with anything else gets
422 idempotency_key_reused. - While the first request is still running, a retry gets
409 idempotency_in_progress. Wait and retry. - After it finishes, a retry gets the stored answer again (same status and body) and sends nothing.
- If the first request was refused before sending (for example
window_closedorsend_failed), the key is freed, so a retry with it tries again. - If WhatsApp did not confirm the send (
503 unavailable), the message may have gone. The key keeps that answer, so retrying the same key returns the same503and never sends twice. Check the message list before sending again with a new key. - Keys are kept for at least 24 hours.
Without the header, a retry after a timeout can send the customer the same message twice.
Errors
400 invalid_text, 400 invalid_idempotency_key, 404 not_found, 409 window_closed, 409 idempotency_in_progress, 422 idempotency_key_reused, 422 recipient_refused, 502 send_failed, 503 unavailable, and send_refused (404 or 503). See Errors.
Take a chat
conversations:writeA person takes the chat over from Nova. No body. What happens:
- Nova stops answering this customer.
handled_bybecomes"human"andhandoff_reasonbecomes"human_override". - The API acts as the shop owner. If a teammate held the chat, the owner takes it back and the teammate is told.
- Nova stays paused on this chat until someone releases it, in the app or with release.
Taking a chat sends nothing to the customer. Reply with POST messages.
curl -X POST https://api.lagbot.app/v1/conversations/c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f/take \
-H "Authorization: Bearer $LAGBOT_KEY"
{ "data": { "conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f", "handled_by": "human" } }
Release a chat
conversations:writeHands the chat back to Nova. No body. What happens:
handled_bybecomes"nova",handoff_reasonis cleared, and any teammate hold ends (the teammate is told).- Nova then reads the chat and catches up. If the customer's last messages have no answer, Nova may reply to them straight away.
Safe to call on a chat Nova already handles.
curl -X POST https://api.lagbot.app/v1/conversations/c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f/release \
-H "Authorization: Bearer $LAGBOT_KEY"
{ "data": { "conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f", "handled_by": "nova" } }
Both answer 404 not_found for a conversation that is not in this shop.
Webhooks
Lagbot sends a signed POST to your URL when something changes in the shop.
Setup
The shop owner adds endpoints at web.lagbot.app → Developers, confirmed with their PIN. Each endpoint has:
- A URL. It must use
httpson port 443, use a public host name (not an IP address, notlocalhost, not a.internalname, not alagbot.appaddress), carry no username or password, and be at most 2048 characters. - A list of event types, or
*for all of them (the default). - A signing secret starting with
whsec_, shown once, when the endpoint is added.
A shop can have at most 5 endpoints. The page also lets the owner send a test ping, see the last 50 deliveries to an endpoint, delete an endpoint, and turn a disabled endpoint back on.
How changes are detected
Lagbot checks each shop for changes about every 2 minutes, so expect an event a couple of minutes after the change. Because it compares snapshots:
- If several changes happen between two checks, you get events for the net change. For example, an order that goes from
quotedtopendingtopaidwithin two minutes can arrive as oneorder.paidwithprevious.status: "quoted". - The first check after a shop's first endpoint is added records a baseline and sends nothing. Past orders are not replayed; read them with GET /v1/orders.
- Order changes are tracked for orders created in the last 14 days. Conversation changes are tracked for conversations with a message in the last 3 days.
message.receivedis tracked only while an enabled endpoint subscribes to it (or to*). Messages that arrived while none did are not sent later.
The delivered request
Headers:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | Lagbot-Webhooks/1 |
Lagbot-Event-Id | The event id, same as id in the body. |
Lagbot-Event-Type | The event type, same as type in the body. |
Lagbot-Signature | t=<unix seconds>,v1=<64 hex chars>. See Verify signatures. |
Body:
{
"id": "evt_3f9a1c0b7e2d4a6f8b5c1d0e9f8a7b6c",
"type": "order.paid",
"created_at": "2026-11-24T09:22:00.041Z",
"business_id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35",
"livemode": true,
"data": {
"order": {
"id": "5b1f3c2e-8a4d-4e6b-9c1a-2f7d8e9a0b1c",
"code": "K7F-2QX",
"status": "paid",
"refunded": false,
"refunded_at": null,
"source": "chat",
"created_at": "2026-11-24T09:12:44.512345+00:00",
"paid_at": "2026-11-24T09:20:03.118902+00:00",
"customer": { "name": "Chidi Okeke", "phone": "2348031234567" },
"items": [
{ "product_id": "8d3e2b1a-4c5f-4a6b-8e7d-9f0a1b2c3d4e", "name": "Jollof rice (large)", "quantity": 2, "unit_price_kobo": 350000, "size": null }
],
"amounts": { "currency": "NGN", "goods_kobo": 700000, "delivery_kobo": 150000 },
"fulfilment": { "type": "delivery", "status": "unfulfilled", "address": "12 Admiralty Way, Lekki, Lagos" },
"conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f"
},
"previous": { "status": "pending", "refunded": false, "fulfilment_status": "unfulfilled" }
}
}
| Field | Description |
|---|---|
id | Event id, evt_ plus 32 hex characters. Stable: a retry of the same event has the same id. |
type | Event type. |
created_at | When Lagbot detected the change (not the exact moment it happened). |
business_id | The shop's id, same as GET /v1/shop id. |
livemode | Always true in v1. |
data | Depends on the type. See Event types. |
Answering, retries and auto-disable
- Answer with any
2xxwithin 8 seconds. Do the real work after you answer. The response body is ignored. - Anything else is a failure: other statuses, timeouts, connection errors, and redirects (
3xxis not followed). - A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, then every 12 hours, up to 11 attempts in all (about 2 days and 21 hours). Lagbot checks for due retries every 2 minutes, so times are approximate.
- After the 11th failure the delivery is marked failed and the endpoint is disabled (reason
failing). The owner turns it back on from the Developers page. Deliveries that were already queued go out after it is back on, within about an hour. Events that happen while an endpoint is disabled are not queued for it. - Each attempt is signed again with a fresh timestamp.
- Delivery is at least once. The same event can arrive more than once. Store
idand skip ids you have seen. - Order is not guaranteed. Use the timestamps and the full object in
data, not arrival order. - Events are kept for 30 days.
Event types
| Type | Fires when | data |
|---|---|---|
order.created | A new order is seen. | { order, previous: null } |
order.updated | The status changed to quoted or pending. | { order, previous } |
order.paid | The status changed to paid, or a new order is seen already paid (then it follows order.created). | { order, previous } |
order.cancelled | The status changed to cancelled. | { order, previous } |
order.rejected | The status changed to rejected. | { order, previous } |
order.expired | The status changed to expired. | { order, previous } |
order.refunded | refunded turned true. | { order, previous } |
order.fulfilment_updated | fulfilment.status changed. | { order, previous } |
conversation.handoff | A chat moved from Nova to a person (handled_by became "human"). | { conversation } |
conversation.resumed | A chat went back to Nova (handled_by became "nova"). | { conversation } |
message.received | A customer sent a message. One event per message. | { conversation_id, message } |
whatsapp.connected | The shop's WhatsApp number became connected. | { connected: true } |
whatsapp.disconnected | The shop's WhatsApp number stopped being connected. | { connected: false } |
ping | Only when the owner presses Send test. Its id starts with evt_test_. You cannot subscribe to it; it always goes to the endpoint being tested. | {} |
Notes on order events:
orderis the full order object at the time of the check.previousis{ status, refunded, fulfilment_status }from the last check, ornullfor a new order.- One change can produce several events. A refund that also moves fulfilment sends both
order.refundedandorder.fulfilment_updated, with the samedata. - An
expiredorder that is paid late sendsorder.paid.
conversation is the conversation object (without reply_window). message is the message object.
{
"id": "evt_7b2c9e4d1a0f3b6c8d5e2f1a0b9c8d7e",
"type": "message.received",
"created_at": "2026-11-24T09:24:00.087Z",
"business_id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35",
"livemode": true,
"data": {
"conversation_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
"message": {
"id": "d3c2b1a0-9f8e-4d7c-8b6a-5f4e3d2c1b0a",
"direction": "inbound",
"sender": "customer",
"type": "text",
"text": "Please can I add one more?",
"created_at": "2026-11-24T09:23:11.902114+00:00",
"status": null,
"has_media": false
}
}
}
conversation.handoff
{
"id": "evt_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"type": "conversation.handoff",
"created_at": "2026-11-24T09:26:00.012Z",
"business_id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35",
"livemode": true,
"data": {
"conversation": {
"id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
"customer": { "name": "Chidi Okeke", "phone": "2348031234567" },
"handled_by": "human",
"handoff_reason": "human_override",
"last_message_at": "2026-11-24T09:23:11.902114+00:00",
"unread_count": 1,
"archived": false
}
}
}
whatsapp.disconnected
{
"id": "evt_5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b",
"type": "whatsapp.disconnected",
"created_at": "2026-11-24T10:02:00.230Z",
"business_id": "2f6c1e7a-5b3d-4c8e-9a10-6d2b7e4f1c35",
"livemode": true,
"data": { "connected": false }
}
Verify signatures
Check every request before you trust it. The Lagbot-Signature header looks like:
Lagbot-Signature: t=1795511520,v1=5f0c3b...64 hex characters...
- Read the raw request body, exactly as received, before any JSON parsing.
- Split the header into
t(unix seconds) andv1(hex). - Compute HMAC-SHA256 with your whole secret string as the key, including the
whsec_prefix, overt + "." + raw body. Hex-encode it. - Compare it to
v1with a constant-time comparison. - Reject the request if
tis more than 5 minutes from your clock.
Node.js
const crypto = require('crypto');
function verifyLagbotSignature(secret, rawBody, header, toleranceSec = 300) {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(String(header || ''));
if (!m) return false;
if (Math.abs(Math.floor(Date.now() / 1000) - Number(m[1])) > toleranceSec) return false;
const expected = crypto.createHmac('sha256', secret).update(m[1] + '.').update(rawBody).digest();
return crypto.timingSafeEqual(expected, Buffer.from(m[2], 'hex'));
}
With Express, take the raw body for this route only:
const express = require('express');
const app = express();
const seen = new Set(); // use your database in production
app.post('/lagbot/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
if (!verifyLagbotSignature(process.env.LAGBOT_WEBHOOK_SECRET, req.body, req.get('Lagbot-Signature'))) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body.toString('utf8'));
res.sendStatus(200);
if (seen.has(event.id)) return;
seen.add(event.id);
if (event.type === 'order.paid' && !event.data.order.refunded) {
console.log('Paid:', event.data.order.code, event.data.order.amounts.goods_kobo);
}
});
app.listen(3000);
Python
import hashlib
import hmac
import re
import time
def verify_lagbot_signature(secret: str, raw_body: bytes, header: str, tolerance_sec: int = 300) -> bool:
m = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", header or "")
if not m:
return False
if abs(int(time.time()) - int(m.group(1))) > tolerance_sec:
return False
signed = m.group(1).encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, m.group(2))
With Flask, pass request.get_data() as raw_body and request.headers.get("Lagbot-Signature") as header.
Limits and what is not in v1
Limits
| Limit | Value |
|---|---|
| Requests per shop | 300 per minute, all /v1 routes |
| Requests per IP address | 600 per minute |
| Page size | 1 to 100, default 50 |
| Active API keys per shop | 10 |
| Webhook endpoints per shop | 5 |
| Request body | Valid JSON with Content-Type: application/json. A body that is not valid JSON is read as empty, so the endpoint answers with its own validation error (for example invalid_body). |
| Reply text | 4096 characters |
Idempotency-Key | 255 characters, kept at least 24 hours |
external_id | 128 characters of A-Z a-z 0-9 . _ : - |
| Webhook response time | 8 seconds |
| Webhook attempts | 11, then the endpoint is disabled |
| Change checks | About every 2 minutes |
Not in v1
- No sandbox or test mode. Test against your own shop. Replies are real WhatsApp messages.
- No paid WhatsApp messages. Replies only inside the 24-hour customer window. No templates, no messages that start a conversation.
- No payment links. You cannot create or send a payment link through the API.
- No fulfilment updates. You can read
fulfilment.statusbut not move an order through its steps. - No delivery pricing or rider booking.
- No order writes. You cannot create, edit, cancel or refund orders.
- No media. Replies are text only, and message media cannot be downloaded (
has_mediatells you it exists). - No variant editing. Sizes, options, per-size prices and per-size stock are managed in the Lagbot app.
- No product deletion. Archive instead.
- No key or webhook management through the API. The owner does both on the Developers page.
- One shop per key. There is no OAuth or multi-shop app access.
Changelog
v1 — 24 November 2026
- First release: shop, products (list, get, create or update by ref, archive), orders (list, get by code), conversations (list, get with reply window, messages, reply, take, release).
- API keys with six scopes, created by the shop owner on the Developers page.
- Signed webhooks for 13 event types, with retries and auto-disable.