# Lagbot API v1 > Lagbot puts an AI salesperson, Nova, on a business's WhatsApp. This API lets other apps send products in, read the orders Nova closes, read and reply to chats, take a chat over from Nova and hand it back, and receive signed webhooks. Nigerian market. Human docs: https://developers.lagbot.app/ ## Basics - Base URL: https://api.lagbot.app/v1 - Auth: header `Authorization: Bearer lb_live_<43 chars of A-Z a-z 0-9 _ ->`. Exactly "Bearer", one space, the key. - Keys: created by the shop owner on web.lagbot.app -> Developers, PIN required, shown once. One key = one shop. Max 10 active keys per shop. A revoked key can work for up to 60 s more (cache). - Scopes (default: all six): shop:read, products:read, products:write, orders:read, conversations:read, conversations:write. - No sandbox or test mode. Test against your own shop. Replies are real WhatsApp messages. - Call from a server. Browsers are blocked by CORS. - Money: integer kobo (NGN; 100 kobo = 1 naira). Unknown amounts are null. - Times: ISO 8601 strings with offset, e.g. 2026-11-24T09:12:44.512345+00:00 or ...Z. Parse; do not string-compare. - Request bodies: JSON, Content-Type: application/json. A body that is not valid JSON is read as empty, so the endpoint returns its own validation error (e.g. invalid_body). - Success: {"data": ...}. Lists add "next_cursor": string|null. - Error: {"error": {"code": "...", "message": "..."}}. Branch on code. - Every /v1 response: Cache-Control: no-store. - Pagination: newest first. ?limit=1..100 (default 50, else 400 invalid_limit). ?cursor= (opaque; bad -> 400 invalid_cursor). next_cursor null = last page. - Rate limits: 300 req/min per shop (all /v1 routes, all keys); 600 req/min per IP. Over: HTTP 429 with body {"success":false,"error":"Too many requests. Please slow down."} (not the usual envelope), no Retry-After. Window is 1 minute from the first request. - Other non-envelope answers: unknown path -> 404 {"success":false,"error":"Route not found: ..."}. - If the API is switched off platform-wide, every /v1 route answers 404 not_found. ## Objects Shop: { id, name: string|null, whatsapp: { connected: bool, number: string|null }, nova: { on: bool } } Product: { id: uuid, external_id: string|null, name, description: string|null, price_kobo: int|null, currency: "NGN", category: string|null, image_url: string|null, in_stock: bool, stock_quantity: int|null (null = not counted), active: bool (false = archived), kind: "product"|"service", updated_at: string|null } Order: { id: uuid, code: string|null (e.g. "K7F-2QX"), status, refunded: bool, refunded_at: string|null, source: string ("chat" default), created_at, paid_at: string|null, customer: { name: string|null, phone: string|null }, items: [{ product_id: uuid|null, name: string|null, quantity: number, unit_price_kobo: int|null, size: string|null }], amounts: { currency: "NGN", goods_kobo: int|null, delivery_kobo: int|null }, fulfilment: { type: string|null (delivery, pickup, counter, appointment, ...), status: string|null (unfulfilled, ready_for_pickup, out_for_delivery, delivered, collected, ...), address: string|null }, conversation_id: uuid|null } Order status: quoted (price given, not committed) | pending (agreed, awaiting payment) | paid (payment confirmed) | rejected (shop turned it down, stock returned) | cancelled (called off) | expired (unpaid in time, stock released; a late payment can still make it paid). Refunded is NOT a status: a refunded order stays "paid" with refunded=true and refunded_at set. Conversation: { id: uuid, customer: { name, phone }, handled_by: "nova"|"human", handoff_reason: string|null ("human_override" when taken in app/API), last_message_at: string|null, unread_count: int, archived: bool } Message: { id: uuid, direction: "inbound"|"outbound", sender: "customer"|"nova"|"human"|other (treat other as shop staff), type: "text"|"image"|"audio"|..., text: string ("" if none), created_at, status: string|null (sent, delivered, read, failed), has_media: bool } ## Endpoints GET /v1/shop [shop:read] -> {data: Shop} GET /v1/products [products:read] query: limit, cursor, include_inactive=true (include archived) order: created_at desc -> {data: Product[], next_cursor} GET /v1/products/{id} [products:read] id = Lagbot uuid (not external_id). Archived included. 404 not_found if not in this shop. -> {data: Product} PUT /v1/products/by-ref/{external_id} [products:write] external_id: 1-128 of A-Z a-z 0-9 . _ : - (else 400 invalid_external_id). Unique per shop. Create if new (201), update if known (200). Idempotent. Body (JSON object, else 400 invalid_body; unknown keys -> 400 unknown_field; bad values -> 400 invalid_field): name: string 1-200 (trimmed) required on create price_kobo: int 0..100000000000 required on create description: string <=2000 | null category: string 1-80 (trimmed), not null; default "General" image_url: https URL <=2048 | null in_stock: bool; default true stock_quantity: int 0..2147483647 | null active: bool; default true (send true to un-archive) Stock: on create, a numeric stock_quantity forces in_stock = qty > 0. On update, a numeric stock_quantity sets in_stock = qty > 0 unless in_stock is also sent. 409 has_variants: price change on a product with sizes/options priced separately, or stock change on a product with per-size stock (change in Lagbot app). 409 conflict: concurrent change, retry. If the mapped product was deleted in the app, PUT recreates it (201; needs name + price_kobo). Only products written through the API (external_id set) can be changed. -> {data: Product} DELETE /v1/products/by-ref/{external_id} [products:write] Archives (active=false). Idempotent. 404 if this external_id was never written. -> {data: Product} GET /v1/orders [orders:read] query: status=comma list of quoted,pending,paid,rejected,cancelled,expired (else 400 invalid_status); since=ISO date-time, created_at >= since (else 400 invalid_since); limit; cursor order: created_at desc -> {data: Order[], next_cursor} GET /v1/orders/{code} [orders:read] code: 1-32 of A-Z a-z 0-9 -. 404 not_found otherwise. -> {data: Order} GET /v1/conversations [conversations:read] query: archived=true (include archived), limit, cursor Only conversations with at least one message. order: last_message_at desc. -> {data: Conversation[], next_cursor} GET /v1/conversations/{id} [conversations:read] -> {data: Conversation + reply_window: { open: bool, last_inbound_at: string|null }} open = customer wrote in the last 24 h. GET /v1/conversations/{id}/messages [conversations:read] query: limit, cursor. Both directions, newest first. -> {data: Message[], next_cursor} POST /v1/conversations/{id}/messages [conversations:write] Sends a real WhatsApp text from the shop's number, only inside the 24 h customer window. Never a paid template. Recorded as sender "human". Un-archives the chat. Does NOT pause Nova (use /take). body: { "text": string 1-4096, not blank } (else 400 invalid_text) header: Idempotency-Key: 1-255 chars, optional, recommended (else 400 invalid_idempotency_key) -> 201 {data: { id: uuid (new message), conversation_id, persisted: bool (false = sent but not saved to the inbox) }} Errors: 404 not_found; 409 window_closed; 422 recipient_refused; 502 send_failed (not sent); 503 unavailable (WhatsApp did not confirm: MAY have been sent; check messages before resending); send_refused 404|503 (refused before sending). Idempotency: key is per shop, bound to sha256(conversation id + "\n" + text). Different request with same key -> 422 idempotency_key_reused. Still running -> 409 idempotency_in_progress. Finished -> replays stored status+body, sends nothing. Refused before send -> key freed, retry sends. Unconfirmed send (503) -> key keeps the 503, same key never resends. Keys kept >= 24 h. POST /v1/conversations/{id}/take [conversations:write] No body. Nova stops answering this chat (handled_by "human", handoff_reason "human_override"). Acts as the shop owner: takes it back from a teammate (who is notified). Sends nothing to the customer. -> {data: { conversation_id, handled_by: "human" }} POST /v1/conversations/{id}/release [conversations:write] No body. Hands back to Nova (handled_by "nova", handoff_reason null, teammate hold ends). Nova then catches up and may answer unanswered customer messages. Safe if Nova already handles it. -> {data: { conversation_id, handled_by: "nova" }} take/release: 404 not_found for another shop's chat; 409 held is reserved (owner can always take). ## Error codes (/v1) 400 invalid_limit, invalid_cursor, invalid_status, invalid_since, invalid_external_id, invalid_body, unknown_field, invalid_field, invalid_text, invalid_idempotency_key 401 invalid_api_key 403 insufficient_scope 404 not_found 409 has_variants, conflict, window_closed, idempotency_in_progress, held 404|503 send_refused 422 idempotency_key_reused, recipient_refused 502 send_failed 503 unavailable ## Webhooks Setup: owner adds endpoints on web.lagbot.app -> Developers (PIN). Max 5 per shop. URL: https, port 443, public host name (no IP, no localhost, no .internal, no lagbot.app), no user:pass, <= 2048 chars. Events: list of types or ["*"] (default). Secret whsec_... shown once. "Send test" posts a ping. Detection: Lagbot polls each shop about every 2 minutes and diffs snapshots. Several changes between checks arrive as the net change (e.g. quoted->pending->paid may arrive as one order.paid with previous.status "quoted"). The first check after a shop's first endpoint records a baseline and sends nothing. Orders tracked if created in the last 14 days; conversations if a message in the last 3 days. message.received only tracked while an enabled endpoint subscribes to it or "*". Request: POST, headers Content-Type: application/json; User-Agent: Lagbot-Webhooks/1; Lagbot-Event-Id; Lagbot-Event-Type; Lagbot-Signature: t=,v1=<64 hex>. Body: { "id": "evt_<32 hex>", "type": "...", "created_at": "", "business_id": "", "livemode": true, "data": {...} } Events: order.created new order seen data { order, previous: null } order.updated status changed to quoted or pending data { order, previous } order.paid status changed to paid, or new order already paid (after order.created) data { order, previous } order.cancelled status -> cancelled data { order, previous } order.rejected status -> rejected data { order, previous } order.expired status -> expired data { order, previous } order.refunded refunded became true data { order, previous } order.fulfilment_updated fulfilment.status changed data { order, previous } conversation.handoff handled_by became "human" data { conversation } conversation.resumed handled_by became "nova" data { conversation } message.received one per inbound customer message data { conversation_id, message } whatsapp.connected shop number became connected data { connected: true } whatsapp.disconnected shop number stopped being connected data { connected: false } ping "Send test" only, id evt_test_..., not subscribable data {} previous = { status, refunded, fulfilment_status } from the last check, or null. One change can emit several events with the same data. Delivery: answer 2xx within 8 s (body ignored). Anything else fails, including 3xx (redirects not followed) and timeouts. Retries after 1m, 5m, 30m, 2h, 6h, 12h, 12h, 12h, 12h, 12h: 11 attempts total (~2 days 21 h), checked every 2 min. After the 11th failure the delivery is failed and the endpoint disabled (reason "failing"); owner re-enables it; already-queued deliveries resume within ~1 h; events while disabled are not queued for it. Each attempt re-signed with a fresh t. At-least-once: dedupe on id. No ordering guarantee. Events kept 30 days. Verify: HMAC-SHA256, key = the whole secret string INCLUDING "whsec_", message = t + "." + raw body bytes, hex. Constant-time compare with v1. Reject if |now - t| > 300 s. Use the raw body, before JSON parsing. 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')); } // Express: app.post('/hook', express.raw({ type: 'application/json' }), (req, res) => { verifyLagbotSignature(secret, req.body, req.get('Lagbot-Signature')) ... }) Python: import hashlib, hmac, re, 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)) ## Limits 300 req/min per shop; 600 req/min per IP; page size 1-100 (default 50); 10 active keys; 5 webhook endpoints; reply text 4096 chars; Idempotency-Key 255 chars, kept >= 24 h; external_id 128 chars; webhook timeout 8 s; 11 webhook attempts; change checks ~every 2 min. ## Not in v1 No sandbox. No paid WhatsApp messages/templates (replies only inside the 24 h window). No payment links. No fulfilment step updates. No delivery pricing or rider booking. No order create/edit/cancel/refund. No media upload or download. No variant/size/option editing. No product deletion (archive). No key or webhook management via API. One shop per key, no OAuth. ## Changelog v1 - 24 Nov 2026: first release.