Skip to Content
Sendable Docs

Agent Quickstart

The short version of the Sendable API for AI agents and LLM tools.

Everything an agent needs to send and read WhatsApp messages through Sendable. Machine-readable sources:

  • OpenAPI: https://api.sendable.dev/openapi/json. Every operation has a stable operationId (for example sendMessage, listChatMessages).
  • MCP server: https://api.sendable.dev/mcp (hosted, streamable HTTP) or npx -y @sendable-dev/mcp (stdio). See MCP Server.
  • Docs index: /llms.txt. All docs in one file: /llms-full.txt. Any docs page as Markdown: add .md to its URL (this page is /docs/agents.md).

1. Get a key

Create a session API key in the dashboard (Session > API Keys). It acts on one linked WhatsApp number. Send it on every request:

x-api-key: <your session key>

401 means the key is missing, invalid, disabled, or expired. Do not retry a 401. Give agent keys only the permissions they need, for example the Send only set (message:write, media:write, chats:read, contacts:read); a missing permission returns 403 with "error": "insufficient_scope" and the required permission.

2. Send a message

curl https://api.sendable.dev/v1/message/send \
  -H "x-api-key: $SENDABLE_API_KEY" \
  -H "content-type: application/json" \
  -H "Idempotency-Key: order-123-notify" \
  -d '{ "chatId": "[email protected]", "text": { "content": "Your order has shipped" } }'
  • chatId is a full jid: <phone>@s.whatsapp.net for people, <id>@g.us for groups.
  • The response has messageId. With "async": true the send is queued and the 202 response has a runId for GET /v1/message/delivery-status/{runId}.
  • Always send an Idempotency-Key (1-128 printable characters, unique per logical message). Retrying with the same key and body returns the first response with Idempotent-Replayed: true and never sends twice. The same key with a different body returns 422; a retry while the first request still runs returns 409.

3. Read messages

curl "https://api.sendable.dev/v1/chats?limit=20" -H "x-api-key: $SENDABLE_API_KEY"
curl "https://api.sendable.dev/v1/chats/6281234567890%40s.whatsapp.net/messages?limit=20" \
  -H "x-api-key: $SENDABLE_API_KEY"

Lists return { data, nextCursor }; pass nextCursor back as cursor. URL-encode jids in paths.

4. Get new events

  • Webhooks (push): register a URL with POST /webhooks and verify signatures. See Webhooks.
  • Polling (pull): GET /v1/events?type=message.created&limit=50 returns events newest first (incoming and outgoing messages). Poll the first page and stop at the last event id you processed.

5. Limits and errors

  • Each key may make 500 requests per hour. Responses carry RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset.
  • On 429, wait Retry-After seconds, then retry. Sends are also paced per number (a gap of a few seconds, optional daily cap and quiet hours). See Rate Limits.
  • JSON errors look like { "error": "<code>", "message": "..." }; some errors are plain text. Retry 429, 502, 503, and 5xx with backoff; fix the request on other 4xx. See Errors.

SDK

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

const sendable = new Sendable({ apiKey: process.env.SENDABLE_API_KEY!, apiKeyScope: 'session' })
await sendable.messages.send(
  { chatId: '[email protected]', text: { content: 'Hello' } },
  { idempotencyKey: 'hello-1' },
)

On this page