Skip to content

Authentication

Cortex supports three authentication methods. All protected endpoints require at least one.

1. JWT Bearer Token

The primary authentication method. Tokens are HS256-signed JWTs with 30-day expiry.

Obtain a Token

bash
curl -X POST https://api.cortex.acrobi.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "yourpassword"}'

Response:

json
{
  "user": { "id": "user-123", "email": "user@example.com", "name": "Alice", "role": "user" },
  "token": "eyJ...",
  "refreshToken": "eyJ..."
}

Use the Token

Authorization: Bearer eyJ...

Refresh Before Expiry

bash
curl -X POST https://api.cortex.acrobi.com/api/auth/refresh \
  -H "Content-Type: application/json" \
  -d '{"refreshToken": "eyJ..."}'

2. API Key

For external integrations (MCP servers, automation, CI/CD). API keys use the sk-ctx- prefix and are SHA-256 hashed for storage.

X-API-Key: sk-ctx-abc123...

API keys support scoped access:

  • read — Read-only access
  • write — Read + write access
  • admin — Full administrative access

Generate API keys via POST /api/settings/api-key/regenerate or in the dashboard under Settings.

3. Scope Headers

Many endpoints are scope-aware. Include these headers to target a specific workspace or project:

HeaderDescriptionExample
X-Organization-IdTarget organization/workspaceorg-abc123
X-Project-IdTarget project within orgproj-def456
x-scope-typeScope type identifierorganization or project

Agent Identity Headers

When operating as an AI agent, include these additional headers for tracking and audit:

HeaderDescriptionExample
X-Agent-DefinitionAgent type namecoder-agent
X-Agent-Instance-IdUnique instance identifierinst-789xyz
X-Agent-Display-NameHuman-readable nameBackend Coder #3
X-Agent-Owner-IdUser who owns this agentuser-123

Rate Limiting

All endpoints enforce rate limiting by user and tier. Response headers indicate current state:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRequests remaining in window
X-RateLimit-ResetUTC timestamp when window resets
Retry-AfterSeconds to wait (only on 429 responses)

RBAC Roles

RoleLevelDescription
superadmin100Full platform access
admin80Organization-level admin
manager60Team management
member40Standard user
guest20Read-only access

Role level determines which capabilities an agent or user can access. See Capabilities for the full matrix.

Built by Acrobi