Authentication
Mailbeam uses API keys to authenticate requests. All requests must include a valid API key in the Authorization header.
Bearer token
Include your API key as a Bearer token in every request:
Authorization: Bearer mb_live_xxxxxxxxxxxxxxxxxxxxExample with cURL:
curl -X POST https://api.mailbeam.dev/v1/verify \
-H "Authorization: Bearer $MAILBEAM_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'Key prefixes
Mailbeam API keys use a prefix to indicate their environment:
| Prefix | Environment | Usage |
|---|---|---|
mb_live_ | Production | Real verifications, counted against quota |
mb_test_ | Test | Always returns predictable results, not counted |
Use mb_test_ keys during development and CI. Test keys return fixed responses based on the email domain:
@valid.mailbeam-test.dev→ always returns{ valid: true, score: 99 }@invalid.mailbeam-test.dev→ always returns{ valid: false, score: 0 }@disposable.mailbeam-test.dev→ always returns{ valid: false, disposable: true }
Environment variables
Never hard-code API keys in your source code. Use environment variables:
# .env.local
MAILBEAM_KEY=mb_live_xxxxxxxxxxxxxxxxxxxxconst mb = new Mailbeam({ apiKey: process.env.MAILBEAM_KEY });Key rotation
You should rotate API keys periodically or immediately if a key is compromised:
- Go to the API Keys page in your dashboard
- Click Create key to generate a new key
- Update your application with the new key
- Click Revoke on the old key once traffic has moved over
Revoking a key immediately invalidates it. Requests using the revoked key will return 401 Unauthorized.
Multiple keys
You can create up to 10 API keys per account. We recommend:
- One key per environment (development, staging, production)
- One key per application if you run multiple services
- Rotate keys when team members leave
Error responses
| Status | Error | Description |
|---|---|---|
401 | invalid_api_key | The API key is missing or malformed |
401 | revoked_api_key | The API key has been revoked |
403 | insufficient_permissions | The key doesn't have permission for this endpoint |