SendKuy API

Webhooks

We call you when something happens, signed so you can trust it.

Register an endpoint with POST /webhooks and we POST a JSON event to it when something happens. The URL must be https:// — the payload can carry the text of your customers' messages, and plain http would send that in the clear.

The response that creates an endpoint is the only one that carries the signing secret in full. Every later read answers with secret_preview instead.

Events

EventRaised for
message.sentCampaign messages only
message.deliveredAny message
message.openedCampaign messages only
message.clickedCampaign messages only
message.repliedCampaign messages only
message.bouncedCampaign messages only
message.failedAny message
message.receivedAny message
campaign.completedAny message
campaign.pausedAny message
contact.createdAny message
contact.updatedAny message

The five marked `campaign_only` are only ever raised for messages born from a campaign. The tables behind single sends do not record those states at all, so subscribing to them and sending one-off messages means waiting for events that will never arrive.

`message.delivered` on a single message means the provider accepted it — for WhatsApp, WhatsApp took it. It is raised once, at hand-off. When the phone receives the message we fill `delivered_at`, and `read_at` once it is read; read them with `GET /messages/{id}`, because no event is raised when they arrive. Campaign messages also move to `delivered` and `opened` as those receipts come in, and raise those events.

Verifying the signature

Each request carries X-SendKuy-Signature, formatted t={timestamp},v1={hmac}.

`hash_hmac('sha256', timestamp . '.' . rawRequestBody, secret)`. Compute it over the raw body, before any JSON parsing — re-encoding changes the bytes and the signature will not match. Compare with a constant-time comparison, and reject timestamps that are too old to stop replays.

Headers

HeaderMeaning
X-SendKuy-EventThe event name, the same value as `events` on the endpoint.
X-SendKuy-Event-IdThe id of this delivery attempt's event. It stays the same across all six attempts, so use it to make your handler idempotent — a retry is the same event, not a second one.

Retries

6 attempts: the first immediately, then after 1m, 5m, 30m, 2h, 12h.

The first call is immediate; the five entries above are the waits before each following attempt. Answer 2xx quickly — the call times out after 10 seconds, and a slow handler is a failed delivery. Repeated failures eventually disable the endpoint, which shows up as `disabled_at`.

Incoming messages

message.received fires for every message a customer sends you, on WhatsApp (QR, Chrome extension and Cloud API), SMS and email. Its data tells you who wrote and where:

{
  "object": "conversation_message",
  "id": "cms_9cBe3A1H-SLhW5fONWZ32wb-IIio5Ts3",
  "conversation_id": "cnv_2Kq0hN7a-PbZx1yLw4mT8e-VcR3uJ6s",
  "body": "Halo, pesanan saya belum sampai",
  "created_at": "2026-11-01T09:00:00+07:00",
  "updated_at": "2026-11-01T09:00:00+07:00",
  "channel": "whatsapp",
  "from": "+6281234567890",
  "gateway_id": "gw_9cBe3A1H-SLhW5fONWZ32wb-IIio5Ts3",
  "provider_message_id": "wamid.HBgNNjI4MTIzNDU2Nzg5MBUCABIYFjNFQjA",
  "received_at": "2026-11-01T09:00:00+07:00",
  "subject": null,
  "media": null
}

Use provider_message_id to skip a message you already handled. media, when present, names the type and file; its url is filled when the channel hands us the file.

Keep them in SendKuy, or forward them only

By default the message is also kept in the SendKuy inbox, and id and conversation_id point at it: you can answer with POST /conversations/{id}/reply.

If your own helpdesk keeps the conversations, turn on Forward incoming messages to my webhook only under Developers › Webhooks. Messages are then not stored in SendKuy, so id and conversation_id are null; answer with POST /messages to from. A forwarded media url stays valid for seven days, so copy the file. A forwarded message your endpoint never accepts, after every retry, is kept in the inbox instead, and so is everything while no active endpoint listens to message.received.

Verify with an SDK

Each SDK checks X-SendKuy-Signature for you. Give it the raw request body, because re-encoding parsed JSON changes the bytes and the signature stops matching, and the endpoint secret in full, whsec_ included.

import { SignatureVerificationError, verifyWebhook } from 'sendkuy';

export async function POST(request: Request) {
  try {
    const event = await verifyWebhook({
      payload: await request.text(),
      signature: request.headers.get('x-sendkuy-signature'),
      secret: process.env.SENDKUY_WEBHOOK_SECRET ?? '',
    });

    return new Response(null, { status: 200 });
  } catch (error) {
    if (error instanceof SignatureVerificationError) {
      return new Response(null, { status: 403 });
    }

    throw error;
  }
}

With Express, read the body raw with express.raw({ type: 'application/json' }) and pass req.body as payload. An empty secret is a configuration mistake, not a bad signature: the SDKs throw SendKuyError or SendKuyException for it, so it surfaces as a 500 in your delivery history instead of a quiet 403.

X-SendKuy-Event-Id stays the same across every retry of one delivery: store it and skip ids you have seen.