Send your first WhatsApp message by API
With the Replifier WhatsApp API, your system (an ERP, your own store, an app) sends messages from the number you already connected, without dealing with Meta. This guide takes you from zero to your first message sent. For the detail of every field, see the send reference; for code you can copy, the examples in curl, Node, PHP and Python.
Before you start
Section titled “Before you start”- A WhatsApp number connected to the brand in Replifier. The identifier of that connection is the
<CONNECTION>in the routes below. - A template approved by Meta. Messages that are not templates can only be sent when the recipient wrote to you in the last 24 hours.
- An API key with the
whatsapp.sendpermission. It is a separate permission: a key with other permissions cannot send WhatsApp. If the key belongs to a brand, it can only use that brand’s numbers; with any other connection it gets 404.
Step by step
Section titled “Step by step”- In the app, create an API key and tick only the
whatsapp.sendpermission. Copy it when you create it, in the formrpf_live_…: Replifier does not show it again. Keep it in an environment variable on your server, never in code or in a mobile app. - Pick a destination number in E.164 format, with a
+sign and country code, for example+14155550123. - Send the template. The request is a
POSTtohttps://api.replifier.com/v1/connections/whatsapp/<CONNECTION>/sendwith your key inAuthorization: Bearerand anIdempotency-Keythat is unique per message:
curl -X POST "https://api.replifier.com/v1/connections/whatsapp/$CONNECTION/send" \ -H "Authorization: Bearer $REPLIFIER_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "to": "+14155550123", "type": "template", "templateName": "order_shipped", "languageCode": "en_US", "components": [ { "type": "body", "parameters": [{ "type": "text", "text": "Ana" }] } ] }'- Check the response. If Meta accepted the message,
okistrueandproviderMessageIdis the message identifier in WhatsApp:
{ "ok": true, "providerMessageId": "wamid.HBgM..." }- When the recipient replies, you have 24 hours to answer with free text, image, document, location, buttons or a list. Same
POST, different body:
curl -X POST "https://api.replifier.com/v1/connections/whatsapp/$CONNECTION/send" \ -H "Authorization: Bearer $REPLIFIER_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "to": "+14155550123", "type": "text", "text": "Thanks! Your order ships today." }'Retry without duplicating
Section titled “Retry without duplicating”With an API key, Idempotency-Key is mandatory: without it the response is 400 with idempotency_key_required. Generate a new key for every message (a UUID works) and, if the request is cut off or you do not know whether it arrived, repeat it with the same key:
- If the first attempt completed, you get the same stored response, with the
Idempotent-Replayed: trueheader, and no other message is sent. - If you use the same key with a different body, or while the first attempt is still running, the response is 409 with
idempotency_conflict. - The key is remembered for 24 hours. A 4xx error response is stored too: after fixing the problem, use a new key.
If something goes wrong
Section titled “If something goes wrong”| What you see | What it means | What to do |
|---|---|---|
422 whatsapp_window_closed |
You tried a message that is not a template and the recipient did not write to you in the last 24 hours. | Send an approved template or wait for them to write. |
422 contact_channel_suppressed |
The recipient opted out of WhatsApp in this brand. | Do not message them on this channel. |
429 whatsapp_rate_limited |
Your key went over 120 messages per minute. | Wait the seconds in Retry-After and retry with the same key. |
429 whatsapp_daily_limit_reached |
The number used up its 24-hour limit, which Meta sets according to its messaging tier. | Wait as long as Retry-After says, or raise the number’s tier in Meta. |
403 api_key_scope |
The key does not have the whatsapp.send permission. |
Create a key with that permission. |
200 with ok: false |
Replifier sent it, but Meta rejected it. providerCode and providerMessage explain why. |
Fix it according to Meta’s message, for example an invalid template or parameters. |
Replifier error codes come in the body as {"error": {"code", "message", "cause", "fix", "requestId"}} and are listed in the error catalog.
Receive notices in your system
Section titled “Receive notices in your system”Replifier notifies your system with signed webhooks. Before trusting any of them, verify its signature: the guide Replifier webhooks and signature verification has the code in Node, PHP and Python.
Done when
Section titled “Done when”Your script sent a template and you received ok: true with a providerMessageId, the message reached the test phone, and repeating the same request with the same idempotency key did not deliver a second message.