Serlion

Developers

API reference

  • REST API v1
  • Webhooks
  • Custom actions
  • Pro, Scale and Custom plans
Base URLhttps://api.serlion.com/api/v1
Contents
01

Introduction

The Serlion API lets your server talk to your chatbot. On the Pro, Scale and Custom plans it also reads your conversations, leads and analytics, and manages the knowledge base. Webhooks notify your server when things happen. Talking to the chatbot works on every plan. Automation tools such as Zapier, Make and n8n can use the same API and webhooks: see Zapier, Make, n8n.

Base URL: https://api.serlion.com/api/v1

Requests and responses are JSON. Timestamps are ISO 8601 strings in UTC. Conversations from the widget preview in your dashboard never appear in the API.

02

Authentication

  • Create a key in . A server key’s full secret is shown once, when you create it, so store it somewhere safe.
  • Send it on every request as Authorization: Bearer serlion_sk_…
  • Keys are chat only (POST /chat, on every plan), read (also every GET route) or read & write (also adds, changes and deletes knowledge base entries). Read and read & write need the Pro, Scale or Custom plan.
  • Keys are of two sorts. A server key (serlion_sk_…) is for your own code, and it is the only sort this API accepts. A website key (sk_live_…) goes in your web page and works on the website chat only. Keys that start with pk_live_ no longer exist.
  • Keep server keys on your server. The API sends no CORS headers, so browsers block requests made from a web page. That keeps server keys out of website code.
  • A key can have an expiry date, a monthly conversation limit of its own and, for website keys, a list of allowed domains. Deleting a key means typing its name to confirm, and it stops working on the next request.
Shell
curl https://api.serlion.com/api/v1/me \
  -H "Authorization: Bearer serlion_sk_..."

With a read or read & write key, GET /me is a good first call: it confirms the key works and tells you which account it belongs to. A chat-only key can only use POST /chat.

03

Errors and limits

Errors come back as { "error": "message", "code": "CODE" }. The message is written for people; use the code in your logic. Three failures have no code: a body that is not valid JSON, a body over 256 KB, and an unexpected failure on our side. For those, use the status and the message.

Response · 403
{
  "error": "This API key is read-only. Create a key with read & write access for this.",
  "code": "INSUFFICIENT_SCOPE"
}
CodeStatusMeaning
UNAUTHORIZED401The key is missing, not valid, or deleted.
KEY_EXPIRED401The key has passed its expiry date.
INSUFFICIENT_SCOPE403The key’s access is too low for the route: a chat-only key on a read or write route, or a read key on a route that changes data.
ORIGIN_NOT_ALLOWED403Your account locks its keys to verified domains and the request carried an Origin header from another site. Calls from your server without an Origin header are not affected.
CONSENT_REQUIRED403POST /chat on a chatbot that asks for consent first, without privacyConsent: true.
PLAN_FEATURE_UNAVAILABLE403The account is not on a plan that includes this part of the API.
KB_LIMIT_REACHED403The knowledge base is full for this plan. The response also has maxEntries.
WEBHOOK_LIMIT_REACHED403The account already has 20 hooks made through POST /hooks. Delete one to add another.
NOT_FOUND404No such conversation, entry, hook, event or route.
CONVERSATION_NOT_FOUND404The conversationId sent to POST /chat or POST /leads does not exist.
BAD_REQUEST400A parameter or body field is missing or invalid. The message says which.
No code400, 413, 500The body is not valid JSON (400), the body is larger than 256 KB (413), or something failed on our side (500). Only the message is sent.
RATE_LIMITED429Too many requests, or more than 100 leads an hour through POST /leads. Wait and try again.
CONVERSATION_MESSAGE_LIMIT429A conversation holds at most 100 messages from the visitor. Waiting does not help: start a new conversation by leaving out conversationId.
KEY_LIMIT_REACHED429The key has used its own monthly conversation limit (set in the key’s settings).
CONVERSATION_LIMIT_REACHED429The account has used all its credits for this month.
AI_NOT_CONNECTED, AI_KEY_REJECTED, AI_OUT_OF_CREDIT, AI_UNAVAILABLE503POST /chat only. The AI could not answer: no AI key is connected, the provider rejected it, the provider account is out of credit, or the AI did not answer just now (try again in a minute). The response also has the conversationId.
ATTACHMENT_UNAVAILABLE503A file was asked for while the file storage could not be reached. Try again later.

