app2email API Pricing

Documentation

Let an AI agent run your WhatsApp with MCP

Connect Claude, ChatGPT, Cursor or any MCP client to your WhatsApp number, give the agent only the access it needs, and have a person approve big sends before they go out.

In this guide you connect an AI agent (Claude, ChatGPT, Cursor, VS Code, Codex or any other MCP client) to your WhatsApp number through app2email's MCP server. Then you ask in plain words: "send the order_shipped template to John", "summarise today's unanswered chats", "add these numbers to Do Not Call". The agent picks the right tools, shows you what it will do, and does it.

What the customer sees: a normal WhatsApp message from your business. Nothing tells them an agent sent it, and nothing reaches them that you did not allow: a sandbox key sends nothing, and a send to more people than you set waits for a person to approve it.

What you see: in the agent's chat, each tool it calls and what came back. In app2email, every sent message in the Activity Log and the conversation, the agent's key on the API key page, and every error and change in the request log.

How it works

  1. Your MCP client connects to https://api.app2email.com/mcp (Streamable HTTP), signed in with OAuth or with an API key of one number.
  2. The server offers the agent 237 tools. Each one maps to one call of the REST API and is marked read-only or destructive (anything that sends or changes something), so your client can ask you before a destructive one runs.
  3. The key decides what the agent may do: its scopes, its daily cap, its approval threshold, whether it is a sandbox key.
  4. Sends go out on WhatsApp like any API send, with the same checks: the 24 hour window, templates, the Do Not Call list, your plan's limits.

What you need

  • A WhatsApp number connected to app2email, on a paid plan and live. Without a plan every call answers 403 plan_not_allowed; a paused service answers 403 service_not_live. See Getting started.
  • An MCP client: Claude Code, claude.ai, ChatGPT (developer mode), Cursor, VS Code, Codex, or any client that speaks Streamable HTTP.
  • Access to one number, in one of two ways:
    • OAuth sign-in (claude.ai, ChatGPT, Claude Code, VS Code, Cursor): no key to copy. When you connect, you sign in to app2email and choose the WhatsApp number, what the app may do, and whether it is a sandbox. The app then holds a key of that number. It shows on the API key page as "OAuth: <app>" and you revoke it there.
    • An API key from the API key page, sent as Authorization: Bearer YOUR_API_KEY. A key belongs to one number. Give it only the scopes the agent's job needs:
What the agent should doScopes
Read and report: messages, conversations, templates, broadcasts, usage, approvalsmessages:read
Send templates and replies, mark as read, hand a chat to a person, assign, notesmessages:send (plus messages:read to look things up first)
Read and change the Do Not Call listdnc:manage
Save contacts and consentcontacts:manage
Create, edit and delete templates and flowstemplates:manage
Add or change webhookswebhooks:manage
Bookings, Submit-Info, ticketsbookings:manage, submissions:manage, tickets:manage
Everything* (Full access): avoid it for an agent

The Default key (the key made before keys had permissions) has messages:send, messages:read, dnc:manage and webhooks:manage only. A tool the key may not use answers 403 insufficient_scope, with the missing scope in details.required_scope.

Tip

Try it with nothing at stake. A sandbox key (a key with the sandbox flag, made on the API key page, or "sandbox" chosen at the OAuth sign-in) runs every check against your own number and sends nothing to WhatsApp: answers have "sandbox": true and message ids that start with wamid.SANDBOX., and message.status events still follow. With no account at all, the create_sandbox tool of the Management MCP server https://api.app2email.com/mcp/manage gives an agent an instant sandbox key (valid 7 days) for the demo number 12025550100 with pretend customers. The demo number has only the basic calls; any other tool answers 403 not_in_instant_sandbox. Details: Sandbox and Agents.

Warning

A sandbox key only simulates sends. Some changes are real even with a sandbox key: the Do Not Call list, opt-ins, contacts and consent, segments, conversation owner, assignee, status and notes, webhooks, and cancelling a broadcast. The full list is under "real change" on Sandbox.

