Lagbot API

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.

Send products in

Keep the shop's catalogue in step with your POS or inventory system, keyed by your own product ids.

Read orders

Read the orders Nova closes, with items, amounts in kobo, payment state and fulfilment details.

Read and reply to chats

Read WhatsApp conversations and send replies inside WhatsApp's 24-hour window.

Take over from Nova

Pause Nova on one chat while a person handles it, then hand it back.

Get webhooks

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

  1. 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.

  2. 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 }
      }
    }
  3. Read the latest paid orders

    curl "https://api.lagbot.app/v1/orders?status=paid&limit=10" \
      -H "Authorization: Bearer $LAGBOT_KEY"
  4. 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 signed ping event, 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

Scopes

A key has all six scopes unless it was created with a narrower list.

ScopeAllows
shop:readGET /v1/shop
products:readGET /v1/products, GET /v1/products/{id}
products:writePUT and DELETE /v1/products/by-ref/{external_id}
orders:readGET /v1/orders, GET /v1/orders/{code}
conversations:readGET /v1/conversations, GET /v1/conversations/{id}, GET /v1/conversations/{id}/messages
conversations:writePOST /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.

One object
{ "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:

ParameterRules
limitWhole number from 1 to 100. Default 50. Otherwise 400 invalid_limit.
cursorThe 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

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.

StatusCodeMeaning
400invalid_limitlimit is not a whole number from 1 to 100.
400invalid_cursorcursor is malformed.
400invalid_statusstatus filter holds a value that is not an order status.
400invalid_sincesince is not an ISO date-time.
400invalid_external_idThe external_id in the path is not 1 to 128 of A-Z a-z 0-9 . _ : -.
400invalid_bodyThe product body is not a JSON object.
400unknown_fieldThe product body has a field the API does not accept.
400invalid_fieldA product field breaks its rule, or name and price_kobo are missing on create. The message names the field.
400invalid_textReply text is missing, blank, or longer than 4096 characters.
400invalid_idempotency_keyIdempotency-Key is empty or longer than 255 characters.
401invalid_api_keyMissing, malformed, unknown or revoked key.
403insufficient_scopeThe key lacks the scope this route needs.
404not_foundNo such resource in this shop. A resource from another shop is also not_found.
409has_variantsThe product has sizes or options with their own prices, or counts stock per size. Change that in the Lagbot app.
409conflictThe product changed, or another request was writing it, at the same moment. Retry.
409window_closedThe customer has not written in the last 24 hours, so WhatsApp will not deliver a reply.
409idempotency_in_progressA request with this Idempotency-Key is still running.
409heldSomeone else holds this chat. Reserved; the API acts as the shop owner, who can always take a chat.
404 or 503send_refusedThe 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.
422idempotency_key_reusedThis Idempotency-Key was used for a different conversation or text.
422recipient_refusedWhatsApp refused this recipient.
502send_failedWhatsApp did not accept the message. It was not sent.
503unavailableA 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:

If the API is switched off for the whole platform, every /v1 route answers 404 not_found.

Shop

The shop the key belongs to.

GET/v1/shopscope shop:read
FieldTypeDescription
iduuidThe shop's id.
namestring or nullThe business name.
whatsapp.connectedbooleantrue when the shop's WhatsApp number is connected.
whatsapp.numberstring or nullThe shop's WhatsApp number, or null if none.
nova.onbooleantrue 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

FieldTypeDescription
iduuidLagbot's id.
external_idstring or nullYour id, when the product was written through the API.
namestringProduct name.
descriptionstring or nullDescription.
price_kobointeger or nullPrice in kobo.
currencystring"NGN".
categorystring or nullCategory. New API products default to "General".
image_urlstring or nullImage URL.
in_stockbooleanWhether Nova may sell it.
stock_quantityinteger or nullUnits in stock. null means stock is not counted.
activebooleanfalse when archived. Nova does not sell archived products.
kindstring"product" or "service". The API always creates "product".
updated_atstring or nullLast change.

List products

GET/v1/productsscope products:read

Newest first, by creation time. Archived products are left out unless you ask for them.

QueryDescription
limit1 to 100. Default 50.
cursorFrom the previous page's next_cursor.
include_inactivetrue 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

GET/v1/products/{id}scope 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

PUT/v1/products/by-ref/{external_id}scope products:write

Creates 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.

FieldRule
nameString, 1 to 200 characters after trimming. Required on create.
price_koboInteger from 0 to 100,000,000,000. Required on create.
descriptionString of at most 2000 characters, or null.
categoryString, 1 to 80 characters after trimming. Cannot be null. Defaults to "General" on create.
image_urlAn https URL of at most 2048 characters, or null.
in_stocktrue or false. Defaults to true on create.
stock_quantityWhole number from 0 to 2,147,483,647, or null for "not counted".
activetrue or false. Defaults to true on create. Send true to bring back an archived product.

Stock rules

When an update is refused

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

DELETE/v1/products/by-ref/{external_id}scope products:write

Sets 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

FieldTypeDescription
iduuidLagbot's id.
codestring or nullShort order code the shop and customer see, for example K7F-2QX. A label, not a secret.
statusstringOne of the statuses below.
refundedbooleantrue when money went back to the customer.
refunded_atstring or nullWhen the refund was recorded.
sourcestringWhere the order came from. "chat" for WhatsApp; other values are possible.
created_atstringWhen the order was created.
paid_atstring or nullWhen payment was confirmed.
customer.namestring or nullCustomer name.
customer.phonestring or nullCustomer WhatsApp number, digits with country code.
items[]arrayOrder lines. Can be empty.
items[].product_iduuid or nullThe product, when known.
items[].namestring or nullLine name.
items[].quantitynumberQuantity. Defaults to 1.
items[].unit_price_kobointeger or nullUnit price in kobo, when known.
items[].sizestring or nullSize or variant, when chosen.
amounts.currencystring"NGN".
amounts.goods_kobointeger or nullGoods total in kobo.
amounts.delivery_kobointeger or nullDelivery charged in kobo, or null.
fulfilment.typestring or nullFor example delivery, pickup, counter or appointment.
fulfilment.statusstring or nullThe shop's fulfilment step, for example unfulfilled, ready_for_pickup, out_for_delivery, delivered, collected. Treat unknown values as "in progress".
fulfilment.addressstring or nullDelivery address.
conversation_iduuid or nullThe WhatsApp conversation the order came from.

Statuses

StatusMeaning
quotedA price was given. The customer has not committed.
pendingThe customer agreed. Waiting for payment.
paidPayment confirmed. paid_at is set.
rejectedThe shop turned the order down. Reserved stock goes back.
cancelledThe order was called off.
expiredNot 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

GET/v1/ordersscope orders:read

Newest first, by created_at.

QueryDescription
statusComma-separated statuses, for example paid,pending. Values: quoted, pending, paid, rejected, cancelled, expired. Anything else gets 400 invalid_status.
sinceISO date-time. Only orders with created_at at or after it. Otherwise 400 invalid_since.
limit1 to 100. Default 50.
cursorFrom 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

GET/v1/orders/{code}scope orders:read

By 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

FieldTypeDescription
iduuidLagbot's id.
customer.namestring or nullCustomer name.
customer.phonestring or nullCustomer WhatsApp number.
handled_bystring"nova" when Nova answers, "human" when Nova is paused on this chat.
handoff_reasonstring or nullWhy 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_atstring or nullTime of the newest message.
unread_countintegerMessages the shop has not read.
archivedbooleantrue when the shop archived it.

The message object

FieldTypeDescription
iduuidLagbot's id.
directionstring"inbound" from the customer, "outbound" to the customer.
senderstringUsually "customer", "nova" or "human". Treat any other value as a person at the shop.
typestringFor example "text", "image", "audio".
textstringMessage text. Empty string when there is none.
created_atstringWhen it was recorded.
statusstring or nullDelivery state of outbound messages, for example sent, delivered, read, failed.
has_mediabooleantrue when the message carries a stored picture, voice note or file. Media itself is not in v1.

List conversations

GET/v1/conversationsscope conversations:read

Newest activity first, by last_message_at. Conversations with no messages are left out. Archived ones are left out unless you ask.

QueryDescription
archivedtrue to include archived conversations.
limit1 to 100. Default 50.
cursorFrom 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

GET/v1/conversations/{id}scope conversations:read

The conversation, plus reply_window: whether a reply can be delivered now.

FieldTypeDescription
reply_window.openbooleantrue when the customer wrote in the last 24 hours, so a reply will be delivered.
reply_window.last_inbound_atstring or nullTime 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

GET/v1/conversations/{id}/messagesscope conversations:read

Every 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

POST/v1/conversations/{id}/messagesscope conversations:write

Sends 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 / headerRule
textString, 1 to 4096 characters, not only spaces. Required.
Idempotency-Key headerOptional, 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

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

POST/v1/conversations/{id}/takescope conversations:write

A person takes the chat over from Nova. No body. What happens:

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

POST/v1/conversations/{id}/releasescope conversations:write

Hands the chat back to Nova. No body. What happens:

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 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:

The delivered request

Headers:

HeaderValue
Content-Typeapplication/json
User-AgentLagbot-Webhooks/1
Lagbot-Event-IdThe event id, same as id in the body.
Lagbot-Event-TypeThe event type, same as type in the body.
Lagbot-Signaturet=<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" }
  }
}
FieldDescription
idEvent id, evt_ plus 32 hex characters. Stable: a retry of the same event has the same id.
typeEvent type.
created_atWhen Lagbot detected the change (not the exact moment it happened).
business_idThe shop's id, same as GET /v1/shop id.
livemodeAlways true in v1.
dataDepends on the type. See Event types.

