Skip to navigation

API keys and security

View as Markdown

Create one BeatAPI key per application, tool and environment in Dashboard → API Keys, send the key only in the Authorization: Bearer <key> header from a server, and revoke a leaked key before you create the replacement. A browser can call BeatAPI directly only with a Realtime client_secret or a signed artifact URL.

Where do I create a key?

Create keys in Dashboard → API Keys. Copy each key when the dashboard shows the key; the dashboard does not display the key again.

How many keys should I have?

One per thing that calls BeatAPI: each application, each tool, and each environment.

Extra keys cost nothing. With one key per component, by_api_key in GET /v1/usage attributes spend without any instrumentation, and you can revoke a leaked or misbehaving key without taking down every other component.

Development, staging, and production should never share a key.

Where must a key never go?

Anywhere a user or a stranger can read it:

  • Browser JavaScript, or any client-side bundle. Anything shipped to a browser is public.
  • Mobile applications. Decompilation is routine.
  • A public repository, or a private one that may later be opened.
  • Logs, error reports, screenshots, and support tickets.
  • URL query strings, because they are recorded by proxies, browser history, and server logs.

The header is the only correct place: Authorization: Bearer <key>.

How do I keep a key out of my repository?

Store the key in an environment variable and keep the file that sets the variable out of version control:

read -rsp "BeatAPI API key: " BEATAPI_API_KEY && echo
export BEATAPI_API_KEY

Reading the key with read -rsp also keeps the key out of shell history. Add .env, ~/.codex/auth.json, and any tool config holding a key to .gitignore.

When an integration supports an environment-variable option, use that option instead of pasting the key into a config file. Codex CLI supports env_key for exactly this reason.

What if a key leaks?

Revoke the leaked key in Dashboard → API Keys first, then create a replacement key and update every component that used the leaked key. Revocation takes effect immediately.

Keep that order: revoke first, replace second. Rotating first and revoking later leaves a window in which the leaked key still spends your balance.

Afterwards, check by_api_key in GET /v1/usage for usage you do not recognise.

How often should I rotate?

On a schedule you will actually keep, and immediately whenever someone with access leaves or a key may have been exposed. Per-component keys make rotation cheap, because each key touches a single deployment.

Can a browser call BeatAPI directly?

Not with an API key. For the Realtime API, your server creates a Session and hands the browser a short-lived client_secret scoped to that Session. See Realtime API. Every other endpoint is server-side only.

Generated media is the exception, and only for reading: a task’s artifact URL carries its own signed credential in the query string and grants access to that one artifact, so a browser can load the artifact from an <img> or <video> with no header attached.

Is my data used for training?

BeatAPI does not train on your requests. Review the Privacy Policy and Terms of Service before sending faces, voices, or other personal data, and before processing anything on someone else’s behalf.

How do I verify a webhook actually came from BeatAPI?

Verify the signature against the raw request bytes, before parsing JSON. Re-serialising the body changes the bytes, and the signature then does not match. Check the timestamp too, so an old delivery cannot be replayed. See Webhooks.

An unverified webhook endpoint is an unauthenticated write path into your system. Treat a failed verification as an attack, not as a bug.

What is logged?

Requests are logged with a request_id for support and billing. Include that ID when reporting a problem, never the key itself.