Connect in four steps

  1. 1. Make a key for the agent (or skip this for OAuth)

    On the API key page, create a key just for the agent and give it a name you will recognise in the logs, eg "Agent". Tick only the scopes from the table above.

    Two settings make a key safe to hand to an agent:

    • An approval threshold (approval_above): a send to more contacts than this number is held until a person approves it. See Held sends.
    • A daily cap: the most messages the key may send per UTC day. Over it, sends answer 429 daily_cap_reached.

    A key can also be limited to some IP addresses (403 ip_not_allowed from anywhere else) and can expire. The key is shown only once. Keep it in an environment variable, not in a prompt or a chat.

  2. 2. Check the key

    GET /me works with any valid key and shows its scopes, caps and limits. The agent's first tool, check_key, makes the same call. In every request, YOUR_NUMBER is the WhatsApp number you send from: country code first, digits only.

    cURL
    curl https://api.app2email.com/v1/YOUR_NUMBER/me \
      -H "Authorization: Bearer $APP2EMAIL_API_KEY"
    Node.js
    const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/me", {
      headers: { Authorization: `Bearer ${process.env.APP2EMAIL_API_KEY}` },
    });
    console.log(await res.json());
    Python
    import os, requests
    
    res = requests.get("https://api.app2email.com/v1/YOUR_NUMBER/me",
                       headers={"Authorization": f"Bearer {os.environ['APP2EMAIL_API_KEY']}"}, timeout=10)
    print(res.json())

    What you get back:

    {
      "success": true,
      "request_id": "a7k3p",
      "key_valid": true,
      "api_version": "v1",
      "number": "4976659348270",
      "plan": "standard_5000",
      "service_status": "LIVE",
      "key": {
        "name": "Agent",
        "scopes": ["messages:read", "messages:send"],
        "ip_allow": "",
        "daily_cap": 200,
        "daily_used": 0,
        "approval_above": 20
      },
      "limits": {
        "max_numbers_per_request": 1000,
        "requests_per_second": 20,
        "burst": 50,
        "rate_limit_mode": "enforce",
        "webhooks_max": 5
      }
    }

    key.daily_cap and key.approval_above are left out when the key has none. A sandbox key also has "sandbox": true.

  3. 3. Add the server to your client

    The URL is the same everywhere: https://api.app2email.com/mcp.

    Claude Code

    With a key (Claude Code MCP docs):

    claude mcp add --transport http app2email https://api.app2email.com/mcp --header "Authorization: Bearer YOUR_API_KEY"

    Claude Code also signs in with OAuth: leave out --header and sign in to app2email when it asks.

    To share the setup with your team, put it in .mcp.json in the project and keep the key in the environment:

    {
      "mcpServers": {
        "app2email": {
          "type": "http",
          "url": "https://api.app2email.com/mcp",
          "headers": {
            "Authorization": "Bearer ${APP2EMAIL_API_KEY}"
          }
        }
      }
    }
    claude.ai

    Customize → Connectors → + Add → Add custom connector (how custom connectors work).

    URL:             https://api.app2email.com/mcp
    Authentication:  OAuth (you sign in to app2email and choose the number)
    
    Or with a key:   Authentication: No sign in
                     Request header: Authorization: Bearer YOUR_API_KEY
    ChatGPT

    Developer mode: add the server as a connector with OAuth. You sign in to app2email and choose the number.

    URL:             https://api.app2email.com/mcp
    Authentication:  OAuth
    Cursor

    ~/.cursor/mcp.json (Cursor MCP docs):

    {
      "mcpServers": {
        "app2email": {
          "url": "https://api.app2email.com/mcp",
          "headers": {
            "Authorization": "Bearer ${env:APP2EMAIL_API_KEY}"
          }
        }
      }
    }
    VS Code

    .vscode/mcp.json (VS Code MCP docs). VS Code asks for the key once and keeps it out of the file:

    {
      "inputs": [
        {
          "type": "promptString",
          "id": "app2email-key",
          "description": "app2email API key",
          "password": true
        }
      ],
      "servers": {
        "app2email": {
          "type": "http",
          "url": "https://api.app2email.com/mcp",
          "headers": {
            "Authorization": "Bearer ${input:app2email-key}"
          }
        }
      }
    }
    Codex

    ~/.codex/config.toml, with APP2EMAIL_API_KEY set in the environment (Codex MCP docs):

    [mcp_servers.app2email]
    url = "https://api.app2email.com/mcp"
    bearer_token_env_var = "APP2EMAIL_API_KEY"
    Any MCP client

    Streamable HTTP at https://api.app2email.com/mcp, protocol versions 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05. Send Authorization: Bearer YOUR_API_KEY, or use OAuth 2.1 with PKCE and dynamic client registration. OAuth metadata: https://api.app2email.com/.well-known/oauth-protected-resource/mcp and https://www.app2email.com/.well-known/oauth-authorization-server.

    For a second number, add a second connection with that number's key (or sign in again and choose the other number).

  4. 4. Test it

    Ask the agent:

    Check my app2email key and list my approved templates.

    It should call check_key, then list_templates, and tell you the key's scopes and limits and each approved template with the values it needs. Both tools are read-only, so nothing is sent.

