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 stableoperationId(for examplesendMessage,listChatMessages). - MCP server:
https://api.sendable.dev/mcp(hosted, streamable HTTP) ornpx -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.mdto 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" } }'chatIdis a full jid:<phone>@s.whatsapp.netfor people,<id>@g.usfor groups.- The response has
messageId. With"async": truethe send is queued and the202response has arunIdforGET /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 withIdempotent-Replayed: trueand never sends twice. The same key with a different body returns422; a retry while the first request still runs returns409.
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 /webhooksand verify signatures. See Webhooks. - Polling (pull):
GET /v1/events?type=message.created&limit=50returns events newest first (incoming and outgoing messages). Poll the first page and stop at the last eventidyou processed.
5. Limits and errors
- Each key may make 500 requests per hour. Responses carry
RateLimit-Limit,RateLimit-Remaining, andRateLimit-Reset. - On
429, waitRetry-Afterseconds, 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. Retry429,502,503, and5xxwith backoff; fix the request on other4xx. 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' },
)