Rate limit: 60 requests per minute per key, and 120 per minute across all keys of one account. POST /chat also allows 20 messages per minute in one conversation, and 40 AI replies per hour in one conversation. A 429 with RATE_LIMITED includes Retry-After: 60 seconds, 3600 when the limit is the hourly one on POST /leads, or the time until the next reply slot for the hourly limit of one conversation.

04

Pagination

  • Lists return { "data": [...], "nextCursor": "..." }, newest first.
  • For the next page, pass ?cursor=<nextCursor> with the same filters. nextCursor: null means there are no more.
  • limit is 1 to 100, default 25.
  • Single objects come back as { "data": { ... } }.
Shell
# First page
curl "https://api.serlion.com/api/v1/leads?limit=50" \
  -H "Authorization: Bearer serlion_sk_..."

# Next page: pass nextCursor back as cursor
curl "https://api.serlion.com/api/v1/leads?limit=50&cursor=WyIyMDI2LTA5LTI0..." \
  -H "Authorization: Bearer serlion_sk_..."
05

Endpoints

All paths are relative to https://api.serlion.com/api/v1. Every endpoint needs a server key. POST /chat works with a chat-only key, on every plan. Every other endpoint needs a server key with read or read & write access, and the Pro, Scale or Custom plan.

POST/chatworks with any server key, on every plan

Sends a message to your chatbot and returns its reply. It goes through the same pipeline as the website widget: your knowledge base, hand-off rules and limits apply, and the conversation shows up in your Conversations tab and counts toward your plan. A server key talks to your default chatbot.

Body fieldDescription
message (required)The visitor’s message, up to 2,000 characters.
conversationIdLeave it out to start a conversation. Send the conversationId from the first reply to continue it. Only ids made by this endpoint are accepted.
visitor{ name?, email?, phone? }. Saves the person as a lead on the conversation when it has an email or a phone number. Only the first visitor object of a conversation is used; later ones are ignored.
identity{ userId, signature }, signed on your server as described in Verified visitors.
languageA language code such as "de", if you know it.
privacyConsentSend true once the person has agreed to your privacy notice. Needed only when your chatbot is set to ask for consent first; without it you get CONSENT_REQUIRED and nothing is stored.

aiGenerated (boolean) is true when the reply was written by the AI. A standby reply is false. Keep this mark when you show the reply. Replies written by AI are marked as such; the Terms don’t allow removing or hiding the mark.

reply is null and handedOff is true while a person on your team has taken over: the chatbot stays quiet and your team answers in the dashboard. Unlike the widget, a chatbot whose AI is not working gives an honest 503 here, so your code can react.

Shell
curl https://api.serlion.com/api/v1/chat \
  -H "Authorization: Bearer serlion_sk_..." \
  -H "Content-Type: application/json" \
  -d '{ "message": "What are your opening hours?" }'
Response · 200
{
  "reply": "We’re open Monday to Friday, 9:00 to 17:30.",
  "aiGenerated": true,
  "conversationId": "api_k3Jx9Qm2vT8wLr5Ys1HnZc7dB0eAfUg4",
  "messageId": "48213",
  "handedOff": false
}
Shell · continue the conversation
curl https://api.serlion.com/api/v1/chat \
  -H "Authorization: Bearer serlion_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "message": "And on Sundays?",
    "conversationId": "api_k3Jx9Qm2vT8wLr5Ys1HnZc7dB0eAfUg4"
  }'
