MCP server
Connect an AI assistant (Cursor, Claude, or any MCP client) to your Whitelabel WhatsApp Cloud API tenant and let it send and read WhatsApp messages through 5 tools.
Whitelabel WhatsApp Cloud API runs a remote Model Context Protocol (MCP) server on top of the same Cloud API you use over HTTP. It uses the same send path, the same policy checks, and the same tenant API key.
MCP is an assistant surface. It is not the integration contract: backends should keep using the HTTP API (Send messages).
Endpoint
| URL | https://wa.vitral.dev/mcp (also https://wa.vitral.dev/api/v1/mcp) |
| Transport | Streamable HTTP (GET, POST, DELETE) |
| Auth | Authorization: Bearer YOUR_TENANT_API_KEY |
| Rate limits | Same per-key limits as the HTTP API (Rate limits) |
Authentication
Use a tenant API key, the same kind of key as the HTTP API (Authentication). The raw key is shown once when it is created.
- A missing or invalid
Authorization: Bearerheader returns HTTP401before any MCP traffic. A revoked or expired key is also401. - Each tool checks the same scope as the matching REST route. A key without that scope gets a tool error with code
FORBIDDEN(Missing required scope: <scope>), and nothing is sent.
| Tool | Scope |
|---|---|
send_message |
messages:send |
send_template |
messages:send |
request_approval |
messages:send |
get_new_messages |
messages:read |
get_contact_status |
conversations:read |
The partner key preset includes all three scopes.
One key acts on every phone number in the tenant. On the send tools, request_approval, and get_contact_status, phoneNumberId is optional when the tenant has exactly one active phone number; with more than one, pass it or the call fails. get_new_messages works differently (see below).
Connect
Replace YOUR_TENANT_API_KEY with your key. Do not commit the key to a repository.
Cursor
~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):
{
"mcpServers": {
"vitral-whatsapp": {
"url": "https://wa.vitral.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_TENANT_API_KEY"
}
}
}
}Claude Code
claude mcp add --transport http vitral-whatsapp https://wa.vitral.dev/mcp \
--header "Authorization: Bearer YOUR_TENANT_API_KEY"Claude Desktop
Claude Desktop's config file launches local servers, so bridge the remote server with mcp-remote (requires Node.js). In claude_desktop_config.json:
{
"mcpServers": {
"vitral-whatsapp": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://wa.vitral.dev/mcp",
"--header",
"Authorization:${VITRAL_WHATSAPP_AUTH}"
],
"env": {
"VITRAL_WHATSAPP_AUTH": "Bearer YOUR_TENANT_API_KEY"
}
}
}
}Restart Claude Desktop after editing the file.
Policy (fails closed)
- Opt-in. A contact counts as opted in only if they have messaged your number, or the contact's
metadata.optedInistrue(set it after you collect consent). - 24-hour window.
send_messagealso needs an open customer service window: the contact messaged you in the last 24 hours. Outside the window, send an approved template. - Approved templates only.
send_templatesends only templates stored in Whitelabel WhatsApp Cloud API for that phone number's WhatsApp Business Account with statusAPPROVED. Unknown, pending, and rejected templates are refused before anything is queued. Sync templates first (Templates). - Marketing templates also require opt-in. Utility and authentication templates do not.
Tools
Every tool returns its result as JSON in a single text content block.
send_message
Send a free-form text message. Refused unless the contact is opted in and the 24-hour window is open.
| Param | Type | Required | Notes |
|---|---|---|---|
to |
string | yes | Recipient phone number or WhatsApp id |
text |
string | yes | Plain-text body |
phoneNumberId |
string | no | Required if the tenant has more than one active number |
previewUrl |
boolean | no | Whether WhatsApp renders URL previews |
Returns the queued message: id, phoneNumberId, conversationId, contactId, type, status, createdAt.
Errors: CONTACT_NOT_OPTED_IN, SERVICE_WINDOW_CLOSED (details include windowExpiresAt).
send_template
Send an approved template.
| Param | Type | Required | Notes |
|---|---|---|---|
to |
string | yes | Recipient phone number or WhatsApp id |
name |
string | yes | Template name |
language |
string | yes | Template language code, e.g. en or es |
phoneNumberId |
string | no | Required if the tenant has more than one active number |
components |
array of objects | no | Meta template components (header, body, and button parameters) |
Returns the queued message, same shape as send_message.
Errors: TEMPLATE_NOT_FOUND (no matching template for that number's WhatsApp Business Account), TEMPLATE_NOT_ALLOWED (status is not APPROVED; details include status), CONTACT_NOT_OPTED_IN (marketing templates only).
get_new_messages
Read inbound messages Whitelabel WhatsApp Cloud API has already stored from webhooks. It does not read WhatsApp directly. Messages are returned oldest first.
| Param | Type | Required | Notes |
|---|---|---|---|
phoneNumberId |
string | no | Only this number. Omit to read every number in the tenant |
contact |
string | no | Only messages from this phone number or WhatsApp id. Requires phoneNumberId, even with one active number |
since |
string | no | ISO-8601 timestamp. Messages created at or after this time |
cursor |
string | no | nextCursor from a previous call. Takes precedence over since |
limit |
integer | no | 1 to 50, default 20 |
Returns { "messages": [...], "nextCursor": "..." }. Each message has id, phoneNumberId, conversationId, contact (id, waId, name, phoneNumber, or null), type, status, body, and createdAt. nextCursor is null when there are no more messages. To poll, keep the last nextCursor you received, or use since.
Errors: VALIDATION_ERROR for a malformed since or cursor, or contact without phoneNumberId.
request_approval
Ask the tenant owner a Yes/No question on WhatsApp, then read the answer.
| Param | Type | Required | Notes |
|---|---|---|---|
prompt |
string | to create | The question. Up to 900 characters are sent |
owner |
string | no | Owner WhatsApp number. Defaults to the owner number configured on your tenant |
phoneNumberId |
string | no | Number that sends the prompt. Required if the tenant has more than one active number |
approvalId |
string | to read | Id from an earlier call. Returns the current state and sends nothing |
How it works:
- Call with
prompt. Whitelabel WhatsApp Cloud API sends the owner an interactive message with Yes and No buttons and returns a pending approval. - The owner taps a button, or replies with exactly
yes,y,si,sí,no, orn. A text reply resolves the owner's newest pending approval on that number. - Call again with
approvalIdto read the decision.
The owner must have an open 24-hour window with the sending number: they message the business number first. Approvals expire 24 hours after they are created.
Returns approvalId, status (PENDING, APPROVED, DENIED, or EXPIRED), prompt, ownerWaId, decided, approved (true, false, or null), expiresAt, resolvedAt, and messageId.
Errors: OWNER_NOT_CONFIGURED (no owner passed and none configured on the tenant), SERVICE_WINDOW_CLOSED (the owner's window is closed), VALIDATION_ERROR (no prompt when creating), NOT_FOUND (unknown approvalId).
get_contact_status
Check opt-in and the 24-hour window for a contact before sending. Read-only, from Whitelabel WhatsApp Cloud API data.
| Param | Type | Required | Notes |
|---|---|---|---|
to |
string | yes | Contact phone number or WhatsApp id |
phoneNumberId |
string | no | Required if the tenant has more than one active number |
Returns exists, waId, contactId, conversationId, optedIn, optInSource (inbound_message, metadata.optedIn, or null), windowOpen, windowExpiresAt, lastInboundCustomerMsgAt, name, and phoneNumber.
Errors
A failed tool call returns a normal MCP result with isError: true. The text is JSON:
{
"code": "SERVICE_WINDOW_CLOSED",
"message": "Customer service window is closed. Send an approved template to re-open the conversation.",
"details": { "to": "5215512345678", "optedIn": true, "windowOpen": false }
}| Code | When |
|---|---|
CONTACT_NOT_OPTED_IN |
The contact never messaged you and metadata.optedIn is not true |
SERVICE_WINDOW_CLOSED |
No inbound message from the contact (or owner) in the last 24 hours |
TEMPLATE_NOT_FOUND |
No stored template with that name and language for the number's WhatsApp Business Account |
TEMPLATE_NOT_ALLOWED |
The template exists but is not APPROVED |
OWNER_NOT_CONFIGURED |
request_approval has no owner number |
FORBIDDEN |
The key lacks the tool's scope |
NOT_FOUND |
Unknown phoneNumberId or approvalId |
VALIDATION_ERROR |
Bad input: inactive or missing phone number, phoneNumberId needed, malformed since or cursor |
Errors from the shared send path (for example billing or credit errors) come back the same way with their HTTP API codes (Errors).