WhatsPro
Back to WhatsPro

Developer guide · API v1

Connect your workflow to WhatsPro.

Use a workspace API key to import contacts and request template messages. Requests are scoped to the workspace that owns the key.

Signed authentication

Create a key in Developer & API after signing in, and choose only the permissions that integration needs. WhatsPro shows the public key and secret once. Every request must include X-API-Key, X-Timestamp, X-Nonce, and X-Signature. The signature is the lowercase hexadecimal HMAC-SHA256 of the uppercase method, exact request path (including query string), exact JSON body bytes sent, timestamp, and nonce concatenated in that order. Timestamps are Unix milliseconds and expire after five minutes; each nonce is single-use. Keep the secret on your server and revoke the key if exposed.

Build the signature in Node.js

Serialize the body once and use the same string both for signing and for the HTTP request. Use a fresh random nonce for every attempt. If a request has a query string, include it in the signed path.

Node.js · signed request helper
import { createHmac, randomBytes } from "node:crypto";

const apiOrigin = process.env.WHATSPRO_API_URL;
const publicKey = process.env.WHATSPRO_API_PUBLIC_KEY;
const secret = process.env.WHATSPRO_API_SECRET;

async function whatsProRequest(method, path, body) {
  const timestamp = String(Date.now()); // milliseconds
  const nonce = randomBytes(18).toString("base64url");
  const rawBody = body === undefined ? "" : JSON.stringify(body);
  const signature = createHmac("sha256", secret)
    .update(method.toUpperCase() + path + rawBody + timestamp + nonce)
    .digest("hex");

  return fetch(new URL(path, apiOrigin), {
    method,
    headers: {
      "X-API-Key": publicKey,
      "X-Timestamp": timestamp,
      "X-Nonce": nonce,
      "X-Signature": signature,
      ...(body === undefined ? {} : { "Content-Type": "application/json" }),
    },
    ...(body === undefined ? {} : { body: rawBody }),
  });
}

// Keep the public key and one-time secret in your server's secret store.
const response = await whatsProRequest("POST", "/api/v1/contacts/bulk", {
  contacts: [{ phone_number: "+14155550123", name: "Taylor", language_code: "en_US" }],
});
console.log(response.status, await response.json());

API key permissions

Each key is limited to the permissions selected when it is created. Create a replacement key to change permissions; keys created before scoped access was added keep their previous endpoint access.

Versioning and deprecation

The version is part of the URL: this API is /api/v1. Compatible additions may ship within v1; a breaking contract change requires a new versioned path. Responses from v1 include X-WhatsPro-API-Version: 1.

Lifecycle dates are not built into the code. When an operator schedules a retirement, responses include the standard Deprecation header and a link to this notice; Sunset is added only when a retirement date is set. Continue checking this reference and response headers for lifecycle updates.

Available endpoints

MethodPathPurpose
GET/api/v1/templatesList templates available in the API key’s workspace.
GET/api/v1/analytics/summaryRead workspace message totals.
POST/api/v1/contacts/bulkImport up to 1,000 E.164 contacts.
POST/api/v1/messages/sendRequest asynchronous delivery of an approved template.

Contacts

Import up to 1,000 contacts

Send E.164 phone numbers. Names can be up to 120 characters. Optional language codes use forms such as en or en_US. Duplicate phone numbers are skipped. Imports never grant marketing consent.

Request
curl -X POST "https://<your-domain>/api/v1/contacts/bulk" \
  -H "X-API-Key: <public-key>" \
  -H "X-Timestamp: <13-digit-unix-milliseconds>" \
  -H "X-Nonce: <unique-random-value-at-least-16-characters>" \
  -H "X-Signature: <hmac-sha256-signature>" \
  -H "Content-Type: application/json" \
  -d '{
    "contacts": [
      { "phone_number": "+14155550123", "name": "Taylor", "language_code": "en_US" }
    ]
  }'
Successful response · HTTP 200
{
  "success": true,
  "received": 1,
  "created": 1,
  "duplicatesSkipped": 0,
  "consentGranted": false
}

Invalid payloads return HTTP 400. An invalid or revoked key returns HTTP 401. Workspace contact limits and API rate limits apply.

Webhooks

Receive and verify event deliveries

Subscribe to whatsapp.message.status for provider send status changes, or whatsapp.message.received for incoming messages. Each event has an id, type, createdAt, and event-specific data. Incoming message data may contain a sender phone number and message text; handle it as customer data.

