Skip to content
DocumentationAPI and integrations

Developers

API and integrations

How to integrate your system with Ledio.ai: report new sign-ups and conversions, send messages and verification codes on WhatsApp, and receive events back by webhook.

Last updated: August 14, 2026Basehttps://api.ledio.ai

What you can do

Ledio integrates with your system in both directions. You tell Ledio when something happens on your side (someone signed up, someone bought) and Ledio tells you when something happens in the conversation (a new contact showed up, a contact became a customer).

All endpoints start from https://api.ledio.ai and accept and return JSON.

Authentication

Every call needs two headers. Both are generated in the dashboard, under Settings → API and webhooks.

FieldTypeDescription
x-api-keyrequiredstringIdentifies your business in Ledio. It's visible in the dashboard and can be copied from there.
x-webhook-secretrequiredstringThe integration secret, starts with whsec_. It's shown only once, when you generate it. Ledio stores only a hash, so there's no way to recover it later: if you lose it, generate a new one.
Note

These headers authorize any request on behalf of your business. Keep them on the server. Never put them in frontend code, a mobile app or a public repository: anyone who has both can send messages from your WhatsApp.

If either is missing or wrong, the response is 401 with a message saying which one failed.

Standard response

Endpoints respond 200 with the same shape. Always check the success field: a 200 with success: false means we authenticated you, but the action didn't happen (number not on WhatsApp, contact not found, channel disconnected).

response
{
  "success": true,
  "message": "Welcome message sent",
  "contactId": "1f5c2a10-2b3c-4d5e-6f70-8a9b0c1d2e3f"
}
FieldTypeDescription
successbooleanWhether the action was completed.
messagestringDetails of what happened, or the reason when success is false.
contactIdstringThe contact's id in Ledio, when the action involved one. Store it to match records with your system.

1. New sign-up

POST/webhook/external/new-user

Tells Ledio that someone signed up in your system. Ledio creates the contact, checks whether the number exists on WhatsApp and, if it does, the AI agent starts the conversation in the chosen flow.

FieldTypeDescription
phonerequiredstringPhone number with country code, digits only: 5511999999999. No spaces, parentheses or dashes.
namestringThe person's name. The agent uses it to personalize the conversation.
externalIdstringTheir id in your system. Lets you match both sides later.
flowCONVERSIONSUPPORTONBOARDINGBILLINGFEEDBACKCUSTOMHow the agent should approach them. Defaults to CONVERSION (sales focus).
contextobjectFree-form data the agent will know during the conversation: source, campaign, intended plan.
curl
curl -X POST https://api.ledio.ai/webhook/external/new-user \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-webhook-secret: whsec_YOUR_SECRET" \
  -d '{
    "phone": "5511999999999",
    "name": "John Smith",
    "externalId": "usr_abc123",
    "flow": "CONVERSION",
    "context": { "source": "landing_page", "campaign": "black_friday" }
  }'

2. User converted

POST/webhook/external/user-converted

Tells Ledio that the person subscribed or bought. The agent stops selling and starts treating them as a customer. Send this as soon as the payment is confirmed: without it, the agent keeps offering what they already bought.

FieldTypeDescription
phonerequiredstringThe same phone number used at sign-up.
namestringUpdates the contact's name, if it already exists.
externalIdstringThe person's id in your system.
contextobjectWhat they bought, so the agent has context: { "plan": "pro", "value": 2990, "currency": "BRL" }.
curl
curl -X POST https://api.ledio.ai/webhook/external/user-converted \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-webhook-secret: whsec_YOUR_SECRET" \
  -d '{
    "phone": "5511999999999",
    "context": { "plan": "pro", "value": 2990, "currency": "BRL" }
  }'

3. Change the service flow

POST/webhook/external/change-flow

Changes how the agent behaves with an existing contact. Useful when the person opens a support request in your system and you want the WhatsApp conversation to follow along.

FieldTypeDescription
phonerequiredstringThe contact's phone number.
flowrequiredCONVERSIONSUPPORTONBOARDINGBILLINGFEEDBACKCUSTOMThe new flow.
contextobjectReason for the change: { "reason": "user_requested_support", "ticket_id": "TK-123" }.
curl
curl -X POST https://api.ledio.ai/webhook/external/change-flow \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-webhook-secret: whsec_YOUR_SECRET" \
  -d '{ "phone": "5511999999999", "flow": "SUPPORT" }'

4. Send a message

POST/webhook/external/send-message

Sends a text over WhatsApp to a contact who has already talked to you.

Note

