Keep Your WhatsApp API Key Safe: Prevent and Handle Leaks
Your API key is the only key anyone needs to send messages on behalf of your WhatsApp number. No password, no second verification — whoever has the key can call the API as if they were your company. Yet many teams treat that key carelessly: hardcoded in a script, shared via Slack, or used unchanged for years by everyone who ever got access. This article walks through what you can concretely do differently.
What the key can actually do
Every call to the TextMeFlow API — whether the modern /v1/* REST API or the TextMeBot-compatible /send.php route — identifies itself with that same key, as an Authorization: Bearer <your_api_key> header or as an ?apikey= parameter. There is no separate read-only variant: whoever has the key can send messages, full stop. That means a leaked key is not just a privacy risk but an operational one: someone who abuses the key to send unsolicited messages en masse puts your number squarely in the sights of the anti-spam pipeline — and in the worst case leads to a Meta ban, with your customers as collateral damage.
Where the key may and may not live
The rule of thumb is simple: the key never goes into version control. Concretely:
- Put it in a
.envfile or in your hosting platform's secrets manager (Railway, Fly.io, a.envon the server that is not in git), never hardcoded in a.js,.phpor.pyfile that you commit. - Add
.envto your.gitignorebefore you create the first file, not afterwards — a key that was ever committed stays in the git history, even after a later deletion. - Never share a key via chat, email or a shared document. Use the secrets feature of your team tool (GitHub Actions secrets, Vercel environment variables, 1Password) instead of copy-paste.
- If you work with a freelancer or agency that needs temporary access, grant that access through an environment you can revoke afterwards (a shared secrets vault), not by sending the key itself.
If you're just starting with the API: the full authentication flow is described in /en/docs/api and the steps to create a first key in /en/docs/getting-started.
Webhooks are a different story
Note the distinction: your API key sends messages, but incoming webhooks (message statuses, customer replies) are not secured with that key. They are HMAC-signed — TextMeFlow signs every webhook payload with its own secret, so your endpoint can verify that the request really comes from TextMeFlow and not from someone who guessed your webhook URL. That is a separate secret with a different role than your API key, and it deserves its own careful storage. How to check that signature is worked out in Verifying webhook signatures.
When to rotate
There are a few moments when you shouldn't wait until something goes wrong:
- An employee or freelancer with access leaves. If the key was ever shared with someone leaving the company, that is the moment to replace it — not "sometime this quarter".
- You accidentally find the key in a committed file, a public repo or a log file. From that moment on, assume it is compromised, even if you're not sure anyone has used it yet.
- You see messages going out that you didn't initiate. That is the clearest sign of abuse and calls for immediate action.
If you suspect a leak, contact TextMeFlow support so the existing key is invalidated and you receive a new one. Then update every place where the old key lived — scripts, automations, CI/CD secrets — because a forgotten spot with the old key simply means a silent failure in production once that key stops working.
One key, multiple integrations
Most teams use the same key in multiple tools: an n8n flow, a backend script, an Airtable automation. That is not a problem in itself, but it does make rotation more annoying — you have to update everywhere. So keep a list of where the key is used (a line in an internal wiki document is enough) so rotation doesn't turn into detective work. For teams working on multiple numbers, a separate device per team or branch is available from the Business plan, which makes rotation and access control per number easier than running everything through one shared key.
No account yet? Create a free TextMeFlow account and start with a key you store correctly from day one — that's easier than cleaning up afterwards.
Want to send WhatsApp messages via API yourself?
Free forever up to 50 messages/month. Scan a QR and send your first message within 5 minutes.
Free forever