Authentication
NexaLayer supports two authentication modes. API Key is recommended for AI Agents — no token lifecycle to manage.Mode 1: API Key (recommended)
Send the API key on every request. No token exchange or refresh.| Header | Value |
|---|---|
X-API-Key | Your api_key (e.g. ak_a1b2c3d4e5f6g7h8) |
- Use for all server-side and agent workloads.
- Key is long-lived until you rotate it; no expiry handling needed.
Mode 2: JWT Token (optional)
Exchangeapi_key + api_secret for a short-lived Bearer token. Use when you need token expiry semantics (e.g. web console).
Obtain token
Use token
| Header | Value |
|---|---|
Authorization | Bearer <access_token> |
Refresh token
Before expiry, call:Comparison
| API Key | JWT | |
|---|---|---|
| Setup | One header | Token exchange + refresh |
| Lifetime | Long-lived | Short (e.g. 1 hour) |
| Best for | Agents, scripts, backend | Web console, high-security flows |
Security
- Store
api_keyandapi_secretin environment variables or a secret manager; do not commit them. - Use HTTPS for all requests.
- Rotate secret via
POST /account/rotate-secretif compromised; API Key mode is unaffected.