This endpoint doesn't create contacts and doesn't send to anyone who has never talked to you. That's a deliberate safeguard: messaging cold numbers is the fastest way to get your business's WhatsApp banned. To start a conversation from scratch, use the new sign-up endpoint.

FieldTypeDescription
phonerequiredstringPhone number of an existing contact.
messagestringThe text to send.
contextstringInformation for the agent to take into account from now on. E.g.: "Lead came from Instagram, interested in a 2024 SUV".
curl
curl -X POST https://api.ledio.ai/webhook/external/send-message \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-webhook-secret: whsec_YOUR_SECRET" \
  -d '{
    "phone": "5511999999999",
    "message": "Hi! How can I help?"
  }'

5. Verification code (OTP)

POST/webhook/external/otp

Sends a verification code over WhatsApp using an authentication template approved by Meta.

Note

Requires your business to be on Meta's Cloud API and to have an approved authentication template. If you connect by QR code, this endpoint doesn't work. Talk to support before integrating.

FieldTypeDescription
phonerequiredstringDestination phone number.
coderequiredstringThe code you generated. Ledio only delivers it; it doesn't generate or validate it.
expiresInMinutesrequirednumberHow many minutes the code is valid, shown in the message.
namestringRecipient's name.
externalIdstringThe person's id in your system.
brandstringBrand name shown in the message.
curl
curl -X POST https://api.ledio.ai/webhook/external/otp \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-webhook-secret: whsec_YOUR_SECRET" \
  -d '{
    "phone": "5511999999999",
    "code": "123456",
    "expiresInMinutes": 5
  }'

Receive events from Ledio

The other direction. Register a URL under Settings → API and webhooks and Ledio sends a POST to it when something happens in the conversation.

EventTypeDescription
contact.createdeventA new contact started a conversation.
contact.convertedeventA contact was marked as a customer, by the agent, from the dashboard or through the conversion endpoint.
contact.updatedeventThe agent reclassified the contact's interest (engagement) or found out their name.

All events arrive in the same envelope:

body we send
{
  "id": "5f1c2a10-2b3c-4d5e-6f70-8a9b0c1d2e3f",
  "type": "contact.converted",
  "createdAt": "2026-08-14T18:22:05.412Z",
  "data": {
    "businessSlug": "your-business",
    "contactId": "1f5c2a10-2b3c-4d5e-6f70-8a9b0c1d2e3f",
    "phone": "5511999999999",
    "name": "John Smith",
    "status": "CONVERTED",
    "flow": "ONBOARDING",
    "engagement": "HOT"
  }
}

Use the id to discard duplicates: if delivery fails, Ledio retries, so the same event may arrive twice. Make your handler idempotent.

Verifying the signature

Every request is signed in the x-ledio-signature header, in the format sha256=<hex>. It's an HMAC-SHA256 of the body exactly as received, using the secret you registered.

Note

Compute the HMAC over the raw body, before any parsing. If you serialize the JSON again to verify it, the signature won't match: that's the most common mistake at this step.

Node.js
import crypto from 'node:crypto'

// rawBody = the body as a string, unparsed
function signatureMatches(rawBody, header, secret) {
  const expected =
    'sha256=' +
    crypto.createHmac('sha256', secret).update(rawBody).digest('hex')

  const a = Buffer.from(expected)
  const b = Buffer.from(header ?? '')
  // Constant-time comparison avoids leaking the signature through timing
  return a.length === b.length && crypto.timingSafeEqual(a, b)
}

Respond with 2xx quickly. If your endpoint takes too long or returns an error, Ledio treats it as a failure and retries later.

Errors

CodeTypeDescription
401authenticationMissing header, unknown API key or wrong secret. The message says which.
400validationInvalid body: a required field is missing or flow has a value outside the list.
200 with success: falsebusiness ruleAuthenticated, but the action didn't happen. The reason comes in message: number not on WhatsApp, contact not found, channel disconnected.

Integration tips

Store the contactId returned by the first call. It's the key for matching the Ledio conversation with the record in your system, and it saves you from relying on the phone number, which can change.

Always send the phone number in the same format, with country code and digits only. Ledio normalizes it, but sticking to one format on your side makes it easier to check when something doesn't match.

Treat success: false as an expected response, not an exception. A number that isn't on WhatsApp is common and shouldn't break your processing queue.

Need help?

If something here doesn't match what you're seeing in practice, reach out through support in the dashboard. Docs that don't match the behavior are a bug, and we want to know.

Still have questions?

Kim, Ledio's AI, answers questions about the platform right away. If you prefer, write to the team.