Skip to content
REST API v1 · Webhooks

Build on WhatsApp with an API you can trust

Send messages, sync contacts and react to events from your own software. Scoped keys, safe retries, signed and timestamped webhooks, and a spec that always matches the server.

  • Bearer API keys with scopes
  • JSON over HTTPS
  • HMAC-signed webhooks
  • OpenAPI 3.1 spec

Quickstart

From zero to your first message in three steps.

  1. Create an API key

    In the app, open Settings, then Developers, and create a key with only the scopes you need. The full key is shown once, so store it as a secret on your server.

  2. Make your first request

    Call GET /me to confirm the key works, then send a template message. Sending needs an Idempotency-Key so a retry can never message the customer twice.

  3. Listen for events

    Add a webhook endpoint, pick the events, and verify the signature on every request. You get message status, replies, contact and template changes as they happen.

The REST API is included in the Pro and Business plans.

Check the connection

curl https://24msg.com/api/v1/me \
  -H "Authorization: Bearer $API_KEY"

Send a template message

curl https://24msg.com/api/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: order-1042-confirmation" \
  -H "Content-Type: application/json" \
  -d '{
  "to": { "phone": "+14155550123" },
  "type": "template",
  "template": {
    "name": "order_confirmation",
    "language": "en",
    "variables": { "1": "Alex", "2": "SO-1042" }
  }
}'
202 Accepted
{
  "id": "0197d3a4-1b2c-7d00-8e11-2f3a4b5c6d7e",
  "conversationId": "0197d3a4-1b2c-7d00-8e11-2f3a4b5c6d7f",
  "contactId": "0197d3a4-1b2c-7d00-8e11-2f3a4b5c6d80",
  "channelId": "0197d3a4-1b2c-7d00-8e11-2f3a4b5c6d81",
  "status": "queued",
  "createdAt": "2026-11-17T10:00:00.000Z"
}

Built so integrations do not break at 2 a.m.

Four details that save you from the usual webhook and retry headaches.

  • Signed and timestamped webhooks

    Each delivery has an HMAC-SHA256 signature over the timestamp and the exact body. Replays older than five minutes are rejected, and a rotated secret stays valid for 24 hours so you can switch without downtime.

  • Idempotency-Key on every write

    Retry a POST after a timeout without doing the work twice. The same key with the same body returns the first response. For sending messages the header is required.

  • A documented retry policy

    Seven attempts over about 32 hours on a fixed schedule, a log of every attempt you can resend from, and an automatic pause with an email when an endpoint keeps failing. No guessing.

  • OpenAPI 3.1 that cannot drift

    The spec is generated from the same schemas the server validates requests against. Import it into Postman or Insomnia, or generate a typed client in your language.

Authentication and scopes

Send your key as a Bearer token. Keys belong to one workspace and carry only the scopes you picked.

HTTP
Authorization: Bearer 24msg_live_a41f09c2_<64 hex characters>

Keys are server-side secrets. The API has no CORS, so never put a key in a browser or mobile app. A missing scope returns 403 with the scope that is required.

Scopes

Scopes
ScopeAllows
contacts:readRead contacts, tags and attributes.
contacts:writeCreate and update contacts and their attributes.
consents:writeRecord opt-in and opt-out evidence for a contact.
tags:writeAdd and remove tags on contacts.
conversations:readList conversations and their status.
messages:readRead message content and delivery status.
messages:sendSend text, media and template messages.
templates:readList approved message templates.
channels:readList connected WhatsApp numbers.
events:writePush commerce events (orders, carts) to trigger automations.
webhooks:manageCreate and manage webhook endpoints through the API.

Scopes are chosen when the key is created and cannot change. To change them, create a new key and revoke the old one.

Limits by plan

Limits by plan
PlanActive keysRequests per minute
Pro360
Business10300

The rate limit is shared by all keys in a workspace, so opening more keys does not raise it.

Errors, paging and rate limits

The same predictable shapes everywhere, so one client handles every endpoint.

Error envelope

Every error has the same JSON shape. Quote requestId when you contact support. details.reason gives a machine-readable cause.

