Skip to Content
Sendable Docs

Webhooks

Receive real-time message, session, and WhatsApp account events from Sendable.

How Webhooks Work

  1. You configure a webhook URL in your session settings.
  2. Sendable sends HTTP POST requests to your URL when subscribed events occur.
  3. Your application verifies the signature, processes the event, and returns HTTP 200 quickly.

Setting Up Webhooks

1. Create an Endpoint

Your endpoint must:

  • Accept POST requests
  • Preserve the raw request body for signature verification
  • Return HTTP 200 quickly, ideally in under 5 seconds
  • Handle duplicate events because delivery is at-least-once

Example in Express:

import express from 'express'
import { Sendable } from '@sendable-dev/sdk'

const sendable = new Sendable({
  apiKey: process.env.SENDABLE_API_KEY!,
  apiKeyScope: 'session',
  webhookSecret: process.env.SENDABLE_WEBHOOK_SECRET,
})

app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
  const payload = req.body.toString()

  let event
  try {
    event = await sendable.webhooks.verifyAndParse(payload, req.headers)
  } catch {
    return res.status(401).send('Invalid signature')
  }

  processEvent(event).catch(console.error)
  res.sendStatus(200)
})

2. Configure in Dashboard or via the API

  1. Go to your session
  2. Navigate to Webhooks
  3. Click Add Webhook
  4. Enter your URL
  5. Select event types
  6. Save

Or create it with a session API key (GET /webhooks/event-types lists every type):

const webhook = await sendable.webhooks.create({
  https_url: 'https://your-app.com/webhook',
  event_types: ['message.received', 'message.delivered', 'group.join-request'],
})
// webhook.webhook_secret -> SENDABLE_WEBHOOK_SECRET

sendable.webhooks also has list, get, update, delete, rotateSecret, listLogs, and retryDelivery.

3. Keep the Secret Safe

Each webhook endpoint has a signing secret in the form whsec_.... Store it securely and pass it into the SDK as webhookSecret.

Event Types

Message Events

EventDescription
message.sentWhatsApp accepted a message sent through the API
message.deliveredFirst SENT/DELIVERED status for an outbound message
message.readRecipient read the message
message.failedA send through the API failed for good before WhatsApp accepted it (once per send, after the last retry)
message.receivedIncoming direct message received
message-personal.receivedIncoming personal-chat message received
message-group.receivedIncoming group or community message received

Session Events

EventDescription
session.socket-connectedWhatsApp socket connected successfully
session.socket-disconnectedWhatsApp socket disconnected

Normalized Events

These carry the same data as GET /v1/events, so anything a webhook missed can be replayed from the feed.

AreaEvents
Messagesmessage.deleted, message.edited, message.reaction
Statusstatus.received (only when the session opted in to storing received statuses), status.posted
Chatschat.upsert, chat.updated, chat.deleted, chat.locked
Groups and communitiesgroup.upserted, group.updated, group.participants.updated, group.join-request, group.member-tag.updated
Contactscontact.upserted, contact.updated
Business labelslabel.edited, label.association.updated
Callscall.updated
Channelsnewsletter.reaction, newsletter.view, newsletter.participants.updated, newsletter.settings.updated
Accountsettings.updated, message-capping.updated, blocklist.set, blocklist.updated
History synchistory.synced, history.status

See Webhook Events for payload examples.

Security

Verify Signatures

Sendable signs webhooks using the Standard Webhooks scheme. Every request includes:

  • webhook-id: unique message ID, the same on every retry of that message
  • webhook-timestamp: Unix time in seconds when the attempt was sent
  • webhook-signature: v1,<base64 HMAC-SHA256> of {webhook-id}.{webhook-timestamp}.{raw body}

The SDK also accepts the older svix-* header names.

The safest path is to verify and parse in one step:

const event = await sendable.webhooks.verifyAndParse(payload, req.headers)

If you want to separate verification from parsing, use:

await sendable.webhooks.assertSignature(payload, req.headers)
const event = JSON.parse(payload)

Use HTTPS

Webhook URLs must use HTTPS. URLs that point to localhost, private networks, or cloud metadata addresses are rejected, and redirects are not followed.

Best Practices

Respond Quickly

Do the verification work inline, then hand off processing:

app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
  const payload = req.body.toString()
  const event = await sendable.webhooks.verifyAndParse(payload, req.headers)

  queueWebhook(event).catch(console.error)
  res.sendStatus(200)
})

Handle Retries

Webhook delivery is at-least-once. Any response other than 2xx, or no response within 15 seconds, counts as a failure. Sendable retries up to the endpoint's max retries setting, waiting retry interval seconds before the first retry and doubling the wait each time (capped at 10 hours). Retries reuse the same webhook-id, so you can use it to deduplicate.

Delivery attempts are kept for 30 days in the webhook logs (GET /webhooks/:webhookId/logs). Re-send one delivery now with POST /webhooks/:webhookId/logs/:deliveryId/retry; it keeps the same webhook-id.

Use Idempotency

Use a stable key built from the envelope:

async function processEvent(event) {
  const id = event.data.id ?? event.data.sessionId
  const idempotencyKey = `${event.type}-${id}-${event.createdAt}`

  if (await alreadyProcessed(idempotencyKey)) {
    return
  }

  await handleEvent(event)
}

Log the Envelope

console.log('webhook', {
  type: event.type,
  createdAt: event.createdAt,
  id: event.data.id ?? event.data.sessionId ?? null,
})

Troubleshooting

Invalid Signature

  • Confirm you are passing the raw request body, not JSON.stringify(req.body)
  • Confirm SENDABLE_WEBHOOK_SECRET matches the endpoint secret from the dashboard
  • Confirm your framework has not consumed or transformed the body before verification

Missing Events

  • Confirm the webhook is active
  • Confirm the subscribed event type matches the event you expect
  • Check the delivery logs in the dashboard or with GET /webhooks/:webhookId/logs
  • For status.received, confirm the session opted in with PUT /v1/status/settings { "storeReceived": true }

Timeouts

  • Return HTTP 200 immediately after verification
  • Move heavy work into a queue or background job

On this page