Node
// Node 18+. Keep the key on your server.
const res = await fetch('https://api.serlion.com/api/v1/chat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SERLION_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ message: 'What are your opening hours?' }),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code ?? res.status}: ${body.error}`);
console.log(body.reply, body.conversationId);
Python
import os
import requests

res = requests.post(
    "https://api.serlion.com/api/v1/chat",
    headers={"Authorization": f"Bearer {os.environ['SERLION_KEY']}"},
    json={"message": "What are your opening hours?"},
    timeout=60,
)
body = res.json()
if not res.ok:
    raise RuntimeError(f"{body.get('code', res.status_code)}: {body['error']}")
print(body["reply"], body["conversationId"])
Response · 503
{
  "error": "No AI key is connected. Connect one under Provider Key, and this key will work.",
  "code": "AI_NOT_CONNECTED",
  "conversationId": "api_k3Jx9Qm2vT8wLr5Ys1HnZc7dB0eAfUg4"
}

GET/me

Your account and the key in use.

Response · 200
{
  "data": {
    "businessId": "biz_4f1c9a2e7b3d5c8e1a6f0b2d",
    "companyName": "Cedarworks",
    "plan": "Pro",
    "conversationRetentionDays": 180,
    "key": { "id": "apikey_9c2e41d07f3a8b15e6d2", "name": "CRM sync", "scope": "read" }
  }
}

GET/conversations

Your conversations, newest first.

QueryDescription
limit1 to 100, default 25.
cursorThe nextCursor from the previous page.
sinceISO 8601. Only conversations that started at or after this time.
untilISO 8601. Only conversations that started before this time.
handoffStatusnone, requested (a visitor asked for a person) or active (someone on your team is replying).

channel is web, telegram, whatsapp, email, line or discord. visitor is null until the visitor has given a name, email or phone number. rating is null until they rate the conversation.

Conversations from Telegram, WhatsApp, email, LINE and Discord have channel set. For WhatsApp, the visitor’s phone is the WhatsApp number. For email, the visitor’s email is the sender’s address.

Response · 200
{
  "data": [
    {
      "id": "sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13",
      "startedAt": "2026-09-24T14:02:11.482Z",
      "lastActivityAt": "2026-09-24T14:09:37.105Z",
      "messageCount": 8,
      "handoffStatus": "none",
      "channel": "web",
      "visitor": { "name": "Ana Souza", "email": "ana@example.com", "phone": null },
      "rating": { "stars": 5, "comment": "Quick and clear.", "ratedAt": "2026-09-24T14:10:02.318Z" }
    }
  ],
  "nextCursor": "WyIyMDI2LTA5LTI0IDE0OjAyOjExLjQ4MjUxMyswMCIsInNlc3NfN2QyYjFmNjQtM2M4ZS00YTk1LWIwZDEtMmU2ZjlhNGM4YjEzIl0"
}

GET/conversations/{id}

One conversation with the same fields as the list, plus every message in order. role is visitor, bot, agent (a person on your team) or system. aiGenerated is true on a message the AI wrote and false on every other message, standby replies included. Keep this mark when you show the messages. attachment is { url, type, name } or null; type is image or file (a PDF).

Response · 200
{
  "data": {
    "id": "sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13",
    "startedAt": "2026-09-24T14:02:11.482Z",
    "lastActivityAt": "2026-09-24T14:09:37.105Z",
    "messageCount": 8,
    "handoffStatus": "none",
    "channel": "web",
    "visitor": { "name": "Ana Souza", "email": "ana@example.com", "phone": null },
    "rating": null,
    "messages": [
      {
        "id": 48213,
        "role": "visitor",
        "content": "Do you ship to Portugal?",
        "aiGenerated": false,
        "createdAt": "2026-09-24T14:02:11.482Z",
        "attachment": null
      },
      {
        "id": 48214,
        "role": "bot",
        "content": "Yes. Orders to Portugal arrive in 3 to 5 working days.",
        "aiGenerated": true,
        "createdAt": "2026-09-24T14:02:13.907Z",
        "attachment": null
      },
      {
        "id": 48215,
        "role": "visitor",
        "content": "Here is my order confirmation.",
        "aiGenerated": false,
        "createdAt": "2026-09-24T14:03:02.771Z",
        "attachment": {
          "url": "https://api.serlion.com/api/v1/conversations/sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13/messages/48215/attachment",
          "type": "file",
          "name": "order-confirmation.pdf"
        }
      }
    ]
  }
}

attachment.url is a download address, not a public one. Send the same API key in the Authorization header and it returns the file itself (its own Content-Type, not a web page or JSON). For a message with no file, or a file that has been deleted, it answers 404 with ATTACHMENT_NOT_FOUND. If many files are being read at once it answers 503 with ATTACHMENT_BUSY and Retry-After: wait that long and ask again. If the file storage cannot be reached just now it answers 503 with ATTACHMENT_UNAVAILABLE: try again later.

Download a file
curl "https://api.serlion.com/api/v1/conversations/sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13/messages/48215/attachment" \
  -H "Authorization: Bearer serlion_sk_..." \
  --output order-confirmation.pdf

GET/leads

Leads, newest first. Query: limit, cursor, since, until (filtering on when the lead was captured).

source is chat (given in the conversation), prechat (the widget’s pre-chat form), identify (passed in by your website) or api (made with POST /leads). marketingConsent is true only when the person agreed to marketing emails: they ticked the box in the chat, or your call to POST /leads said they had.

Response · 200
{
  "data": [
    {
      "id": "lead_1758722977105_3fa9c2d1",
      "conversationId": "sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13",
      "name": "Ana Souza",
      "email": "ana@example.com",
      "phone": null,
      "messageExcerpt": "Can someone send me a quote for 40 units?",
      "source": "chat",
      "marketingConsent": false,
      "createdAt": "2026-09-24T14:09:37.105Z"
    }
  ],
  "nextCursor": null
}

GET/analytics

The last 30 days, the same numbers as Home in your dashboard. The volume arrays have one entry per day. satisfactionPercent and handoffRatePercent are null when there is no data yet.

Response · 200
{
  "data": {
    "periodDays": 30,
    "conversationVolume": [
      { "date": "2026-08-26", "count": 14 },
      { "date": "2026-08-27", "count": 9 }
    ],
    "totalConversations": 412,
    "leadsVolume": [
      { "date": "2026-08-26", "count": 2 },
      { "date": "2026-08-27", "count": 1 }
    ],
    "totalLeads": 37,
    "feedback": { "up": 88, "down": 6, "satisfactionPercent": 94 },
    "handoff": { "handoffCount": 21, "totalConversations": 412, "handoffRatePercent": 5 }
  }
}

Knowledge base

An entry is { id, title, sourceType, sourceUrl, content, createdAt, updatedAt }. sourceType is text, file (uploaded in the dashboard) or url (imported from a web page). Titles can be up to 100 characters and content up to 8,000.

GET/knowledge-base

Every entry, in the order they were added, plus maxEntries for your plan. Not paginated.

Response · 200
{
  "data": [
    {
      "id": "kb_entry_0c7e2a9f41b3d8e6a5f1c2b4",
      "title": "Shipping and delivery",
      "sourceType": "text",
      "sourceUrl": null,
      "content": "We ship to every EU country. Orders arrive in 3 to 5 working days...",
      "createdAt": "2026-09-01T09:15:42.000Z",
      "updatedAt": "2026-09-18T16:03:10.000Z"
    }
  ],
  "maxEntries": 25
}

GET/knowledge-base/{id}

One entry, as { "data": { ... } }.

POST/knowledge-baserequires a read & write key

Body { "title", "content" } for text, or { "title", "sourceUrl" } to import a web page (send one or the other, not both). Serlion fetches the page and keeps the entry linked to it. Returns 201 with the new entry.

Shell
curl -X POST https://api.serlion.com/api/v1/knowledge-base \
  -H "Authorization: Bearer serlion_sk_..." \
  -H "Content-Type: application/json" \
  -d '{ "title": "Returns", "content": "You can return any item within 30 days." }'
Body · import a page
{ "title": "Pricing page", "sourceUrl": "https://example.com/pricing" }

PATCH/knowledge-base/{id}requires a read & write key

Body { "title"?, "content"?, "refreshFromUrl"?: true }. Fields you leave out stay the same. refreshFromUrl fetches the page again and only works for entries imported from a URL. Returns the updated entry.

Body · re-fetch the page
{ "refreshFromUrl": true }

DELETE/knowledge-base/{id}requires a read & write key

Deletes the entry. Returns 204 with no body.

06

Webhooks

Setup. Add an endpoint (an HTTPS URL) in and choose the events it should get. You can have up to 5 endpoints. Apps like Zapier can add more through the API: see Zapier, Make, n8n. Serlion shows the endpoint’s signing secret (whsec_…) when you add it, and you can reveal it again there later.

Events

TypeSent whendata
conversation.startedA visitor sent the first message of a new conversation.{ sessionId, channel, startedAt, firstMessage, visitor | null }
lead.createdA visitor left an email address or phone number.{ id, sessionId, name, email, phone, messageExcerpt, source, marketingConsent, createdAt }
handoff.requestedA visitor asked to talk to a person.{ sessionId, requestedAt, withinBusinessHours }
handoff.escalatedA handoff request has had no reply for 5 minutes.{ sessionId, minutesWithoutReply, escalatedAt }
handoff.resolvedSomeone on your team marked a handoff as resolved.{ sessionId, resolvedAt, resolvedBy: { type: 'owner' | 'team_member', name } }
conversation.ratedA visitor rated a conversation.{ sessionId, rating (1–5), comment, ratedAt }
conversation.deletedA conversation was deleted, by the visitor or by your team. Delete any copy you keep.{ sessionId, deletedAt, deletedBy: 'visitor' | 'business' }
webhook.testSent by Send test event in the dashboard.{ message }

visitor in conversation.started is { name, email, phone }, or null if the visitor hasn’t given any of them yet. channel is web, telegram, whatsapp, email, line or discord.

source in lead.created is chat, prechat, identify or api. marketingConsent is true only when the person agreed to marketing emails.

When you receive conversation.deleted, delete everything you stored for that sessionId: the conversation was erased, by the visitor or by your team (deletedBy is business when the owner or a team member deleted it in the dashboard).

Payload

Every request is a POST with a JSON body in the same envelope. data depends on type.

Request body
{
  "eventId": "evt_5b0e2c7a9d41f3e86c2a1b7d",
  "type": "lead.created",
  "timestamp": "2026-09-25T12:00:00.000Z",
  "businessId": "biz_4f1c9a2e7b3d5c8e1a6f0b2d",
  "data": {
    "id": "lead_1758801600000_9e2c4b1a",
    "sessionId": "sess_7d2b1f64-3c8e-4a95-b0d1-2e6f9a4c8b13",
    "name": "Ana Souza",
    "email": "ana@example.com",
    "phone": null,
    "messageExcerpt": "Can someone send me a quote for 40 units?",
    "source": "chat",
    "marketingConsent": false,
    "createdAt": "2026-09-25T12:00:00.000Z"
  }
}

Delivery and retries

  • Respond with any 2xx status within 10 seconds. Anything else counts as a failure. Deliveries to one endpoint are sent one at a time, so a slow answer only delays your own events.
  • A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours (7 attempts in total).
  • Redirects are not followed. Use the final URL.
  • An endpoint whose deliveries have failed for 3 days is turned off, and you get an email. Fix it, then turn it back on in the dashboard.
  • Events can arrive more than once and out of order. Use the webhook-id header to ignore duplicates: it stays the same on every retry of a delivery, and also when you resend the delivery from the dashboard. Mark an id as done only after you have processed the event successfully, not when it first arrives, or a resend will look like a duplicate. Use timestamp in the body to put events in order.
  • The dashboard keeps a delivery log for 30 days, where you can see each attempt and resend a delivery.

Verifying signatures

Serlion follows the Standard Webhooks spec. Each request has three headers:

HeaderValue
webhook-idThe delivery ID. Same on every retry.
webhook-timestampWhen this attempt was signed, in Unix seconds.
webhook-signaturev1,<base64>. Space-separated when there is more than one (for 24 hours after a secret rotation).

The signature is HMAC-SHA256 over {webhook-id}.{webhook-timestamp}.{raw body}. The key is the base64-decoded part of your secret after whsec_. Always verify against the raw body exactly as received: parsing and re-serializing the JSON changes it.

The easiest route is an official Standard Webhooks library.

Node · standardwebhooks
import { Webhook } from 'standardwebhooks';

const wh = new Webhook(process.env.SERLION_WEBHOOK_SECRET); // "whsec_…"

// Use the RAW request body, not re-serialized JSON:
const event = wh.verify(rawBody, {
  'webhook-id': req.headers['webhook-id'],
  'webhook-timestamp': req.headers['webhook-timestamp'],
  'webhook-signature': req.headers['webhook-signature'],
});
// verify() throws if the signature or timestamp is wrong.
Python · standardwebhooks
# pip install standardwebhooks
import os
from flask import Flask, request
from standardwebhooks.webhooks import Webhook, WebhookVerificationError

app = Flask(__name__)
wh = Webhook(os.environ["SERLION_WEBHOOK_SECRET"])  # "whsec_…"

@app.post("/webhooks/serlion")
def serlion_webhook():
    try:
        # The raw body, not request.json re-serialized.
        event = wh.verify(request.get_data(), {
            "webhook-id": request.headers.get("webhook-id", ""),
            "webhook-timestamp": request.headers.get("webhook-timestamp", ""),
            "webhook-signature": request.headers.get("webhook-signature", ""),
        })
    except WebhookVerificationError:
        return "", 400

    # ... handle event["type"] / event["data"] ...
    return "", 204

Without a library, in Node:

Node · manual
import crypto from 'node:crypto';

const TOLERANCE_SECONDS = 5 * 60;

export function verifySerlionWebhook(rawBody, headers, secret) {
  const id = headers['webhook-id'];
  const timestamp = headers['webhook-timestamp'];
  const signatureHeader = headers['webhook-signature'];
  if (!id || !timestamp || !signatureHeader) throw new Error('Missing webhook headers');

  // Reject old (or far-future) timestamps, so a captured request can't be replayed later.
  const ts = Number(timestamp);
  if (!Number.isInteger(ts) || Math.abs(Date.now() / 1000 - ts) > TOLERANCE_SECONDS) {
    throw new Error('Timestamp outside the 5-minute window');
  }

  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = crypto
    .createHmac('sha256', key)
    .update(`${id}.${timestamp}.${rawBody}`)
    .digest();

  // Several signatures during a secret rotation: accept if any one matches.
  const valid = signatureHeader.split(' ').some((entry) => {
    const [version, signature] = entry.split(',');
    if (version !== 'v1' || !signature) return false;
    const received = Buffer.from(signature, 'base64');
    return received.length === expected.length && crypto.timingSafeEqual(received, expected);
  });
  if (!valid) throw new Error('Invalid signature');

  return JSON.parse(rawBody);
}

// Express: keep the body raw for this route.
// app.post('/webhooks/serlion', express.raw({ type: 'application/json' }), (req, res) => {
//   const event = verifySerlionWebhook(req.body, req.headers, process.env.SERLION_WEBHOOK_SECRET);
//   res.sendStatus(204);
// });

Rotating a secret

Rotate an endpoint’s secret in . For the next 24 hours every request carries two signatures, one from the old secret and one from the new, so your receiver keeps working while you switch it over. After that, only the new secret signs.

07

Zapier, Make, n8n

Automation tools can use the API and webhooks described above: subscribe a URL to events, read a sample to map the fields, create leads. Serlion has no official apps for Zapier, Make or n8n. This is the generic route, through their webhook and HTTP steps.

Setup

  • Create a server key with read & write access in . Subscribing, unsubscribing and creating leads need it. Listing hooks and samples works with a read key.
  • To start a trigger (for example "when a lead is created"), take the https address your tool gives you for catching events and send it to POST /hooks with the events you want. Keep the id and the secret from the answer.
  • To map fields, get a sample with GET /samples/lead.created. It has the same envelope and fields as a real delivery.
  • When the automation is switched off, send DELETE /hooks/{id}. This is the "unsubscribe" call Zapier needs for a Zap that is turned off.
  • To act (for example "create a lead from a form"), use POST /leads.

In Zapier, Webhooks by Zapier or a custom app can make these calls. In Make and n8n, an HTTP module (or n8n’s Webhook node as the receiver) works the same way, and the sample is what you map fields from. Deliveries are signed like those of a dashboard endpoint: if your tool lets you check the signature, see Verifying signatures. Headers, retries and what turns a hook off are the same as in Delivery and retries.

All routes here take Authorization: Bearer serlion_sk_…, need the Pro, Scale or Custom plan, and answer errors in the shape described under Errors and limits.

POST/hooksrequires a read & write key

Subscribes a URL to events. Body:

Body fieldDescription
url (required)An https address. The same rules as dashboard endpoints apply, and redirects are not followed.
events (required)An array of event types from the Events table. webhook.test is only for the dashboard’s test button.
descriptionOptional text to recognise the hook by.

Returns 201 with the hook and its signing secret. The secret is shown once: store it now. A hook that keeps failing is turned off like any endpoint (enabled is false and disabledReason says why); delete it and subscribe again.

A hook belongs to the key that made it. When that key is rotated, deleted or reaches its end date, the hook is turned off too (disabledReason is key) and stays off. Hooks made with other keys keep working. Subscribe again with a working key.

Shell
curl -X POST https://api.serlion.com/api/v1/hooks \
  -H "Authorization: Bearer serlion_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hooks.example.com/catch/123456/abcdef/",
    "events": ["lead.created"],
    "description": "New leads to my spreadsheet"
  }'
