/api/v2/template/send for new integrations: it adds template lookup by name, async mode, your own tracking ID, and status webhooks. /template/send is the standard endpoint and stays supported.
Before you start
- An API key from Settings → API Keys & Webhooks. See API Reference.
- A template with Meta status Approved, created for a WhatsApp number that is still connected. Templates in any other status are rejected. See Templates.
- The recipient’s number in international format with the country code and no
+, for example966501234567.
List your templates
GET https://api.trypopcorn.ai/template returns every template in the workspace that has not been deleted, newest first, with the IDs you need for sending.
metaTemplateMetaStatus is APPROVED can be sent. metaTemplateComponents is the template structure as a JSON string, including button texts, which you need for buttonValues.
V2 endpoint (recommended)
POST https://api.trypopcorn.ai/api/v2/template/send
Authenticate with POPCORN-API-KEY: sk-... or Authorization: Bearer sk-.... Send Content-Type: application/json.
Responses
Synchronous (async omitted or false), HTTP 200, after WhatsApp accepted the message:
async: true), HTTP 202, before anything is sent:
202, so a wrong template or number is reported synchronously. A failure at WhatsApp itself is only logged: no error response and no webhook, because tracking starts once WhatsApp accepts the message. Use synchronous mode when you need to know that the send went through.
If the request to WhatsApp fails at the network level (timeout, connection reset, DNS), Popcorn makes up to three attempts with a short backoff before giving up. Error responses from WhatsApp itself are not retried. This applies to both synchronous and async sends.
Errors
Errors use HTTP400, 404, or 500 with this body:
WhatsApp’s own error details are not returned in the response; check the message in the Inbox or your WhatsApp Business account for the reason.
Authentication errors (
401, 403) are listed in API Reference.
Health check
GET https://api.trypopcorn.ai/api/v2/template/health requires the same authentication and returns {"status": "ok", "service": "template-v2-api", "version": "2.0", "timestamp": "..."}. Use it to confirm a key works before going live.
Standard endpoint
POST https://api.trypopcorn.ai/template/send
Authenticate with POPCORN-API-KEY only. This endpoint has no tracking, no webhooks, and no async mode.
200 with {"success": true}.
A send failure also returns HTTP 200, so check success rather than the status code:
error is one of: Template not found, Template is not bound to an active Meta sender, Template sender mapping is no longer active, Template is not approved for sending, No active Meta WhatsApp sender found, Customer cannot receive outbound messages (blocked or unsubscribed), This customer has no WhatsApp delivery identity. Ask them to message you first., or Error sending template message when WhatsApp rejected the request. This endpoint does not retry network failures.
A missing recipientNumber or templateId returns HTTP 400 with {"error": "Request error: recipientNumber is required"}.
Dynamic URL buttons
buttonValues fills URL buttons at send time. Keys must match the button text exactly as defined in the template.
- Parameterized URL (the button URL contains a placeholder, for example
https://example.com/track/{{1}}): pass only the value.{"Track Order": "ORD-4521"}produceshttps://example.com/track/ORD-4521. If you pass a full URL here, only its last path segment is used. - Static URL: pass a complete URL to replace it, for example
{"Visit Website": "https://example.com/offer"}.
What happens after a send
- If the recipient’s number is not yet a customer in your workspace, Popcorn creates one.
- The message appears in the conversation in the Inbox. With
autoPilot: falsethe conversation is taken off Autopilot and placed in Unassigned; withtruethe AI agent connected to the sending number answers the customer’s replies. See Inbox overview. - V2 sends create a tracking record, so status webhooks follow if you configured them.