Skip to content
zotrion

Developers

The Zotrion API

Send and read WhatsApp messages, manage contacts and receive events, from your own server.

Log in to make a key

Base address https://api.zotrion.com · version 1.0.0

Quick start

Make a key in the app, then ask for your numbers. Keep the key on your server. It is shown once, when you make it.

curl "https://api.zotrion.com/v1/numbers" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
What comes back
{
  "numbers": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "display_number": "+1 415 555 0123",
      "verified_name": "Harbor Street Tailors",
      "account_name": "Harbor Street Tailors",
      "status": "connecting",
      "quality_rating": "GREEN",
      "messaging_limit": "TIER_1K",
      "history_sync_status": "complete",
      "contacts_sync_status": "complete",
      "needs_reconnect": false,
      "connected_at": "2026-11-22T10:15:00Z",
      "last_health_at": "2026-11-22T10:15:00Z",
      "disconnecting": false,
      "health": "AVAILABLE",
      "account_health": "AVAILABLE",
      "account_review": "APPROVED",
      "name_status": "APPROVED",
      "health_issues": [
        {
          "code": "invalid_request",
          "description": "A short note from WhatsApp about the number.",
          "solution": "What to do about it."
        }
      ]
    }
  ]
}

Authentication

Send your API key in the Authorization header — Authorization: Bearer zk_live_.... Make keys in the app under Developers. A key is shown once; keep it on your server, never in a browser or a mobile app. A key belongs to one workspace and does only what its scopes allow.

Every request carries your key
Authorization: Bearer zk_live_xxxxxxxxxxxxxxxxxxxxxxxx

Scopes

messages:send, messages:read, contacts, templates, webhooks. A request without the scope its endpoint needs is answered 403 insufficient_scope.

Errors

Every error is JSON — {"error": {"code": "...", "message": "..."}}. Act on the code; the message is for people. 401 invalid_api_key: missing, unknown or revoked key. 403 api_not_in_plan: the workspace's plan has no developer API.

Every error looks like this
{
  "error": {
    "code": "invalid_request",
    "message": "A plain-words explanation of what went wrong."
  }
}

Rate limits

Each key has a limit, and all keys of a workspace share the plan's limit (Starter 60, Growth 300 requests a minute). Past either, the answer is 429 rate_limited with a Retry-After header in seconds.

Idempotency

POST /v1/messages needs an Idempotency-Key header (8 to 100 letters, digits or _ . : -). Sending the same key again returns the first message and sends nothing twice.

Reference

Every route, with what it takes and what it answers.

Messages

POST/v1/messages

Send a WhatsApp message.

Needs the messages:send scope.

Text can be sent while the customer's 24-hour window is open (they wrote to you in the last 24 hours); otherwise send an approved template (window_closed, 409). The message is queued (status queued) and sent at once; read it again or listen for message.status to follow it. 201: a new message. 200: this Idempotency-Key was used before — the first message is returned. Other errors: number_required (400), invalid_template (400), template_not_approved, quota_reached, number_not_connected, idempotency_key_reused (409).

Parameters

  • Idempotency-Keystring, in the headerrequired

Request body (JSON)

  • tostringrequired

    The recipient's phone number with its country code, like +14155550123.

  • number_idstring (uuid)

    The number to send from (GET /v1/numbers). May be left out when the workspace has exactly one.

  • typestringrequired

    One of: text, template

  • textstring

    For type text: up to 4,096 characters.

  • template_idstring (uuid)

    For type template: an approved template (GET /v1/templates).

  • template_componentslist of object

    The template's variables, in WhatsApp's components format.

  • namestring

    Stored as the contact's name when the contact is new.

Answers

  • 200 OK
  • 201 Created
  • 400 Invalid request
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 409 Not possible right now
  • 429 Too many requests