400 Bad Request
{
  "code": "validation",
  "message": "Idempotency-Key header is required",
  "requestId": "req_8f3a1c2e",
  "details": { "reason": "idempotency_key_required" }
}
Error envelope
StatuscodeMeaning
400validationThe body or query is invalid. See details.issues.
401unauthenticatedThe key is missing, malformed, revoked or expired.
402limit_reachedA plan limit was reached (keys, endpoints, contacts).
403forbidden · feature_lockedA scope is missing, or the plan has no REST API.
404not_foundNot found. Resources of other workspaces are also 404.
409conflictConflict, for example an idempotent request still in progress.
422validation · no_consent · template_requiredA business rule blocked it: window closed, no consent, template not approved, or an Idempotency-Key reused with a different body.
429rate_limitedRate limit exceeded. Wait Retry-After seconds.
500internalOur side. Retry with backoff and quote requestId.

Pagination

List endpoints return newest first as { data, nextCursor }. Pass nextCursor back as ?cursor= until it is null. limit is 1 to 100 and defaults to 25. There is no total count.

Idempotency

Send Idempotency-Key with any POST. Keys are scoped to your workspace and kept for 24 hours. Same key and same body returns the original response with Idempotent-Replayed: true. Same key with a different body returns 422. POST /messages requires the header.

Rate limit headers

Every response, errors included, tells you where you stand. On 429, wait for Retry-After seconds. The window is 60 seconds, so a burst at the boundary can reach twice the limit.

Rate limit headers
HeaderValue
X-RateLimit-LimitRequests allowed per window
X-RateLimit-RemainingRequests left in this window
X-RateLimit-ResetWhen the window resets (Unix seconds)
Retry-After429

Webhooks

We POST JSON to your HTTPS endpoint when something happens. Verify the signature, answer 2xx quickly, and do the heavy work in a queue.

The event envelope

Every event has the same outer shape. id is the event ID and stays the same on every retry and resend, so use it to deduplicate. Unknown fields may appear later: ignore them.

POST application/json
{
  "id": "0197d3a2-7c1e-7a10-9a3f-5b2c8e1d4f60",
  "type": "message.received",
  "apiVersion": "1",
  "occurredAt": "2026-11-17T10:00:00.000Z",
  "workspaceId": "0197d3a2-0000-7000-8000-00000000a001",
  "data": {
    "message": { "id": "…", "direction": "in", "type": "text", "status": "delivered" },
    "contact": { "id": "…", "phone": "+14155550123", "externalId": null, "name": "Alex" }
  }
}

Request headers

Request headers
HeaderValue
X-24msg-SignatureTimestamp and signature, see below
X-24msg-Event-IdEvent ID: your deduplication key
X-24msg-Event-TypeThe event type, for example message.received
X-24msg-Delivery-IdID of this delivery
X-24msg-Delivery-AttemptAttempt number, 1 to 7

Verify the signature

The signature is an HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with your whsec_ secret.

  1. Read the X-24msg-Signature header: t=1763380800,v1=5257a8…. There can be two v1 values during a secret rotation.
  2. Reject the request if the timestamp differs from your clock by more than 300 seconds.
  3. Compute HMAC-SHA256 over t + "." + the raw body, using the whole whsec_ string as the key.
  4. Compare with every v1 value in constant time. Any match is valid.
  5. Answer 2xx fast and store the event ID for at least 7 days, so a resend is ignored.

Use the raw body bytes exactly as received. If your framework parses JSON first and you re-serialize it, the signature will not match.

import crypto from "node:crypto";
import express from "express";

export function verifySignature(rawBody, header, secret, toleranceSec = 300) {
  let t = "";
  const signatures = [];
  for (const part of header.split(",")) {
    const [key, value] = part.trim().split("=");
    if (key === "t") t = value;
    if (key === "v1") signatures.push(value);
  }
  if (!/^\d+$/.test(t) || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSec) return false;

  const expected = crypto
    .createHmac("sha256", secret) // the whole whsec_... string
    .update(`${t}.`)
    .update(rawBody) // Buffer: the bytes exactly as received
    .digest();
  return signatures.some((sig) => {
    const got = Buffer.from(sig, "hex");
    return got.length === expected.length && crypto.timingSafeEqual(got, expected);
  });
}

