Updated on November 24, 2026
A WhatsApp Flows endpoint is an HTTPS server of your own that the Flow calls while the customer fills it in, to fetch data (open time slots, prices, validating a CPF, the Brazilian taxpayer ID) and decide which screen comes next. Every request arrives encrypted: a 128-bit AES key comes wrapped with your 2048-bit RSA public key, the content is encrypted with AES-GCM, and the response goes back encrypted with the same key and the initialization vector flipped. The endpoint also has to answer Meta’s health check ping and reply to everything in under 10 seconds.
This guide picks up where the article WhatsApp Flows: forms inside the conversation leaves off: that one covers the Flow JSON and sending the Flow; here the topic is only the data server, with the key flow, the format of each request, the encryption code in Node.js and what hurts the Flow’s health.
When a Flow needs an endpoint
Meta is straightforward about it: Flows with an endpoint should avoid calling it when it isn’t needed, because every call adds latency for the customer. According to the endpoint implementation documentation, your server receives requests in these cases:
| Trigger in the Flow | What reaches the endpoint | How to avoid it, if not needed |
|---|---|---|
Message sent with flow_action: "data_exchange" | action: "INIT" when the customer opens the Flow | Send the first screen’s data in flow_action_payload.data |
on-click-action with name: "data_exchange" | action: "data_exchange" with the screen’s fields | Use navigate when the next screen is already known |
Screen with refresh_on_back: true | action: "BACK" | Omit refresh_on_back |
Component with on-select-action | Data exchange when the value changes | Don’t define the action |
| Invalid response from you on the previous call | Error notification (data.error) | Validate the payload before responding |
| Meta’s periodic check | action: "ping" | Can’t be avoided: always respond |
Rule of thumb: if the Flow is a fixed form (name, email, reason for contact), it doesn’t need an endpoint. Scheduling with real availability, quotes that depend on customer records and coupon validation are the typical cases where it does.
Setup, step by step
Meta splits the setup into four stages:
- Create a key pair and upload (sign) the public key.
- Deploy an HTTPS server that accepts
POST, with a valid TLS certificate. This certificate is not used to encrypt the payload. - Implement request decryption and response encryption.
- Connect the endpoint to the Flow: set the
data_api_versionin the Flow JSON, configure the endpoint URL and connect a Meta app to the Flow.
1. Generate a 2048-bit RSA key pair
The Flows business encryption guide uses OpenSSL:
openssl genrsa -des3 -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
The first command generates the password-protected private key. The second exports the public key. Keep the private key and its passphrase in a secrets vault, never in the repository.
2. Upload the public key to the phone number
The key is configured per phone number: POST /{PHONE_NUMBER_ID}/whatsapp_business_encryption, with a system user token that has the whatsapp_business_messaging permission. Meta signs the key automatically on upload.
curl -X POST "https://graph.facebook.com/v27.0/$PHONE_NUMBER_ID/whatsapp_business_encryption" \
-H "Authorization: Bearer $META_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "business_public_key=$(cat public.pem)"
A successful response is {"success": true}. To check, send a GET to the same path: the business_public_key_signature_status field returns VALID or MISMATCH.
Three precautions the documentation points out:
- If the account has several phone numbers, upload the key to each of them.
- Upload the key again when you re-register the number and when
public-key-missingalerts or key signature verification alerts show up. - If you serve several businesses, use a dedicated endpoint and key pair for each messaging account.
If the token is still an issue, the walkthrough is in system user in Meta Business.
3. Connect the endpoint to the Flow
According to the Flows API reference, starting with Flow JSON 3.0 the endpoint URL (endpoint_uri) is set through the API or the Flow Builder UI, not inside the JSON. The same update call accepts application_id, the Meta app connected to the Flow. Every Flow with an endpoint needs a connected app:
curl -X POST "https://graph.facebook.com/v27.0/$FLOW_ID" \
-H "Authorization: Bearer $META_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"endpoint_uri": "https://api.yourcompany.com/flows",
"application_id": "YOUR_APP_ID"
}'
Without endpoint_uri, the Flow can’t be sent or published. If the Flow was created in WhatsApp Manager, the app is connected on the “Edit Flow” page.
Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →
How the request arrives and how to respond
Every request body has three base64 fields:
{
"encrypted_flow_data": "<ENCRYPTED_FLOW_DATA>",
"encrypted_aes_key": "<ENCRYPTED_AES_KEY>",
"initial_vector": "<INITIAL_VECTOR>"
}
For data_api_version 3.0, the documentation describes this procedure:
| Step | Algorithm |
|---|---|
| Unwrap the AES key | Base64 → RSA/ECB/OAEPWithSHA-256AndMGF1Padding with the private key (SHA-256 for MGF1 too). Result: a 128-bit key |
| Decrypt the payload | Base64 → AES-GCM with the AES key and the initial_vector. The 128-bit tag is at the end of the bytes |
| Build the response | UTF-8 JSON → AES-GCM with the same key, IV with all bits flipped (XOR 0xFF), empty AAD, 16-byte tag at the end |
| Return it | Everything in base64, in the body, as plain text |
Once decrypted, the data exchange payload looks like this:
{
"version": "3.0",
"action": "data_exchange",
"screen": "AGENDA",
"data": { "data_escolhida": "2026-12-02" },
"flow_token": "ft_7d1c0e9a4b"
}
You generate the flow_token when sending the message, and it works as a session identifier. Meta asks that it not be predictable. For Flows version 7.3 or later with data_api_version 4.0 or later, you also receive flow_token_signature, an HS256 JWT signed with the app secret, which you can validate to confirm the token hasn’t been tampered with.
The possible responses:
| Situation | Response (before encryption) |
|---|---|
| Go to the next screen | {"screen": "HORARIOS", "data": {...}} |
| Invalid input | Same screen, with data.error_message: the customer sees a notice (snackbar) |
| End the Flow | {"screen": "SUCCESS", "data": {"extension_message_response": {"params": {"flow_token": "..."}}}} |
| Error notification received | {"data": {"acknowledged": true}} |
| Health check ping | {"data": {"status": "active"}} |
When you end with SUCCESS, the Flow closes and the Flow response message is sent to the conversation, with the params values passed on to the messages webhook. Meta recommends following up with a summary message to the customer.
Full example in Node.js
The code below uses Express and the built-in crypto module. It validates the signature, decrypts, routes by action and encrypts the response. Meta also maintains a sample Node.js server in the WhatsApp-Flows-Tools repository.
import express from "express";
import crypto from "node:crypto";
const APP_SECRET = process.env.META_APP_SECRET;
const PRIVATE_KEY = crypto.createPrivateKey({
key: process.env.FLOWS_PRIVATE_KEY,
passphrase: process.env.FLOWS_PRIVATE_KEY_PASSPHRASE,
});
const TAG_LENGTH = 16;
const app = express();
app.use(express.json({ verify: (req, _res, buf) => { req.rawBody = buf; } }));
function isValidSignature(req) {
const received = Buffer.from(req.get("x-hub-signature-256") || "");
const expected = Buffer.from(
"sha256=" + crypto.createHmac("sha256", APP_SECRET).update(req.rawBody).digest("hex")
);
return received.length === expected.length && crypto.timingSafeEqual(received, expected);
}
function decrypt({ encrypted_aes_key, encrypted_flow_data, initial_vector }) {
const aesKey = crypto.privateDecrypt(
{ key: PRIVATE_KEY, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: "sha256" },
Buffer.from(encrypted_aes_key, "base64")
);
const iv = Buffer.from(initial_vector, "base64");
const data = Buffer.from(encrypted_flow_data, "base64");
const decipher = crypto.createDecipheriv("aes-128-gcm", aesKey, iv);
decipher.setAuthTag(data.subarray(-TAG_LENGTH));
const plain = Buffer.concat([decipher.update(data.subarray(0, -TAG_LENGTH)), decipher.final()]);
return { payload: JSON.parse(plain.toString("utf-8")), aesKey, iv };
}
function encrypt(response, aesKey, iv) {
const flippedIv = Buffer.from(iv.map((byte) => byte ^ 0xff));
const cipher = crypto.createCipheriv("aes-128-gcm", aesKey, flippedIv);
return Buffer.concat([
cipher.update(JSON.stringify(response), "utf-8"),
cipher.final(),
cipher.getAuthTag(),
]).toString("base64");
}
async function availableSlots(date) {
// Query your calendar here. Hardcoded values just for the example.
return [
{ id: `${date}T09:00`, title: "09:00" },
{ id: `${date}T14:30`, title: "14:30" },
];
}
async function handle(p) {
if (p.action === "ping") return { data: { status: "active" } };
if (p.data && p.data.error) {
console.warn("Flow reported an error:", p.data.error, p.data.error_message);
return { data: { acknowledged: true } };
}
if (p.action === "INIT") return { screen: "AGENDA", data: {} };
if (p.action === "data_exchange" && p.screen === "AGENDA") {
const horarios = await availableSlots(p.data.data_escolhida);
if (horarios.length === 0) {
return { screen: "AGENDA", data: { error_message: "No times available that day. Please pick another date." } };
}
return { screen: "HORARIOS", data: { horarios } };
}
if (p.action === "data_exchange" && p.screen === "HORARIOS") {
// Save the booking before ending the Flow.
return {
screen: "SUCCESS",
data: { extension_message_response: { params: { flow_token: p.flow_token, horario: p.data.horario } } },
};
}
return { screen: p.screen || "AGENDA", data: { error_message: "Sorry, we didn't get that. Please try again." } };
}
app.post("/flows", async (req, res) => {
if (!isValidSignature(req)) return res.sendStatus(432);
let ctx;
try {
ctx = decrypt(req.body);
} catch {
return res.sendStatus(421);
}
const response = await handle(ctx.payload);
res.type("text/plain").send(encrypt(response, ctx.aesKey, ctx.iv));
});
app.listen(3000);
Things that often go wrong:
- Raw body. The
X-Hub-Signature-256signature is computed over the exact bytes of the body. If your framework rewrites the JSON first, validation fails. It’s the same precaution as with the regular webhook, explained in validating the webhook signature. oaepHash. WithoutoaepHash: "sha256", Node uses SHA-1 for OAEP and the AES key won’t unwrap.- Responding with plain JSON. The Flow expects the base64 string as plain text. Returning
res.json(...)doesn’t work. - Rotating the app secret. To reset it without taking the endpoint down, accept signatures valid with either the old or the new secret for a few hours, then only the new one.
To test on your machine, the tunneling technique from testing the webhook locally also works for the Flow endpoint. If you’d rather go serverless, the same logic fits in a Worker; see webhook with Cloudflare Workers.
Response codes and Flow health
The Flows error codes reference defines three HTTP statuses for the endpoint:
| Status | When to use it | What WhatsApp does |
|---|---|---|
421 | The payload couldn’t be decrypted | Downloads the public key again and retries; if that fails, shows a generic error |
427 | The flow_token is no longer valid | Disables the Flow button; you can set the message shown |
432 | The request signature doesn’t match | Shows a generic error |
Beyond that, the request fails with timeout_error if the endpoint takes more than 10 seconds, and closing the connection without a response or returning an unexpected status, such as 500, also counts as an error.
The health and monitoring guide explains what happens when the metrics get worse. WhatsApp tracks the endpoint’s error rate, latency and availability, and sends alert webhooks before restricting the Flow:
| Status | Effect |
|---|---|
| Published | No restriction |
| Throttled | Only 10 new messages with that Flow per hour; people who already received it can still open it |
| Blocked | The Flow can’t be sent or opened, including ones already sent |
To get back to published, Meta advises responding in under 1 second when there’s a latency alert, keeping the endpoint reachable at all times, answering the ping correctly and fixing the errors listed in the alert. In practice: fetch slow data asynchronously ahead of time (a calendar cache, for example) and run the endpoint on infrastructure that doesn’t “sleep”.
How to do it with Vectalk
Vectalk is a proxy for Meta’s official WhatsApp Cloud API. Flow management is part of its API, using an instance token: list, create, upload the flow.json with POST /api/flows/{flowId}/assets, publish and deprecate, as described in Create Flow and Flow assets. Sending a Flow message uses POST https://apis.vectalk.com.br/api/messages, and the send message page documents flow_action with the values navigate and data_exchange. Fetching a Flow returns the data_api_version and endpoint_uri fields.
What Vectalk’s documentation doesn’t describe today is uploading the public key (whatsapp_business_encryption), setting the endpoint_uri and connecting the Meta app to the Flow, which is the app whose secret signs the requests. If your project depends on a Flow with an endpoint, confirm that path through the contact page before you start. Flows without an endpoint work with what’s already documented.
On billing, each delivered message is deducted from your prepaid balance, with no card registered with Meta. To create your account, go to apps.vectalk.com.br/register. The platform overview is in the official WhatsApp API guide.
Frequently asked questions
Can I use the same key pair for several phone numbers?
The key is uploaded per phone number, so you need to call whatsapp_business_encryption for each one. Meta recommends that anyone serving several businesses use a dedicated endpoint and key pair per messaging account.
Is the health check ping encrypted too?
Yes. Every request to the endpoint arrives in the encrypted format. Once decrypted, the payload contains "action": "ping", and the {"data": {"status": "active"}} response must also be encrypted.
What is the endpoint’s maximum response time?
Above 10 seconds the request fails with timeout_error. To avoid latency alerts, Meta advises aiming for under 1 second.
What do I do when I get a 421 error in production?
A 421 makes WhatsApp download the public key again. If the error persists, check with GET /{PHONE_NUMBER_ID}/whatsapp_business_encryption that the status is VALID and upload the key again, especially after re-registering the number.
Do I need an endpoint to receive Flow responses?
No. The Flow’s final response arrives on the regular messages webhook. The endpoint is only for exchanging data while the customer fills in the Flow. An example of a serverless lead capture Flow is in form inside WhatsApp with Flows.
Official sources consulted on November 24, 2026: Implementing your Flow endpoint (updated June 28, 2026); WhatsApp Flows business encryption (updated July 2, 2026); Flow health and monitoring (updated June 16, 2026); Flows API (updated June 16, 2026); Flows error codes; WhatsApp-Flows-Tools on GitHub; Vectalk documentation: Flows and sending messages.
Try the official WhatsApp API today
Create your account, generate a token and send your first message with the quick-start guide. Same payloads and webhooks as Meta's Cloud API.
