Feature

WhatsApp API developer experience: test keys and signed webhooks

Other posts show how to use these features. This one explains why each exists, and the small decisions behind them that you only notice when something goes wrong.

6 min read

Picture a script with a small bug. It's meant to send one shipping update per order, but when the network hiccups it retries, and the retry sends the message again. At two in the morning it does this for four hundred orders.

Nobody writes that bug on purpose, and almost every API makes it easy to write. The measure of WhatsApp API developer experience isn't how short the quickstart is. It's what happens when you get something wrong. Can you find out cheaply? Is the mistake reversible? Does the error tell you what to do?

We've already written how-to posts on test keys and safe retries and on rate limits and errors. This is the level above those: the design thinking behind six details of the Avox API, and what we think each one gets right. Where one has a sharp edge, we'll say so.

1. WhatsApp API developer experience starts with test keys

An Avox test key starts with avx_test_ and goes through exactly the same checks as a live key: the key itself, its number, your plan, rate limits, the request body and idempotency. Then, instead of sending to WhatsApp, it answers with a pretend result. Nobody gets a message and nothing is charged.

The pretend result is deliberately hard to confuse with the real thing. The message_id starts with wamid.TEST, the body carries "test": true, and the response has an Avox-Test-Mode: true header. Test keys also have their own rate limits and daily allowance, so a test suite running in a loop can't eat the allowance your production traffic needs.

The design choice we like most is the seven special test numbers. Send to +15550000002 with a test key and you get a 422 outside_messaging_window, the error you'd see if the customer hadn't written in the last 24 hours. +15550000005 gives you a 429 with a Retry-After header, and +15550000007 gives 502 meta_unavailable. You can write and test your error handling today, rather than waiting to hit those errors in production. (The 24-hour window itself is Meta's rule: see Meta's guide for the current wording.)

There's also a Test button beside every key in Settings > API Keys. It's a dry run: it checks the key is active and the number is ready, without sending anything or costing anything with Meta. Be aware of its limit, which the docs state too: it can't see your server's copy of the key or your request body, so it doesn't replace test mode.

2. Retries should be boring: idempotency

Add an Idempotency-Key header, one per message, and a retry with the same key and the same body returns the first result unchanged, marked with Idempotent-Replayed: true. Nothing is sent twice. The same key with a different body returns 409 idempotency_conflict, and the same key while the first request is still running returns 409 idempotency_in_progress.

Keys are scoped to the API key and finished results are kept for 24 hours. The dashboard lists every replay as its own request, labelled "replayed", so you can see a retry doing its job.

The one case where we hand you the decision

If WhatsApp doesn't answer in time, you get 502 meta_unavailable, and Avox frees the key rather than storing the failure. That means a retry runs as a new request, and it will send.

That's deliberate. When Meta doesn't answer, nobody knows whether the message went out, so Avox doesn't guess in either direction. The choice is yours, and the docs say what to do: for something where a duplicate matters, such as a one-time code, check Logs for a status on the message before sending again. It's more work, and it's the honest answer.

3. Errors you can branch on

Every failure has the same shape: a stable code, a plain message, a docs_url that links to that code's entry, a request_id (also the X-Request-Id header), and Retry-After when waiting will help. The API errors page says codes are never renamed or removed, which is what lets you write if (error.code === "outside_messaging_window") and trust it in a year. The message is allowed to improve over time, so don't parse it.

Take the request_id to the API logs page and search for it. You'll see the time, status, error code, key, connection, a masked recipient and latency, and you can Export CSV for what matches your filters.

4. Incoming events you can trust: signed webhooks

Message forwarding (see our forwarding post) sends each new incoming customer message to your own HTTPS endpoint. Every request carries an Avox-Signature header: t=UNIX_SECONDS,v1=HEX_SIGNATURE. The signature covers the timestamp and the raw body, with your signing secret as the key.

Three rules for your endpoint, all of them there to protect you:

  1. Check the signature over the raw body, and refuse anything older than five minutes. That stops someone replaying a captured request later.
  2. Answer with a 2xx within 10 seconds. Acknowledge first, work afterwards.
  3. Skip repeats using the Avox-Event-Id header, which stays the same across retries.

If your endpoint is down, Avox tries again after about 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours, with a little randomness so a burst of failures doesn't retry in lockstep. After the seventh failed attempt the delivery is marked Failed. If five deliveries in a row fail, Avox pauses forwarding for that connection and emails every Admin once, rather than hammering an endpoint that's clearly broken. You then click Send test event until it shows Delivered, switch forwarding back on, and use Resend on anything you missed.

The limits are worth knowing. Forwarding covers incoming customer messages only. Delivery statuses stay in Logs. Media arrives as Meta's media id and caption, never the file. And the signing secret is shown once, when it's created, so store it straight away.

5. Keys you can rotate without a 3 a.m. deploy

Creating, rotating or revoking an API key needs a six-digit code emailed to the person doing it. It works once, for 10 minutes, for that one action on that one key. It's a small speed bump, and it means an open browser tab on its own isn't enough to create or change a key.

Rotation itself is the thoughtful part. You choose when the old key stops: Immediately, In 1 hour, In 24 hours (the default) or In 7 days. The new key inherits the name, number, permissions and limits, and the usage counts carry over, so rotating is never a way around a limit. Until the old one expires, both work, so you deploy at your own pace. Choose Immediately only if the key may have leaked.

Two honest notes. The full key is shown once and Avox stores only a hash of it, so a lost key means rotating. And because idempotency keys belong to one API key, finish pending retries on the old key before you switch.

Questions people ask

Is a test key a separate environment?

No. It runs against your own connected number with the same checks as a live key, then answers with a pretend result.

Do I need idempotency for every send?

It's optional, but we'd use it for anything sent from a queue, a scheduled job or code that retries on its own.

Where can I see what my keys did?

On the API logs page: the Sent tab for requests and the Received tab for forwarded messages. Filter to Test only or Live only.

A next step

Create a test key in Settings > API Keys, send to +15550000002, and check that your code handles the 422. Then follow the Avox API docs through the rest of the testing page before you ask for a live key.

  • #api developer experience
  • #whatsapp api test mode
  • #idempotency key api
  • #signed webhooks
  • #api keys
  • #developers
Thanks for reading!

Thanks for reading

How did this land? 0 reactions

Was this helpful?

Try it yourself

The details behind a good WhatsApp API developer experience: test keys, safe retries, stable errors, signed webhooks and key rotation without downtime.

Share this story

Follow Avox on Google

Pick Avox as a preferred source and Google shows our stories more often in Top Stories and its search results.

Add Avox as a preferred source on Google(opens Google)

Related articles

More stories on the same topics, picked for you.

Bring your team onto Avox today

No switch, no lost history: just faster replies from day one.

Signing up also gets you product updates, now and then. Unsubscribe any time. Privacy