const app = express();
app.post("/hooks/24msg", express.raw({ type: "application/json" }), (req, res) => {
  const ok = verifySignature(req.body, req.get("X-24msg-Signature") ?? "", process.env.WHSEC);
  if (!ok) return res.sendStatus(400);
  const event = JSON.parse(req.body); // dedupe on event.id, then enqueue
  res.sendStatus(200);
});

Retry policy

A delivery succeeds on any 2xx within 10 seconds. Redirects are not followed and count as failures. We try up to seven times on this schedule, with about 10 percent jitter, then mark the delivery failed. You can resend it from the delivery log or the API with the same event ID.

Retry policy
AttemptSent
1Immediately
21 minute after the failure
35 minutes later
430 minutes later
52 hours later
66 hours later
724 hours later, then marked failed

Automatic pause

If an endpoint fails 50 deliveries in a row over at least 24 hours, we pause it and email the workspace owners and admins. Fix it, re-enable it in the app, and resend what you missed.

Delivery guarantees

Delivery is at least once and not ordered. An event can arrive twice, or after a later one: deduplicate by event ID and sort by occurredAt.

Where we send

Endpoints must be public HTTPS addresses on port 443. We refuse private and internal addresses, and check again on every attempt.

Event catalog

Subscribe to the events you need, or to all of them. The data column shows what goes in data.

Messages

Messages
EventWhen it firesdata
message.receivedA customer message arrived.message, contact
message.sentAn outgoing message was accepted by WhatsApp.message
message.deliveredAn outgoing message reached the phone.message
message.readThe customer read the message.message
message.failedA message could not be delivered.message (error)

Conversations

Conversations
EventWhen it firesdata
conversation.openedA new conversation started or was reopened.conversation
conversation.assignedA conversation was assigned or unassigned.conversationId, assigneeMemberId, previousAssigneeMemberId
conversation.closedA conversation was resolved.conversationId, closedAt

Contacts

Contacts
EventWhen it firesdata
contact.createdA new contact was created.contact
contact.updatedA contact changed.contact, changedFields
contact.consent_changedA contact granted or revoked consent.contactId, scope, status, previousStatus, source, at
tag.addedA tag was added to a contact.contactId, tag

Templates and numbers

Templates and numbers
EventWhen it firesdata
template.status_changedWhatsApp approved, rejected or re-rated a template.templateId, name, language, category, previousStatus, status, qualityScore, rejectedReason
channel.status_changedA number's connection, quality or limit changed.channelId, previousStatus, status, qualityRating, messagingLimit
campaign.completedA campaign finished or was cancelled.campaignId, name, outcome, stats, finishedAt
webhook.test
EventWhen it firesdata
webhook.testSent when you press Send test.message

Contact imports and merges do not fire one event per contact, to avoid floods. Media bytes and costs are never included.

Reference and tools

Every endpoint, parameter, schema and error, generated from the same definitions the server enforces. The reference is in English.

In Postman or Insomnia, choose Import, then Link, and paste the openapi.json address. Generators such as openapi-generator turn the same file into a typed client. /api/v1/openapi.json

Frequently asked questions

Which plans include the API?

The REST API and webhooks are included in Pro and Business. Pro allows 3 active keys and 60 requests per minute, Business 10 keys and 300 per minute. Starter and trial workspaces cannot create keys.

Does the API bypass WhatsApp's rules?

No. Sending goes through the same checks as the inbox: the 24-hour window, approved templates and customer consent. A request that would break a rule is rejected with a 422 and a reason, before anything reaches Meta.

How do I avoid sending a message twice?

Send an Idempotency-Key header, for example a UUID you store with your order. If the request times out, repeat it with the same key and body: you get the original response and the customer gets one message.

What happens if my server is down?

We retry up to seven times over about 32 hours. Every attempt is logged with status code, duration and response. If it still fails, the delivery is marked failed and you can resend it, with the same event ID, from the app or the API.

Can I call the API from a browser or mobile app?

No. Keys are secrets and the API deliberately has no CORS. Call it from your own backend, and let your front end talk to your backend.

How do I rotate or revoke credentials?

Revoking an API key takes effect immediately. Webhook secrets can be rotated in the app: the old secret keeps signing next to the new one for 24 hours, so you can deploy the change without dropping events.

Try it with your own number

Start free