Response · 201
{
  "data": {
    "id": "whep_7c1e5a9d2b4f8e305a6b1c9d",
    "url": "https://hooks.example.com/catch/123456/abcdef/",
    "events": ["lead.created"],
    "description": "New leads to my spreadsheet",
    "enabled": true,
    "disabledReason": null,
    "createdAt": "2026-10-06T09:30:00.000Z"
  },
  "secret": "whsec_MfKQ9r8GtzHk3v0q7x2..."
}
Response · 403
{
  "error": "You can have up to 20 hooks made through the API. Delete one to add another.",
  "code": "WEBHOOK_LIMIT_REACHED"
}

GET/hooks

The hooks made through the API, as { "data": [ { id, url, events, description, enabled, disabledReason, createdAt } ] }. The endpoints you add in the dashboard are not listed here. The account owner sees these hooks in the dashboard under Developers, with the key that made each one, and can switch one off there.

DELETE/hooks/{id}requires a read & write key

Unsubscribes. Returns 204 with no body. It only works on hooks made through the API: the id of a dashboard endpoint answers 404 with NOT_FOUND, so an automation can’t remove your own endpoints.

GET/samples

Every event with its description and an example: { "data": [ { type, description, sample } ] }. GET /samples/{event} returns one example as { "data": <sample> }, and 404 with NOT_FOUND for an unknown event.