curl -X POST "https://api.zotrion.com/v1/messages" \
  -H "Authorization: Bearer $ZOTRION_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-ready" \
  -d '{
    "to": "+14155550123",
    "type": "text",
    "text": "Hi! Your jacket is ready for pickup.",
    "name": "Sara Kim"
  }'
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "conversation_id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
  "direction": "in",
  "origin": "customer",
  "type": "text",
  "body": "Hi! Your jacket is ready for pickup.",
  "status": "queued",
  "error": {
    "code": "invalid_request",
    "message": "A plain-words explanation of what went wrong."
  },
  "media": {
    "id": "0b6f0f7a-1111-4222-8333-444455556666",
    "mime": "image/jpeg",
    "filename": "jacket.jpg",
    "size_bytes": 48213,
    "available": true
  },
  "template_id": "e7b2d4a1-93c6-4f08-a5d1-8b6c3e9f0a74",
  "sent_by_user_id": "0b6f0f7a-1111-4222-8333-444455556666",
  "timestamp": "2026-11-22T10:15:00Z"
}

GET/v1/messages/{message_id}

Read one message.

Needs the messages:read scope.

status: queued, sending, sent, delivered, read, failed, or received for an inbound message.

Parameters

  • message_idstring (uuid), in the pathrequired

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl "https://api.zotrion.com/v1/messages/0b6f0f7a-1111-4222-8333-444455556666" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "conversation_id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
  "direction": "in",
  "origin": "customer",
  "type": "text",
  "body": "Hi! Your jacket is ready for pickup.",
  "status": "queued",
  "error": {
    "code": "invalid_request",
    "message": "A plain-words explanation of what went wrong."
  },
  "media": {
    "id": "0b6f0f7a-1111-4222-8333-444455556666",
    "mime": "image/jpeg",
    "filename": "jacket.jpg",
    "size_bytes": 48213,
    "available": true
  },
  "template_id": "e7b2d4a1-93c6-4f08-a5d1-8b6c3e9f0a74",
  "sent_by_user_id": "0b6f0f7a-1111-4222-8333-444455556666",
  "timestamp": "2026-11-22T10:15:00Z"
}

Conversations

GET/v1/conversations

List conversations, most recent first.

Needs the messages:read scope.

Parameters

  • cursorstring, in the query string

    next_cursor of the previous page.

  • limitinteger, in the query string

  • statusstring, in the query string

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 429 Too many requests
curl "https://api.zotrion.com/v1/conversations" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "conversations": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "number_id": "c41f7a92-6e3d-4a85-b0c7-1d9e2f385a60",
      "contact": {
        "id": "0b6f0f7a-1111-4222-8333-444455556666",
        "name": "Sara Kim",
        "phone_number": "+14155550123",
        "username": "sarakim",
        "tags": [
          "vip"
        ],
        "created_at": "2026-11-22T10:15:00Z"
      },
      "status": "open",
      "assigned_user_id": "0b6f0f7a-1111-4222-8333-444455556666",
      "unread_count": 0,
      "last_message_at": "2026-11-22T10:15:00Z",
      "last_inbound_at": "2026-11-22T10:15:00Z",
      "window_expires_at": "2026-11-22T10:15:00Z",
      "window_open": false,
      "last_message": {
        "type": "string",
        "preview": "Hi! Is my jacket ready?",
        "direction": "in",
        "status": "string"
      }
    }
  ],
  "next_cursor": "string"
}

GET/v1/conversations/{conversation_id}

Read one conversation.

Needs the messages:read scope.

window_open says whether text can be sent right now.

Parameters

  • conversation_idstring (uuid), in the pathrequired

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl "https://api.zotrion.com/v1/conversations/0b6f0f7a-1111-4222-8333-444455556666" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "number_id": "c41f7a92-6e3d-4a85-b0c7-1d9e2f385a60",
  "contact": {
    "id": "0b6f0f7a-1111-4222-8333-444455556666",
    "name": "Sara Kim",
    "phone_number": "+14155550123",
    "username": "sarakim",
    "tags": [
      "vip"
    ],
    "created_at": "2026-11-22T10:15:00Z"
  },
  "status": "open",
  "assigned_user_id": "0b6f0f7a-1111-4222-8333-444455556666",
  "unread_count": 0,
  "last_message_at": "2026-11-22T10:15:00Z",
  "last_inbound_at": "2026-11-22T10:15:00Z",
  "window_expires_at": "2026-11-22T10:15:00Z",
  "window_open": false,
  "last_message": {
    "type": "string",
    "preview": "Hi! Is my jacket ready?",
    "direction": "in",
    "status": "string"
  }
}

