Developers
WhatsApp API
Connect your CRM or app to the WhatsApp numbers in your Invytra workspace. Send templates, replies and files, read chat history, and get every incoming message, outgoing message and status update by webhook. Invytra keeps working as normal: everything sent through the API shows in the Invytra inbox, and replies typed in Invytra reach your app too.
Included in the Growth and VIP plans at no extra cost. Invytra adds no per-message API charge; Meta's own WhatsApp charges apply as usual.
Getting started
- The workspace owner opens Integrations in Invytra and clicks New API key. The key (it starts with
inv_) is shown once: store it on your server. - Send it with every request in the Authorization header. Keys only work for that workspace.
- For incoming messages and status updates, add a webhook on the same page and pick the
whatsapp.message.*events.
curl https://app.invytra.com/api/v1/whatsapp/numbers \ -H "Authorization: Bearer inv_YOUR_KEY"
Base URL: https://app.invytra.com/api/v1. Requests and responses are JSON. Successful responses wrap the result in data. Never put the key in a browser or mobile app; call the API from your server.
WhatsApp rules the API follows
- Templates (approved by Meta) can be sent any time. They are the only way to start a conversation or write after 24 hours of silence.
- Free-form text and files only inside the 24-hour window after the person's last message. Outside it the API answers
WINDOW_CLOSED. - Opt-outs: anyone who replied STOP, or is on the workspace's do-not-contact list, is never messaged (
OPTED_OUT). - Marketing templates need the person's opt-in. When you send to someone new, pass
"contact": { "optIn": true }only if they agreed to WhatsApp messages from you; otherwise only utility/authentication templates go out (NO_CONSENT).
Numbers
GET/whatsapp/numbers
The workspace's WhatsApp numbers. Use a number's id (or its phone) as from when sending.
{ "data": [
{ "id": "cm4x…", "phone": "918012345678", "displayPhone": "+91 80123 45678", "name": "Taxpolis",
"status": "connected", "quality": "green", "messagingTier": "TIER_1K" }
] }Templates
GET/whatsapp/templates?status=approved
Every template with its language, category, status and the variables it needs. Body variables are named "1", "2"… (Meta's {{1}}, {{2}}), a text header's is header, and a link button's is button:0.
{ "data": [
{ "id": "cm5a…", "name": "invoice_ready", "language": "en", "category": "utility", "status": "approved",
"header": { "type": "document" }, "headerMedia": "document",
"body": "Hi {{1}}, your invoice of {{2}} is ready.", "footer": null, "buttons": ["Pay now"],
"variables": [ { "name": "1", "label": "{{1}}" }, { "name": "2", "label": "{{2}}" } ] }
] }Send a message
POST/whatsapp/messages
Returns 201 with the message (its id and Meta's wamid). Delivered/read/failed come later by webhook, or from GET /whatsapp/messages/{id}. Send an Idempotency-Key header (any unique string, up to 100 characters) so a retried request returns the first message instead of sending twice.
A template
curl -X POST https://app.invytra.com/api/v1/whatsapp/messages \
-H "Authorization: Bearer inv_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-8812" \
-d '{
"from": "918012345678",
"to": "919876543210",
"type": "template",
"template": {
"name": "invoice_ready",
"language": "en",
"variables": { "1": "Ravi", "2": "₹4,500" },
"headerMediaUrl": "https://files.example.com/invoice-8812.pdf"
},
"contact": { "firstName": "Ravi" }
}'A text reply (inside the 24-hour window)
{ "to": "919876543210", "type": "text", "text": "Thanks Ravi, we've received the documents.",
"replyTo": "wamid.HBgM…" }A file (inside the 24-hour window)
{ "to": "919876543210", "type": "media",
"media": { "type": "document", "url": "https://files.example.com/receipt.pdf", "fileName": "receipt.pdf", "caption": "Your receipt" } }from(optional): a number's id or phone. Without it, the reply goes from the number the person last wrote to (or the first number).to: the person's number with country code, digits only (a leading + is fine).media.type: image (JPG/PNG, 5 MB), video (MP4, 16 MB), audio (16 MB) or document (PDF and others, 100 MB). The URL must be public https; Meta downloads it.contact(optional): first/last name for someone new, andoptInas described under the rules.
Chat history
GET/whatsapp/messages?phone=919876543210&limit=50
Messages in and out, newest first. Filters: phone, number (a number's id or phone), direction (in/out), since (ISO time, e.g. to catch up after downtime), limit (1–100, default 50). For the next page pass before=<nextBefore> from the previous answer.
{ "data": [ { …message… } ], "nextBefore": "cm6q…" }The message object
{
"id": "cm6q…", "wamid": "wamid.HBgM…", "direction": "in", // in | out
"type": "text", // text, template, image, document, …
"contactPhone": "919876543210",
"number": { "id": "cm4x…", "phone": "918012345678" }, // your business number
"from": "919876543210", "to": "918012345678",
"text": "Please send the invoice", // the text, caption or filled-in template
"template": null, // template name for templates
"media": { "type": "application/pdf", "fileName": "pan.pdf",
"url": "https://app.invytra.com/api/v1/whatsapp/media/cm6q…" }, // or null
"replyTo": null, "status": "received", // out: sent, delivered, read, failed
"error": null, "campaignId": null,
"source": null, // out: INBOX, CAMPAIGN, AUTO_REPLY, API
"sentBy": null, // out: teammate's name, or "API · <key name>"
"contact": { "id": "cm2b…", "name": "Ravi Kumar" },
"timestamps": { "created": "2026-11-27T10:15:00.000Z", "sent": null, "delivered": null, "read": null, "failed": null }
}One message
GET/whatsapp/messages/{id}
By Invytra id or by Meta's wamid. Use it to check a status you missed.
Contact & opt-out
GET/whatsapp/contacts/{phone}
Whether the person opted out, how they gave consent, and windowOpenUntil: until when free-form messages are allowed (null = send a template).
{ "data": { "id": "cm2b…", "phone": "919876543210", "name": "Ravi Kumar", "optedOut": false, "optedOutAt": null,
"consent": { "source": "INBOUND", "at": "2026-11-20T09:00:00.000Z" },
"lastInboundAt": "2026-11-27T10:15:00.000Z", "windowOpenUntil": "2026-11-28T10:15:00.000Z", "lastNumberId": "cm4x…" } }Media files
GET/whatsapp/media/{messageId}
The file of a message (photos, documents, voice notes), with the same API key. The media.url in messages and webhooks points here, so it doesn't expire on its own, but Meta only keeps files for 30 days: download what you need to keep when the webhook arrives.
Webhooks
Add a webhook under Integrations (an https URL on your server) and choose events. Invytra sends a POST with { id, event, createdAt, workspaceId, data }, where data is the message object above.
lead.unsubscribedSomeone unsubscribed from email or replied STOP on WhatsApp.whatsapp.message.receivedAny message someone sends to one of your WhatsApp numbers (text, media, buttons), with the number it came to.whatsapp.message.sentAny message your numbers send: from the inbox, a campaign, an automated reply or the API.whatsapp.message.statusA sent message was delivered, read or failed (with the reason).
- Answer with any 2xx within 10 seconds. Failed calls are retried 6 times (after 1, 5, 30, 120, 360 and 720 minutes); after 20 failures in a row the webhook turns off and the owner sees why.
- Events can arrive more than once or out of order: use the event
idand the messageidto ignore repeats, and the timestamps to order them. - Every call is signed. Check the
Invytra-Signatureheader (t=<unix time>,v1=<hex>) with your webhook's secret instead of allowing IP addresses:
// Node.js (use the raw request body, before JSON parsing)
const [t, v1] = req.headers["invytra-signature"].split(",").map((p) => p.split("=")[1]);
const expected = crypto.createHmac("sha256", process.env.INVYTRA_WEBHOOK_SECRET)
.update(`${t}.${rawBody}`).digest("hex");
const ok = crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))
&& Date.now() / 1000 - Number(t) < 300; // sent in the last 5 minutesMissed something while your server was down? Fetch it with GET /whatsapp/messages?since=….
Errors & limits
{ "error": { "code": "WINDOW_CLOSED", "message": "It's been more than 24 hours since their last message, so WhatsApp only allows a template now." } }| HTTP | code | Meaning |
|---|---|---|
| 400 | INVALID | A field is missing or wrong (the message says which). |
| 401 | UNAUTHORIZED | No key, a wrong key, or a revoked key. |
| 403 | PLAN | The workspace isn't on Growth or VIP any more. |
| 404 | NUMBER_NOT_FOUND · TEMPLATE_NOT_FOUND · NOT_FOUND | Nothing with that id/name in this workspace. |
| 409 | OPTED_OUT · NUMBER_NOT_CONNECTED | They opted out, or the number needs reconnecting in Invytra. |
| 422 | WINDOW_CLOSED · NO_CONSENT | Use a template / needs opt-in for marketing templates. |
| 429 | RATE_LIMITED | Slow down; the Retry-After header says how many seconds. |
| 502 | SEND_FAILED | Meta refused the message; the message explains why. |
| 503 | NOT_SET_UP | WhatsApp isn't available on the server right now. |
- Per API key: 600 requests and 120 sends a minute. Meta also limits how many new people a number can message per day (its messaging tier, shown in
/whatsapp/numbers). - Need a test? Make a separate key for testing and send to your own WhatsApp number; revoke it when you're done.
Questions? Write to [email protected]. See also Webhooks and Zapier.