Smaller tool lists

237 tools is a lot for some clients and for small models. The same server offers smaller sets. Every tool can still be called by name.

SetURLWhat is in it
Messaginghttps://api.app2email.com/mcp/messaging16 everyday tools: send, read, wait for replies, hand over
Conversationshttps://api.app2email.com/mcp/conversations10: conversations, owner, team, assignment, status, notes
Templateshttps://api.app2email.com/mcp/templates15: list, create, edit, delete, insights
Broadcastshttps://api.app2email.com/mcp/broadcasts8: list, report, cancel, retarget, retry
Do Not Callhttps://api.app2email.com/mcp/do-not-call4: list, add, remove
Approvalshttps://api.app2email.com/mcp/approvals3: list and approve held sends
Search, then callhttps://api.app2email.com/mcp/search2: find_tools and call_tool, for clients with a small tool limit

Several sets at once: https://api.app2email.com/mcp?tools=messaging,do-not-call. Every set is listed on MCP.

The tools the agent gets

These are the tools most agents use. Every tool, with what it does, is on MCP.

PurposeToolsKindScope
Check the key and the plancheck_key, get_usage, get_number_healthread-onlyany key / messages:read
Read chatslist_conversations, get_conversation, get_conversation_messages, list_messages, get_messageread-onlymessages:read
Wait for new messageswait_for_message, list_eventsread-onlymessages:read
Templateslist_templates, get_templateread-onlymessages:read
Sendsend_template, send_text, send_media, send_interactive, send_message, send_reaction, send_location, mark_readdestructivemessages:send
Hand over and team inboxset_conversation_owner, list_team_members, assign_conversation, set_conversation_status, add_conversation_note, list_conversation_notesmixedmessages:send / messages:read
Broadcastslist_broadcasts, get_broadcast, get_broadcast_clicks, cancel_broadcastmixedmessages:read / messages:send
Do Not Calllist_donotcall, add_donotcall, remove_donotcallmixeddnc:manage
Contacts and consentlist_contacts, upsert_contactmixedmessages:read / contacts:manage
Approvalslist_approvals, approve_sendmixedmessages:read / messages:send
Change templatescreate_template, edit_template, delete_template, archive_templatedestructivetemplates:manage

The server has more for the other parts of app2email: bookings and the calendar, payments, the shop, store messages, tickets, Submit-Info forms, Flows, AI answers, chat automations, drip sequences, the business profile and QR codes, webhooks and setup files.