GET/v1/conversations/{conversation_id}/messages

List a conversation's messages, newest first.

Needs the messages:read scope.

Parameters

  • conversation_idstring (uuid), in the pathrequired

  • cursorstring, in the query string

    next_cursor of the previous page.

  • limitinteger, in the query string

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl "https://api.zotrion.com/v1/conversations/0b6f0f7a-1111-4222-8333-444455556666/messages" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "messages": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "conversation_id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
      "direction": "in",
      "origin": "customer",
      "type": "text",
      "body": "Hi! Your jacket is ready for pickup.",
      "status": "queued",
      "error": {
        "code": "invalid_request",
        "message": "A plain-words explanation of what went wrong."
      },
      "media": {
        "id": "0b6f0f7a-1111-4222-8333-444455556666",
        "mime": "image/jpeg",
        "filename": "jacket.jpg",
        "size_bytes": 48213,
        "available": true
      },
      "template_id": "e7b2d4a1-93c6-4f08-a5d1-8b6c3e9f0a74",
      "sent_by_user_id": "0b6f0f7a-1111-4222-8333-444455556666",
      "timestamp": "2026-11-22T10:15:00Z"
    }
  ],
  "next_cursor": "string"
}

Contacts

GET/v1/contacts

List contacts.

Needs the contacts scope.

Parameters

  • cursorstring, in the query string

    next_cursor of the previous page.

  • limitinteger, in the query string

  • qstring, in the query string

    Search by name or phone number.

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 429 Too many requests
curl "https://api.zotrion.com/v1/contacts" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "contacts": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "name": "Sara Kim",
      "phone_number": "+14155550123",
      "username": "sarakim",
      "tags": [
        "vip"
      ],
      "created_at": "2026-11-22T10:15:00Z"
    }
  ],
  "next_cursor": "string"
}

POST/v1/contacts

Add a contact.

Needs the contacts scope.

201: a new contact. 200: a contact with this phone number exists — it is returned unchanged.

Request body (JSON)

  • phone_numberstringrequired

  • namestring

  • tagslist of string

Answers

  • 200 OK
  • 201 Created
  • 400 Invalid request
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 409 Not possible right now
  • 429 Too many requests
curl -X POST "https://api.zotrion.com/v1/contacts" \
  -H "Authorization: Bearer $ZOTRION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "+14155550123",
    "name": "Sara Kim",
    "tags": [
      "vip"
    ]
  }'
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "name": "Sara Kim",
  "phone_number": "+14155550123",
  "username": "sarakim",
  "tags": [
    "vip"
  ],
  "created_at": "2026-11-22T10:15:00Z"
}

GET/v1/contacts/{contact_id}

Read one contact.

Needs the contacts scope.

Parameters

  • contact_idstring (uuid), in the pathrequired

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl "https://api.zotrion.com/v1/contacts/0b6f0f7a-1111-4222-8333-444455556666" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "name": "Sara Kim",
  "phone_number": "+14155550123",
  "username": "sarakim",
  "tags": [
    "vip"
  ],
  "created_at": "2026-11-22T10:15:00Z"
}

PATCH/v1/contacts/{contact_id}

Change a contact's name or tags.

Needs the contacts scope.

A field left out is not changed.

Parameters

  • contact_idstring (uuid), in the pathrequired

Request body (JSON)

  • namestring

  • tagslist of string

Answers

  • 200 OK
  • 400 Invalid request
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl -X PATCH "https://api.zotrion.com/v1/contacts/0b6f0f7a-1111-4222-8333-444455556666" \
  -H "Authorization: Bearer $ZOTRION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sara Kim",
    "tags": [
      "vip"
    ]
  }'
Answer 200
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "name": "Sara Kim",
  "phone_number": "+14155550123",
  "username": "sarakim",
  "tags": [
    "vip"
  ],
  "created_at": "2026-11-22T10:15:00Z"
}

Numbers

GET/v1/numbers

List the workspace's WhatsApp numbers.