A sample has the same envelope and fields as a real delivery. The person in it is made up (Alex Example, alex@example.com), so it is safe to keep in a trigger.

GET /samples/lead.created · 200
{
  "data": {
    "eventId": "evt_sample000000000000000000",
    "type": "lead.created",
    "timestamp": "2026-10-06T09:30:00.000Z",
    "businessId": "biz_4f1c9a2e7b3d5c8e1a6f0b2d",
    "data": {
      "id": "lead_1760000000000_ab12cd34",
      "sessionId": "sess_sample1234567890",
      "name": "Alex Example",
      "email": "alex@example.com",
      "phone": "+1 555 010 4477",
      "messageExcerpt": "Can someone call me about the Pro plan?",
      "source": "chat",
      "marketingConsent": true,
      "createdAt": "2026-10-06T09:30:00.000Z"
    }
  }
}

POST/leadsrequires a read & write key

Creates a lead from an automation: a form, a spreadsheet, another tool. It is announced like a lead from the chat: your email and Slack alerts, the lead webhook, the lead.created event, HubSpot and Pipedrive, and, with consent, a connected newsletter service.

Body fieldDescription
emailUp to 200 characters. Send email or phone; at least one is required.
phoneUp to 40 characters.
nameUp to 200 characters.
messageUp to 1,000 characters are accepted, but only the first 200 are kept: it is shown as a short preview of the lead’s message.
conversationIdAttach the lead to an existing conversation.
marketingConsenttrue or false. It is your statement that the person agreed to marketing emails. Only then does a connected newsletter service (Mailchimp or Brevo) receive them. Leave it out when you are not sure.

