BavimailBavimail

API key authentication for every request

Create a key in the dashboard, send it in the x-api-key header, and start sending.

Last updated November 25, 2026

API Key Format

Bavimail API keys start with the ak_ prefix followed by a random string:

ak_…

The prefix lets you identify Bavimail keys in your codebase and secrets scanners.

Authenticating Requests

Send your API key in the x-api-key header:

curl -X POST https://api.bavimail.com/outbound-emails \
  -H "x-api-key: $BAVIMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inbox_id": "YOUR_INBOX_ID", "to_emails": ["[email protected]"], "subject": "Hello", "body": "<p>Hi</p>"}'

Do not send an API key as Authorization: Bearer. That header carries a dashboard session token or an OAuth access token (for example from an MCP client); an API key sent there is not read as an API key and is refused with 401 auth_invalid_oauth_token. When a request carries both headers, the x-api-key header is used.

SDK Initialization

Both SDKs send the key in the x-api-key header for you. Neither reads it from the environment on its own, so pass it to the constructor; the client throws if no key is given.

import { Bavimail } from 'bavimail'

const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY })

Key Management

Create a Key

Open the dashboard

Go to API Keys in the dashboard.

Create the key

Click Create API Key.

Name the key

Name it something descriptive (e.g., production-backend , staging-agent ). The name is optional, but two live keys cannot share one: a key created without a name is named "Bavimail API Key", so a second unnamed key answers 409 api_key_name_taken while the first is live. Name every key you create.

Copy immediately

Copy the key immediately -- it is shown only once.

You can also create a key with POST /api-keys while authenticated with an existing credential. The response carries the full key in key, once.

Revoke a Key

Find the key

Go to API Keys.

Revoke it

Find the key, open its actions and choose Revoke API Key. Through the API, call DELETE /api-keys/{apiKeyId}.

Immediate effect

The key stops working immediately. Any request using it returns 401 .

Rotate a Key

Create a new key

Create a new key from the dashboard.

Deploy the new key

Deploy the new key to your application.

Verify traffic

Verify traffic is flowing on the new key.

Revoke the old key

Revoke the old key.

There is no downtime if you run both keys in parallel during rotation.

Security Best Practices

  • Never commit keys to version control. Use environment variables or a secrets manager.

  • Use separate keys per environment. One for production, one for staging, one for development.

  • Use one key per service or agent. A key acts with your account's full access; keys carry no per-key permissions. Separate keys let you revoke one without touching the others.

  • Rotate keys periodically. At minimum, rotate when a team member leaves or a key may have been exposed.

  • Monitor key usage. The dashboard shows when each key was last used.

Error Responses

Errors use the shape {"ok": false, "error": "<message>", "code": "<code>"}.

StatusCodeDescription
401auth_missingNo credential was sent. Send the key in the x-api-key header.
401auth_invalid_api_keyThe x-api-key value is not a valid, live API key.
401auth_invalid_oauth_tokenThe Authorization: Bearer value is not a valid OAuth access token, which is what an API key sent as Bearer returns.
403account_frozenThe account is being deleted and can no longer be used.

How are API keys managed?

Create API keys per environment and per agent from the dashboard or with POST /api-keys. Send the key in the x-api-key header on every request, never as Authorization: Bearer. See /docs/authentication for creation, rotation, and revocation.

From Bavlio Inc.: Rosefall, the agency · Bavlio, outreach software · Bavimail, email platform