Answering, retries and auto-disable

Event types

TypeFires whendata
order.createdA new order is seen.{ order, previous: null }
order.updatedThe status changed to quoted or pending.{ order, previous }
order.paidThe status changed to paid, or a new order is seen already paid (then it follows order.created).{ order, previous }
order.cancelledThe status changed to cancelled.{ order, previous }
order.rejectedThe status changed to rejected.{ order, previous }
order.expiredThe status changed to expired.{ order, previous }
order.refundedrefunded turned true.{ order, previous }
order.fulfilment_updatedfulfilment.status changed.{ order, previous }
conversation.handoffA chat moved from Nova to a person (handled_by became "human").{ conversation }
conversation.resumedA chat went back to Nova (handled_by became "nova").{ conversation }
message.receivedA customer sent a message. One event per message.{ conversation_id, message }
whatsapp.connectedThe shop's WhatsApp number became connected.{ connected: true }
whatsapp.disconnectedThe shop's WhatsApp number stopped being connected.{ connected: false }
pingOnly 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:

conversation is the conversation object (without reply_window). message is the message object.

message.received
{
  "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...
  1. Read the raw request body, exactly as received, before any JSON parsing.
  2. Split the header into t (unix seconds) and v1 (hex).
  3. Compute HMAC-SHA256 with your whole secret string as the key, including the whsec_ prefix, over t + "." + raw body. Hex-encode it.
  4. Compare it to v1 with a constant-time comparison.
  5. Reject the request if t is 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

LimitValue
Requests per shop300 per minute, all /v1 routes
Requests per IP address600 per minute
Page size1 to 100, default 50
Active API keys per shop10
Webhook endpoints per shop5
Request bodyValid 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 text4096 characters
Idempotency-Key255 characters, kept at least 24 hours
external_id128 characters of A-Z a-z 0-9 . _ : -
Webhook response time8 seconds
Webhook attempts11, then the endpoint is disabled
Change checksAbout every 2 minutes

Not in v1

Changelog

v1 — 24 November 2026