Needs the messages:read scope.

A number can send while its status is registered or active.

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 429 Too many requests
curl "https://api.zotrion.com/v1/numbers" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "numbers": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "display_number": "+1 415 555 0123",
      "verified_name": "Harbor Street Tailors",
      "account_name": "Harbor Street Tailors",
      "status": "connecting",
      "quality_rating": "GREEN",
      "messaging_limit": "TIER_1K",
      "history_sync_status": "complete",
      "contacts_sync_status": "complete",
      "needs_reconnect": false,
      "connected_at": "2026-11-22T10:15:00Z",
      "last_health_at": "2026-11-22T10:15:00Z",
      "disconnecting": false,
      "health": "AVAILABLE",
      "account_health": "AVAILABLE",
      "account_review": "APPROVED",
      "name_status": "APPROVED",
      "health_issues": [
        {
          "code": "invalid_request",
          "description": "A short note from WhatsApp about the number.",
          "solution": "What to do about it."
        }
      ]
    }
  ]
}

Templates

GET/v1/templates

List message templates.

Needs the templates scope.

Only a template with status approved can be sent.

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 429 Too many requests
curl "https://api.zotrion.com/v1/templates" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "templates": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "account_id": "0b6f0f7a-1111-4222-8333-444455556666",
      "name": "Sara Kim",
      "language": "en_US",
      "category": "marketing",
      "status": "pending",
      "components": [
        {}
      ],
      "rejected_reason": "string",
      "quality_score": "GREEN",
      "submitted": false,
      "updated_at": "2026-11-22T10:15:00Z"
    }
  ]
}

Webhooks

GET/v1/webhooks

List webhooks.

Needs the webhooks scope.

Answers

  • 200 OK
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 429 Too many requests
curl "https://api.zotrion.com/v1/webhooks" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"
Answer 200
{
  "webhooks": [
    {
      "id": "0b6f0f7a-1111-4222-8333-444455556666",
      "url": "https://example.com/zotrion",
      "events": [
        "message.received"
      ],
      "enabled": true,
      "disabled_reason": "failing",
      "failing_since": "2026-11-22T10:15:00Z",
      "created_at": "2026-11-22T10:15:00Z"
    }
  ],
  "events": [
    "string"
  ]
}

POST/v1/webhooks

Add a webhook.

Needs the webhooks scope.

The answer carries signing_secret once. Up to 5 webhooks per workspace (too_many_webhooks, 409).

Request body (JSON)

  • urlstringrequired

    A public https:// address (port 443 or 8443). Addresses inside a private network are refused.

  • eventslist of stringrequired

    One of: message.received, message.status, conversation.assigned, conversation.status

Answers

  • 201 Created
  • 400 Invalid request
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 409 Not possible right now
  • 429 Too many requests
curl -X POST "https://api.zotrion.com/v1/webhooks" \
  -H "Authorization: Bearer $ZOTRION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/zotrion",
    "events": [
      "message.received"
    ]
  }'
Answer 201
{
  "id": "0b6f0f7a-1111-4222-8333-444455556666",
  "url": "https://example.com/zotrion",
  "events": [
    "message.received"
  ],
  "enabled": true,
  "disabled_reason": "failing",
  "failing_since": "2026-11-22T10:15:00Z",
  "created_at": "2026-11-22T10:15:00Z",
  "signing_secret": "whsec_3c9d1a7b5e0f4a2c8d6b1e9f"
}

DELETE/v1/webhooks/{webhook_id}

Remove a webhook.

Needs the webhooks scope.

Parameters

  • webhook_idstring (uuid), in the pathrequired

Answers

  • 204 No content
  • 401 Missing or invalid API key
  • 403 Not allowed
  • 404 Not found
  • 429 Too many requests
curl -X DELETE "https://api.zotrion.com/v1/webhooks/0b6f0f7a-1111-4222-8333-444455556666" \
  -H "Authorization: Bearer $ZOTRION_API_KEY"

Answer 204: no content.

Webhooks