Returns 201 with the lead (source is api). The same person sent again within 60 seconds, for example by a retry, returns 200 with duplicate: true, and nothing is sent twice. Errors: 400 BAD_REQUEST (the message says which field), 404 CONVERSATION_NOT_FOUND, and 429 RATE_LIMITED after 100 leads an hour, with a Retry-After header.

Shell
curl -X POST https://api.serlion.com/api/v1/leads \
  -H "Authorization: Bearer serlion_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "email": "sam@example.com",
    "name": "Sam Sample",
    "message": "Asked for a demo on the pricing page form",
    "marketingConsent": true
  }'
Response · 201
{
  "data": {
    "id": "lead_1760002200000_5d9e7f21",
    "conversationId": null,
    "name": "Sam Sample",
    "email": "sam@example.com",
    "phone": null,
    "messageExcerpt": "Asked for a demo on the pricing page form",
    "source": "api",
    "marketingConsent": true,
    "createdAt": "2026-10-06T09:30:00.000Z"
  }
}
Response · 200 · same person within 60 seconds
{
  "data": { "id": "lead_1760002200000_5d9e7f21", "source": "api", "...": "..." },
  "duplicate": true
}

Avoid loops

Leads made with POST /leads also send the lead.created event, with source set to api. An automation that creates leads and is triggered by lead.created must filter on source not equal to api. Without that filter, every lead it creates starts it again.