What you can ask, and what the agent does

Send the order_shipped template to +44 7700 900123 for John, order #1234
  1. get_template with order_shipped: is it approved, which language, which values it needs.
  2. send_template with dry_run true: everything is checked (template values, the number, the Do Not Call list, your monthly limit) and the exact message comes back. Nothing is sent.
  3. The agent shows you the message and asks. Your client can also ask you before any destructive tool runs.
  4. send_template again without dry_run, with an idempotency_key, so a retry cannot send it twice.
  5. get_message with the message_id: sent, delivered, read, or failed with a reason.

The tool makes the same request as POST /messages. The number is written with its country code, digits only:

{
  "to": "447700900123",
  "type": "template",
  "template": {
    "name": "order_shipped",
    "language": { "code": "en" },
    "components": [
      { "type": "body", "parameters": [
        { "type": "text", "text": "John" },
        { "type": "text", "text": "#1234" }
      ] }
    ]
  },
  "dry_run": true
}

The real send answers like this:

{
  "success": true,
  "request_id": "kxrkf",
  "message_id": "wamid.HBgLNjE0MTIzNDU2NzgVAgARGBJTQU1QTEVfVEVTVF9FVkVOVAA=",
  "status": "accepted",
  "from": "4976659348270",
  "to": "447700900123",
  "template": { "name": "order_shipped", "language": "en", "category": "UTILITY" },
  "text": "Hi John, your order #1234 has shipped.",
  "conversation_url": "https://www.app2email.com/conversation/447700900123_4976659348270_..."
}

On WhatsApp: John gets the template from your business name. In app2email the message shows in the Activity Log and in John's conversation, with its ticks.

Summarise today's unanswered chats
  1. list_conversations with since set to the start of today: one entry per contact who was active today, with last_inbound, last_outbound and window_open.
  2. The agent keeps the contacts whose last_inbound is later than last_outbound: they wrote last and nobody answered.
  3. get_conversation_messages for each of them, then a short summary per customer: who, what they want, how long they have waited.
{
  "success": true,
  "request_id": "q2lzd",
  "conversations": [
    {
      "contact": "61412345678",
      "name": "John",
      "last_inbound": "2026-10-26T01:20:44Z",
      "last_outbound": "2026-10-26T01:12:09Z",
      "window_open": true,
      "messages": 12,
      "conversation_url": "https://www.app2email.com/conversation/61412345678_4976659348270_..."
    }
  ],
  "next_cursor": null,
  "count": 1
}

Every tool here is read-only, so a key with messages:read alone is enough. window_open tells you who can still get a free-form reply; the others need a template.

Add these numbers to Do Not Call: 61412345678, 61498765432
  1. add_donotcall with the numbers, and a name and a note each if you give them. Up to 1000 numbers. All or nothing: one invalid number (400 invalid_numbers, listed in details.invalid) and nothing is added. Numbers already on the list stay as they are.
  2. list_donotcall with one number, to show you it is on the list.

The key needs dnc:manage. This is a real change even with a sandbox key. From then on, marketing templates are not sent to these numbers, and a broadcast reports them as skipped_do_not_call.

John wants to talk to a person: hand him to Sarah
  1. get_conversation for John: owner, window_state and window_closes_at.
  2. set_conversation_owner with owner human, a short reason and a summary of the chat. app2email's auto reply and other agents then leave John alone, and conversation.owner_changed is sent.
  3. list_team_members, then assign_conversation to Sarah, and add_conversation_note with anything she should know (the team sees notes, John never does).

A good agent does not take a chat back that a person took, unless you ask it to. More in Hand a chat from your bot to a person and back.

Send the november_offer template to the VIP segment
  1. send_template with segment and dry_run true: how many contacts, and the message each one gets.
  2. The real send. If the key has an approval threshold below the number of contacts, the send is held: the agent gets pending_approval and a link, and tells you. See the next section.
  3. Once a person approves, the messages go out. get_broadcast shows the result per number.