Register an https:// address and choose events. Each delivery is a POST with the headers Zotrion-Event-Id, Zotrion-Event-Type, Zotrion-Delivery-Id and Zotrion-Signature: t=<unix time>,v1=<hex>. To verify, compute HMAC-SHA256 of the string "<t>.<raw request body>" with your endpoint's signing secret, compare it with v1 in constant time, and refuse a t older than 5 minutes. Answer 2xx within 10 seconds. Anything else is tried again after 1 minute, 5 minutes, 30 minutes, 2, 6, 12 and 24 hours (8 attempts). Redirects are not followed. An endpoint that fails for 3 days is switched off. The same event may arrive more than once: use Zotrion-Event-Id to recognize it.

Headers on every delivery

  • Zotrion-Event-Id
  • Zotrion-Event-Type
  • Zotrion-Delivery-Id
  • Zotrion-Signature

If your server doesn't answer 2xx

  1. Attempt 1: at once
  2. Attempt 2: 1 minute after the one before
  3. Attempt 3: 5 minutes after the one before
  4. Attempt 4: 30 minutes after the one before
  5. Attempt 5: 2 after the one before
  6. Attempt 6: 6 after the one before
  7. Attempt 7: 12 after the one before
  8. Attempt 8: 24 hours after the one before

Check that a call came from Zotrion

Work out the signature from the raw request body, exactly as it arrived, with your endpoint's signing secret. If you parse the JSON first and write it back out, the signature will not match.

import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body exactly as received (a string, before any JSON parsing).
export function isFromZotrion(rawBody, signatureHeader, signingSecret) {
  const parts = Object.fromEntries(signatureHeader.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > 300) return false; // older than 5 minutes
  const expected = createHmac("sha256", signingSecret).update(`${parts.t}.${rawBody}`).digest();
  const given = Buffer.from(parts.v1 ?? "", "hex");
  return given.length === expected.length && timingSafeEqual(given, expected);
}

Event payloads

Choose which events an address hears about. The type is in the Zotrion-Event-Type header; the details are in data.

message.received

A customer wrote. data.message (id, conversation_id, number_id, direction, type, text, status, timestamp) and data.contact (id, name, phone_number).

Body of the call
{
  "data": {
    "message": {
      "id": "7f1c2a90-4b3d-4e68-a1f5-0c9d8b7e6a54",
      "conversation_id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
      "number_id": "c41f7a92-6e3d-4a85-b0c7-1d9e2f385a60",
      "direction": "in",
      "type": "text",
      "text": "Hi! Is my jacket ready?",
      "status": "received",
      "timestamp": "2026-11-22T10:15:00Z"
    },
    "contact": {
      "id": "9a3e1c70-2b58-4d6f-8e14-3c7f5a0b1d29",
      "name": "Sara Kim",
      "phone_number": "+14155550123"
    }
  }
}

message.status

A message you sent changed status: data.message.status is sent, delivered, read or failed (with error_code).

Body of the call
{
  "data": {
    "message": {
      "id": "7f1c2a90-4b3d-4e68-a1f5-0c9d8b7e6a54",
      "conversation_id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
      "number_id": "c41f7a92-6e3d-4a85-b0c7-1d9e2f385a60",
      "direction": "out",
      "type": "text",
      "text": "Yes, it's ready.",
      "status": "delivered",
      "timestamp": "2026-11-22T10:15:00Z"
    }
  }
}

conversation.assigned

A conversation was assigned or unassigned: data.conversation.assigned_user_id (null when unassigned).

Body of the call
{
  "data": {
    "conversation": {
      "id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
      "assigned_user_id": "3b9f6d12-0a7e-4c85-9d31-6e2a8c4f1b07"
    }
  }
}

conversation.status

A conversation was opened, set pending or closed: data.conversation.status.

Body of the call
{
  "data": {
    "conversation": {
      "id": "5d2c8e31-7a44-4b0e-9f21-6a1c0d8e7b52",
      "status": "closed"
    }
  }
}

Join the waitlist

Signup isn't open yet. Leave your email and we'll write once, on the day we open. Zotrion is free. Meta bills you directly for WhatsApp messages.

We'll write once, on the day we open. We use your email for that message and nothing else.

Already have an account? Log in

A food stall owner in an apron reads a message on his phone at his counter.