Status event payload
{
  "id": "evt_…",
  "type": "whatsapp.message.status",
  "createdAt": "2030-01-01T12:00:00.000Z",
  "data": { "messageId": "…", "providerMessageId": "…", "recipient": "14155550123", "status": "delivered", "timestamp": "…", "error": null }
}

Verify X-WhatsPro-Signature against the exact raw request body. X-WhatsPro-Signature-Version: 1 signs timestamp + "." + rawBody with HMAC-SHA256 and the endpoint secret; the signature header uses the sha256= prefix. Compare in constant time and reject timestamps outside your replay window. X-WhatsPro-Delivery stays the same across retries and manual replay, so store it as your deduplication key.

Node.js signature check · after validating equal lengths
const expected = "sha256=" + createHmac("sha256", secret).update(timestamp + "." + rawBody).digest("hex");
const valid = timingSafeEqual(Buffer.from(signature), Buffer.from(expected));

Delivery is at least once and event order is not guaranteed. WhatsPro retries with exponential backoff starting at one second. After five consecutive endpoint failures, delivery pauses for 15 minutes and pending events resume automatically. Admins can replay a failed delivery in Developer & API. Respond with any 2xx status after processing; deduplicate using the delivery ID.

Messages

Request a template message

The endpoint accepts the request for asynchronous delivery and returns a message ID and current status. A successful response means WhatsPro accepted the request; check message status for the provider outcome. Template approval and recipient consent are checked before queueing.

Request
curl -X POST "https://<your-domain>/api/v1/messages/send" \
  -H "X-API-Key: <public-key>" \
  -H "X-Timestamp: <13-digit-unix-milliseconds>" \
  -H "X-Nonce: <unique-random-value-at-least-16-characters>" \
  -H "X-Signature: <hmac-sha256-signature>" \
  -H "Idempotency-Key: order-8421-update" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155550123",
    "template": "order_update",
    "language": "en_US",
    "variables": { "1": "8421" }
  }'
Accepted response · HTTP 202
{ "success": true, "messageId": "<message-id>", "status": "accepted" }

A 202 response means WhatsPro durably accepted the request; delivery happens asynchronously. Send Idempotency-Key (1–128 permitted characters) to safely retry the same body. Keys are scoped to the API app and endpoint. Reuse the same key only with the exact same request body; a changed body returns HTTP 409 and needs a new key. A recipient without recorded opt-in, a recipient who opted out, or a template that is not approved and synced is rejected with HTTP 400.

Sandbox

Test the API without live workspace effects

Create a sandbox key in Developer & API, then use the matching route prefix /api/v1/sandbox. Sandbox keys are blocked from live routes, and live keys are blocked from sandbox routes. Requests still use the same HMAC authentication, scopes, validation, rate limits, and idempotency behavior.

Sandbox message result · HTTP 202
{ "success": true, "sandbox": true, "simulated": true, "messageId": "sandbox_msg_<id>", "status": "simulated", "notice": "No WhatsApp message was sent or stored." }

Errors

Handle request failures

Errors return JSON with a status code, timestamp, request path, and message. Validation messages may be an array.

HTTPMeaningWhat to do
400Invalid fields or headers, invalid E.164 number, unavailable approved template, missing consent, opted-out recipient, or no active plan.Correct the request or workspace setup. A changed send body needs a new idempotency key.
401Key, signature, timestamp, or nonce is missing, expired, invalid, or already used.Check signing bytes and create a fresh timestamp and nonce for each attempt.
403The key lacks the endpoint permission or is being used against the other environment.Grant the needed scope or use the route prefix that matches the key environment.
404The API path does not exist.Check the v1 path and HTTP method.
409An idempotency key has a different request body or its original request is still processing.For an in-progress request, wait and retry the same body with the same key. Use a new key for a changed body.
429The API app exceeded its fixed requests-per-minute window (60 per minute by default; a per-app limit can override it).Use X-RateLimit-Reset or Retry-After to wait. Sign the retry with a fresh nonce; keep the same idempotency key and body for a send retry.
500An unexpected server error occurred.For a send, retry with the same idempotency key and body to avoid duplicate acceptance; otherwise retry with a fresh nonce.
503Redis replay protection or API rate limiting is unavailable.Retry later with a newly signed request and fresh nonce; keep the same idempotency key and body for a send.

Errors use a JSON body containing statusCode, timestamp, path, and message; validation messages may be an array. Rate-limit headers are returned on authenticated requests and exposed to browser clients through CORS, alongside version and configured lifecycle headers.

Need a key?

Sign in to the workspace, open Developer & API, and create a key for your integration. Keep credentials private and rotate them if access changes.

Open workspace