A marketing template only goes to contacts who agreed to it. See Send a marketing broadcast that respects opt-ins.

Held sends: a person approves first

Give the agent's key an approval threshold (approval_above) on the API key page. Any send to more contacts than that is held instead of sent, so the agent can send one-to-one replies on its own but a big send waits for a person. A held send expires 48 hours after it was held.

What the agent gets back is HTTP 202 with status pending_approval. It is not an error: the agent should tell you and not try another way.

{
  "success": true,
  "request_id": "p3kdm",
  "status": "pending_approval",
  "approval": {
    "id": "apr_a1b2c3d4e5f6g7h8",
    "url": "https://www.app2email.com/dashboard/approvals?id=apr_a1b2c3d4e5f6g7h8",
    "expires": "2026-11-04T01:12:09Z",
    "recipients": 250,
    "key": "Agent"
  }
}

A person approves or rejects it on the dashboard page in approval.url. Your own systems can also do it with another key: POST /approvals/{id}/approve sends it now (the Do Not Call list, the limits and the daily cap are checked again) and POST /approvals/{id}/reject drops it. Approving needs messages:send and a key that is not a sandbox key. The agent's approve_send tool needs a key without an approval threshold, so an agent cannot approve its own held sends.

cURL
# What is waiting
curl https://api.app2email.com/v1/YOUR_NUMBER/approvals \
  -H "Authorization: Bearer $MANAGER_KEY"

# Approve one (this sends the messages)
curl -X POST https://api.app2email.com/v1/YOUR_NUMBER/approvals/apr_a1b2c3d4e5f6g7h8/approve \
  -H "Authorization: Bearer $MANAGER_KEY"
Node.js
const base = "https://api.app2email.com/v1/YOUR_NUMBER";
const headers = { Authorization: `Bearer ${process.env.MANAGER_KEY}` };

const { approvals } = await (await fetch(`${base}/approvals`, { headers })).json();
for (const a of approvals) {
  console.log(a.id, a.key, a.recipients, a.summary?.template?.name, a.url);
}

// After a person said yes:
// await fetch(`${base}/approvals/${id}/approve`, { method: "POST", headers });
Python
import os, requests

base = "https://api.app2email.com/v1/YOUR_NUMBER"
headers = {"Authorization": f"Bearer {os.environ['MANAGER_KEY']}"}

approvals = requests.get(f"{base}/approvals", headers=headers, timeout=10).json()["approvals"]
for a in approvals:
    print(a["id"], a["key"], a["recipients"], a["summary"].get("template", {}).get("name"), a["url"])

# After a person said yes:
# requests.post(f"{base}/approvals/{approval_id}/approve", headers=headers, timeout=60)

What you get back from GET /approvals (pending ones by default; ?status=all adds the resolved and expired ones of the last 7 days):

{
  "success": true,
  "request_id": "a4lxc",
  "approvals": [
    {
      "id": "apr_a1b2c3d4e5f6g7h8",
      "status": "pending",
      "created": "2026-11-02T01:12:09Z",
      "expires": "2026-11-04T01:12:09Z",
      "key": "Agent",
      "request_id": "p3kdm",
      "recipients": 250,
      "summary": {
        "recipients": 250,
        "to_send": 248,
        "template": { "name": "november_offer", "language": "en", "category": "MARKETING" },
        "text": "Hi {{first_name}}, ..."
      },
      "url": "https://www.app2email.com/dashboard/approvals?id=apr_a1b2c3d4e5f6g7h8",
      "approve_url": "https://api.app2email.com/v1/4976659348270/approvals/apr_a1b2c3d4e5f6g7h8/approve"
    }
  ],
  "count": 1
}

The events

If you have a webhook (POST /webhooks with your https url, or on the API key page under Webhooks), two events tell you about held sends, for example to ping a manager in your team chat. message.held_for_approval when a send is held:

{
  "id": "evt_Xq3k9m2Lw8Rt5Yp1Zs01",
  "type": "message.held_for_approval",
  "created": "2026-11-06T01:00:00.000Z",
  "number": "4976659348270",
  "data": {
    "approval_id": "apr_a1b2c3d4e5f6g7h8",
    "url": "https://www.app2email.com/dashboard/approvals?id=apr_a1b2c3d4e5f6g7h8",
    "approve_url": "https://api.app2email.com/v1/4976659348270/approvals/apr_a1b2c3d4e5f6g7h8/approve",
    "recipients": 250,
    "key": "Agent key",
    "summary": { "type": "template", "template": "order_update", "to": 250 },
    "expires": "2026-11-08T01:00:00.000Z",
    "timestamp": "2026-11-06T01:00:00.000Z"
  }
}

And approval.resolved when it was approved (and sent), rejected or expired:

{
  "id": "evt_Xq3k9m2Lw8Rt5Yp1Zs01",
  "type": "approval.resolved",
  "created": "2026-11-06T01:00:00.000Z",
  "number": "4976659348270",
  "data": {
    "approval_id": "apr_a1b2c3d4e5f6g7h8",
    "status": "approved",
    "resolved_by": "dashboard",
    "result": {
      "http_status": 202,
      "status": "accepted",
      "accepted": 250,
      "failed": 0,
      "broadcast_code": "k3XbQ9rTzP2mWv7a1c9e"
    },
    "timestamp": "2026-11-06T01:00:00.000Z"
  }
}

The messages themselves then report their progress as message.status events (sent, delivered, read, failed), like any send. Every event, with its payload: Webhooks.

See what the agent did

  • The API key page lists the agent's key, or "OAuth: <app>" for a client that signed in. Revoke it there to cut the agent off.
  • The Activity Log and the Inbox show every message the agent sent, with its status, in the conversation it belongs to. A list or segment send also shows under Broadcasts, with its report.
  • The request log keeps every error (status 400 and up) and every request that changed something (sends, webhook and settings changes) for 30 days, with the key's name. No bodies and no keys are stored. It is not one of the agent's tools: you read it yourself, with a key that has messages:read.
cURL
# The latest errors
curl "https://api.app2email.com/v1/YOUR_NUMBER/requests?status=error&limit=50" \
  -H "Authorization: Bearer $APP2EMAIL_API_KEY"

# One request, by the request_id the agent quoted
curl https://api.app2email.com/v1/YOUR_NUMBER/requests/kxrkf \
  -H "Authorization: Bearer $APP2EMAIL_API_KEY"
Node.js
const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/requests?status=error&limit=50", {
  headers: { Authorization: `Bearer ${process.env.APP2EMAIL_API_KEY}` },
});
const { requests } = await res.json();
for (const r of requests.filter((r) => r.key === "Agent")) {
  console.log(r.time, r.method, r.route, r.status, r.request_id);
}
Python
import os, requests

res = requests.get("https://api.app2email.com/v1/YOUR_NUMBER/requests",
                   params={"status": "error", "limit": 50},
                   headers={"Authorization": f"Bearer {os.environ['APP2EMAIL_API_KEY']}"}, timeout=10)
for r in res.json()["requests"]:
    if r["key"] == "Agent":
        print(r["time"], r["method"], r["route"], r["status"], r["request_id"])

What you get back:

{
  "success": true,
  "request_id": "x9d2m",
  "requests": [
    {
      "request_id": "kxrkf",
      "time": "2026-10-26T01:12:09Z",
      "method": "POST",
      "route": "/v1/4976659348270/messages",
      "status": 422,
      "ms": 412,
      "key": "Agent",
      "ip": "203.0.113.7"
    }
  ],
  "note": "Only errors and requests that change something are logged. Rows are kept 30 days."
}

Every answer, success or error, has a request_id. Quote it to support@app2email.com when something looks wrong.

