Skip to content

Authentication

Athena uses two types of API keys for external integrations:

TypePrefixLifetimeSourceUse
Workspace API Keywak_Long-livedAdmin creates manuallyServer-to-server
Ephemeral API Keyeak_1 min – 24 hToken exchange or server mintClient-side sessions

Both are passed in the X-API-Key header. Never expose wak_ keys to client devices.


Token Exchange (Mobile / Web Apps)

Your app authenticates users through Firebase, Clerk, or a compatible provider. After authentication, exchange the provider’s ID token for an Athena eak_:

POST /auth/external/{workspace_id}
Content-Type: application/json
{
"provider": "firebase",
"token": "eyJhbGciOiJSUzI1NiIs..."
}

Supported providers: firebase (Google Firebase Auth), clerk.

Response (200):

{
"data": {
"key": "eak_a1b2c3d4e5f6...",
"expires_at": "2026-05-13T12:00:00Z",
"customer": {
"id": "019f902b-db70-7ea4-8ef2-60a8ff5747cd",
"external_id": "firebase_uid_xyz",
"email": "user@example.com",
"display_name": "Jane Doe",
"active_credits": 100.0,
"frozen_credits": 0.0,
"inactive_credits": 0.0
}
}
}

The returned eak_ key is valid for 24 hours. Store it on the device and use it for all subsequent API calls via X-API-Key: eak_....

Rate limits on token exchange:

ScopeLimit
Per IP (before JWT verification)10 / min, 50 / hr
Per identity (after JWT verification)5 / min, 20 / hr

Error codes:

HTTPCodeCause
403forbiddenExternal auth not enabled for this workspace
401unauthorizedJWT verification failed (expired, invalid signature)
429rate_limitRate limit exceeded — check Retry-After

Server-Side Ephemeral Key Minting

For server-to-server flows, mint ephemeral keys directly without requiring a user JWT:

POST /ephemeral-keys/create
X-API-Key: wak_your_workspace_key
Content-Type: application/json
{
"name": "user-session-12345",
"purpose": "agent_execution",
"scopes": ["agent:execute", "conversation:create"],
"ttl_seconds": 3600,
"agent_ids": [
"019f902b-db6f-7ea4-8ef2-60a8ff5747cd",
"019f902b-db71-7ea4-8ef2-60a8ff5747cd"
]
}
FieldRequiredDescription
nameYesIdentifier for debugging / audit trail
purposeYesagent_execution
scopesYesArray of scope strings (see below)
ttl_secondsYes60 – 86400 (1 min to 24 h)
agent_idsNoRestricts key to specific agents. Empty = all agents.

Response:

{
"data": {
"key": "eak_xyz789...",
"expires_at": "2026-05-13T01:00:00Z"
}
}

Scopes

Each eak_ key is minted with a set of scopes that define what it can do:

ScopeAccess
agent:executeExecute agents, upload attachments, check credit balance, manage push preferences, view notifications
conversation:createCreate conversations, archive conversations, send feedback, patch sticky variables. Implies conversation:read
conversation:readRead conversation list and message history, read sticky variables
media:readView generated media assets
attachment:readView own uploads
ephemeral_key:createMint new ephemeral keys (requires wak_ only)
cms:readRead CMS storefront content (public endpoints, no key required)

Default scopes issued by token exchange: agent:execute + conversation:create.


Key Renewal

eak_ keys expire. Your app should:

  1. Track expires_at from the creation response.
  2. Renew proactively before expiry (recommendation: renew when less than 5 minutes remain).
  3. Handle 401 unauthorized responses by triggering re-authentication and retrying the failed request.
{
"error": {
"code": "unauthorized",
"message": "Invalid or expired API key"
}
}

Using the X-API-Key Header

All authenticated requests require:

X-API-Key: eak_...
X-Workspace-Id: 019f58c6-0400-7fa2-a41f-a32abf613c76

The X-Workspace-Id header is required for API key paths. It must contain the workspace’s raw UUIDv7.

Missing or malformed workspace headers return 400 bad_request.


Security Best Practices

  • Store wak_ keys only in server-side environment variables, never in client code, mobile bundles, or version control.
  • Use short ttl_seconds for ephemeral keys — 3600 (1 hour) is recommended for most mobile sessions.
  • Use agent_ids restriction when a session should only access specific agents.
  • Monitor for 401 responses in production and alert on unexpected 403 (may indicate workspace misconfiguration).