Limits

LimitValue
Hooks made through the API20 per account. They don’t count toward the 5 dashboard endpoints.
Leads made through the API100 an hour per account.
Requests60 a minute per key, and 120 a minute across all keys of one account.
Hook addresseshttps only. Redirects are not followed.
08

Custom actions

A custom action lets your chatbot call your own API during a conversation and answer with live data. When a visitor asks "Where is my order 1042?", the bot calls GET https://api.shop.com/orders/1042 and answers "It shipped yesterday with DHL." Actions are read-only: every request is a GET.

Requests

  • Actions are set up in , on the Pro, Scale and Custom plans.
  • Serlion calls your URL with GET. Placeholders like {orderId} are filled with URL-encoded values the AI collected from the conversation.
  • Optional query parameters without a value are left out.
  • The AI never chooses the address, headers or credentials, only the values of the parameters you define.
  • Requests come from Serlion’s servers, over HTTPS only, with an 8-second timeout. Redirects aren’t followed.
HeaderValue
acceptapplication/json
user-agentSerlion-Actions/1.0 (+https://serlion.com)
Your auth headerAs configured on the action.
serlion-request-idUnique per request.
serlion-timestampWhen the request was signed, in Unix seconds.
serlion-signaturev1,<base64>

Verifying requests

Each action has its own signing secret (whsec_…). It’s shown when you add the action, and you can see it again or replace it from the action in the dashboard.

  • The signature is HMAC-SHA256 over {serlion-request-id}.{serlion-timestamp}.{METHOD}.{path and query}.
  • The key is the base64-decoded part of the action’s signing secret after whsec_.
  • "Path and query" is exactly the request target your server received, for example /orders/A%201?email=ana%40x.com. In Express that’s req.originalUrl, in PHP $_SERVER['REQUEST_URI'].
  • Reject timestamps more than 5 minutes old, and a serlion-request-id you have already seen in that time.
  • For 24 hours after you replace the secret, serlion-signature carries two signatures separated by a space: one made with the new secret and one with the old. Accept the request if either matches.
Node · Express
import crypto from 'node:crypto';

function verifySerlion(req, secret) {
  const id = req.get('serlion-request-id');
  const ts = req.get('serlion-timestamp');
  const header = req.get('serlion-signature') || '';
  if (!id || !ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = crypto.createHmac('sha256', key)
    .update(`${id}.${ts}.${req.method}.${req.originalUrl}`)
    .digest();
  return header.split(' ').some((entry) => {
    const [version, signature] = entry.split(',');
    if (version !== 'v1' || !signature) return false;
    const received = Buffer.from(signature, 'base64');
    return received.length === expected.length && crypto.timingSafeEqual(received, expected);
  });
}

Responses

  • Answer with JSON and any 2xx status.
  • A 404 tells the bot that nothing was found, which it passes on to the visitor.
  • Any other status, a redirect, a body that isn’t JSON, or a body over 256 KB counts as a failure. The bot then says it couldn’t check right now and offers to connect the visitor with your team.
  • Only the response fields you listed on the action reach the AI. Use dotted paths for nested values (tracking.url) and [] for every item in a list (items[].name; the first 20 items). With no fields listed, the whole response is passed.
  • The result is capped at 4,000 characters, and card numbers are masked.
  • The AI treats results as information, never as instructions. Still, don’t return text you wouldn’t want a visitor to read.

Limits

LimitValue
Actions per account10
Parameters per action8
Lookups per conversation10
Lookups per account60 a minute
Call logKept 30 days, without parameter values or response content.
09

Verified visitors

If your website has logged-in customers, your server can sign their user id so actions can safely look up their data with {visitor.userId} in the action’s URL. The signature is made on your server with the identity secret from . Never put the secret in your web page.

  • The signature is the hex HMAC-SHA256 of the user id, keyed with the identity secret as text.
  • Pass both to the widget with Serlion.identify({ userId, signature }). On logout, call Serlion.identify(null).
  • An invalid or missing signature, or a userId that is empty or longer than 200 characters, is ignored silently: the visitor is simply not verified, and actions using {visitor.userId} aren’t offered to the AI.
  • Rotating the identity secret takes effect at once. Visitors signed with the old one are treated as not signed in until your server uses the new one.
Your server (Node)
import crypto from 'node:crypto';
const signature = crypto.createHmac('sha256', process.env.SERLION_IDENTITY_SECRET)
  .update(String(user.id))
  .digest('hex');
Your server (PHP)
$signature = hash_hmac('sha256', (string) $user->id, getenv('SERLION_IDENTITY_SECRET'));
Your server (Python)
import hmac, hashlib, os
signature = hmac.new(os.environ["SERLION_IDENTITY_SECRET"].encode(), str(user.id).encode(), hashlib.sha256).hexdigest()
Your web page
<script>
  window.Serlion = window.Serlion || [];
  // Print each value as a JSON string with your template engine (a "json" or "tojson" filter), not inside quotes you type yourself.
  Serlion.push(['identify', { userId: {{ user.id | json }}, signature: {{ signature | json }}, name: {{ user.name | json }} }]);
</script>