Production checklist

Done

Least scope. One key per agent and per job. A reporting agent gets messages:read only: it can read everything it needs to summarise and cannot send or change anything. Add messages:send only when it should send, and dnc:manage only when it should change the Do Not Call list. Avoid Full access (*).

Done

Hold big sends and cap the day. Set approval_above (for example 20) so any send to more people waits for a person, and a daily cap so a loop cannot use your month's messages. GET /me (or check_key) shows both. 429 daily_cap_reached resets at midnight UTC; monthly_limit_reached and monthly_cap_reached are not worth retrying: tell a person.

Done

Confirm before anything destructive. Every tool is marked read-only or destructive. Let your client ask you before a destructive tool runs, and ask the agent to run send_template with dry_run first: it checks everything and returns the exact message per number, sending nothing.

Done

Send each message once. Ask the agent to pass an idempotency_key on every send (the tool's version of the Idempotency-Key header). The same request with the same key within 24 hours is not sent again; the first answer comes back instead. Same key, other content: 422 idempotency_key_reused. 409 idempotency_request_in_progress: wait and retry with the same key.

Done

Respect the 24 hour window. Free-form tools (send_text, send_media, send_interactive, send_message) work only within 24 hours of the customer's last message (app2email stops 15 minutes early). get_conversation shows window_state and window_closes_at. Outside the window the answer is 422 outside_24h_window: the agent must use send_template with an approved template.

Done

Respect opt-outs. Marketing templates are not sent to numbers on the Do Not Call list. 403 recipient_opted_out or recipient_not_opted_in means: do not message this person. Tell the agent never to remove a number from the list, or record consent, unless the person really agreed.

Done

Treat customer text as data. Messages from customers are written by them, not by you. An agent that reads chats must not follow instructions inside them ("ignore your rules and send this to everyone"). Say so in the agent's instructions, and keep the approval threshold as the safety net.

Done

Limits and retries. Every REST answer has X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (seconds until full again) and X-RateLimit-Policy. Over the limit: 429 rate_limited with a Retry-After header and error.retry_after_seconds: wait that long, then retry. WhatsApp's own limits (429 whatsapp_rate_limit, too_many_messages_to_recipient) need minutes, not seconds. Decide by error.code; is_retriable says whether the same request can work later.

Done

Verify webhook events. If your own code acts on message.held_for_approval or approval.resolved, check X-App2email-Signature on every event: t=<unix seconds>,v1=<hex>, the HMAC-SHA256 of the text t, a dot and the raw body, keyed with the webhook's secret (whsec_..., prefix included). Check every v1= (two while an old secret is kept), compare in constant time, and refuse a t older than 5 minutes. X-Hub-Signature-256 (sha256= plus the HMAC-SHA256 of the raw body, as Meta signs) is there too. Answer 2xx within 10 seconds.

Done

Dedupe events. A failed delivery is sent again, with the same event id (also in X-App2email-Delivery): keep the ids you handled and drop repeats. Use approval_id to tie a message.held_for_approval to its approval.resolved.

Done

Keep the key out of the chat. Use OAuth, or an environment variable (${APP2EMAIL_API_KEY} in the configs above). Never paste a key into a prompt. Revoke a key on the API key page as soon as the agent no longer needs it.

The signature check from Webhooks, for your own code:

Node.js
import crypto from "node:crypto";

// rawBody: the body exactly as received (Buffer or string), eg express.raw({ type: "application/json" })
export function verifyWebhook(rawBody, header, secret, toleranceSeconds = 300) {
  const t = /(?:^|,)\s*t=(\d+)/.exec(header ?? "")?.[1];
  const v1 = [...(header ?? "").matchAll(/(?:^|,)\s*v1=([0-9a-f]+)/g)].map((m) => m[1]);  // every v1=: two while an old secret is kept
  if (!t || v1.length === 0 || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;
  const expected = crypto.createHmac("sha256", secret).update(t + ".").update(rawBody).digest("hex");
  return v1.some((v) => v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
}

// const ok = verifyWebhook(req.body, req.get("X-App2email-Signature"), process.env.WEBHOOK_SECRET);
Python
import hashlib, hmac, re, time

def verify_webhook(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    t = re.search(r"(?:^|,)\s*t=(\d+)", header or "")
    v1 = re.findall(r"(?:^|,)\s*v1=([0-9a-f]+)", header or "")  # every v1=: two while an old secret is kept
    if not t or not v1 or abs(time.time() - int(t.group(1))) > tolerance:
        return False
    expected = hmac.new(secret.encode(), t.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(v, expected) for v in v1)

# ok = verify_webhook(request.get_data(), request.headers.get("X-App2email-Signature"), WEBHOOK_SECRET)

If it does not work

What you seeWhyFix
The client shows no app2email toolsThe connection did not sign inCheck the URL https://api.app2email.com/mcp and the header Authorization: Bearer YOUR_API_KEY, or sign in again with OAuth
The client is slow, or says it has too many tools237 tools is more than it handles wellConnect https://api.app2email.com/mcp/messaging, a few sets with ?tools=, or https://api.app2email.com/mcp/search
401 missing_api_key, invalid_authorization_header, invalid_api_keyNo key, a mistyped header, or a wrong keySend Authorization: Bearer YOUR_API_KEY with a key listed on the API key page
401 api_key_revoked, api_key_expiredThe key was revoked, replaced or ran outMake a new key, or sign in again with OAuth
403 api_key_number_mismatchA normal key used on the demo number 12025550100Use your key with your own number, or an instant sandbox key on the demo number
403 insufficient_scopeThe key lacks the scope in details.required_scopeMake a key with that scope, or sign in again and allow more
403 ip_not_allowedThe key is limited to some addresses, and the client runs elsewhereAdd the address on the API key page; hosted clients such as claude.ai and ChatGPT call from their own servers
403 plan_not_allowed, service_not_liveNo paid plan, or the service is pausedChoose a plan; a paused service goes live with "Go Live" on the Settings page
403 sandbox_keyA sandbox key cannot do this (templates, settings, approvals)Use a normal key for that job
403 not_in_instant_sandboxThe demo number does not have this toolUse a sandbox key on your own number
202 pending_approvalThe send went over the key's approval_aboveApprove it at approval.url, or lower the size of the send
409 approval_expired, approval_already_resolvedIt was held more than 48 hours, or someone already decidedSend the request again (it is held again), or nothing to do
404 approval_not_foundWrong id, or resolved more than 7 days agolist_approvals (or GET /approvals?status=all) lists them
422 outside_24h_windowThe customer last wrote more than 24 hours agoSend an approved template with send_template
404 template_not_found, 422 template_not_approved, template_parameters_invalidWrong name or language, not approved yet, or wrong valueslist_templates shows each approved template and a complete example_request
403 recipient_opted_out, recipient_not_opted_inThe person opted out, or has no opt-in record for marketingDo not message them. With recipient_not_opted_in, utility templates can still be sent
400 invalid_numbersOne of the numbers for Do Not Call is not valid (details.invalid); nothing was addedCountry code first, digits only, eg 447700900123
429 rate_limitedToo many calls for this keyWait Retry-After seconds, then retry
429 daily_cap_reachedThe key's daily cap is usedWait until midnight UTC, or raise the cap on the API key page
429 monthly_limit_reached, monthly_cap_reachedThe plan's messages, or your own monthly cap, are usedWait for the next billing month, upgrade, or raise the cap
404 request_not_foundThe request was not logged (only errors and changes are), or is older than 30 daysUse the request_id of a failed or changing request
503 request_log_unavailableThe request log is not available right nowTry again later

For agents that find you on their own

More how-to guides

All how-to guides