Authentication
Overview
Naiza public APIs use two auth modes:
- API key auth (
x-api-key) for/api/v1/*server-to-server integrations - Bearer auth (
Authorization: Bearer <token>) forPOST /api/v1/websdk/signalsusing short-lived SDK tokens
API Key Authentication
Include your key in every API request:
POST /api/v1/decisions/evaluate x-api-key: naiza_api_sk_live_... Content-Type: application/json
First Auth Check
curl -X GET "https://api.naiza.ai/api/v1/decisions?limit=1" \ -H "x-api-key: naiza_api_sk_live_YOUR_KEY"
Web SDK Authentication Flow
- Your backend calls
POST /api/v1/websdk/tokenswithx-api-key - Naiza returns a short-lived token (about 15 minutes)
- Browser SDK sends signal batches to
POST /api/v1/websdk/signalswithAuthorization: Bearer <token> - API keys never leave your server
Secure Key Management
- Keep keys in a secret manager or server-side environment variables
- Never ship keys in frontend bundles, mobile binaries, or logs
- Rotate keys regularly and immediately after suspected compromise
- Use separate keys for dev, staging, and production
401 Unauthorized
Common causes:
- Missing
x-api-key - Revoked or invalid key
- Key belongs to a different tenant
- Expired/invalid Web SDK bearer token
Example response:
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key",
"details": {}
}
}