Authorization header. Keys are scoped by environment — live keys write to your production audit chain and count against your plan limits, while test keys use a separate free-tier pool and are safe to use during development and CI.
Obtaining an API Key
You create and manage API keys from your AuditRails dashboard. Keys are displayed only once at creation time and are stored as a one-way hash — if you lose a key, revoke it and create a new one. Dashboard → API Keys → Create API KeyKey Types
AuditRails issues two distinct key prefixes with different behaviors:Sending the Authorization Header
Pass your API key as a Bearer token in every request:Bearer (capital B), a single space, then your key. No other authentication schemes (Basic, API-Key header, query-string tokens) are accepted.
Authentication Errors
All authentication failures return HTTP401 Unauthorized with a structured error body. The code field tells you exactly what went wrong:
Example 401 response:
The
request_id in every error body matches the X-Request-Id response header. Include it when contacting AuditRails support — it lets the team look up the exact request in server-side logs.Security Best Practices
- Rotate keys regularly. Use the dashboard to revoke old keys and issue new ones on a schedule that fits your security policy.
- Use separate keys per service. Issuing one key per application or microservice limits blast radius if a key is compromised.
- Set expiry dates. For short-lived jobs (e.g. batch migrations), create a key with a tight expiry window.
- Never expose keys client-side. API keys must only be used from server-to-server calls. If you need to log events from a browser, proxy requests through your own backend.
- Monitor for unexpected usage. The AuditRails dashboard shows per-key request counts — an unusual spike can indicate a leaked key.