Authentication

Egret supports two authentication methods: JWT tokens for browser/UI clients and API keys for server-to-server integrations.

JWT (Browser clients)

Obtain a short-lived access token and a long-lived refresh token by logging in:

POST /auth/jwt/create/
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "your_password"
}

Response:

{
  "access": "eyJhbGciOiJIUzI1NiJ9...",
  "refresh": "eyJhbGciOiJIUzI1NiJ9..."
}
TokenLifetimeUsed for
access5 minutesAll API requests
refresh30 daysObtaining new access tokens

Use the access token in the Authorization header:

Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...

API Keys (Server-to-server)

API keys are long-lived credentials for scripts, integrations, and server-to-server calls. They don't expire unless revoked or an explicit expires_at is set.

Authorization: Api-Key ek_live_abc123...

Create API keys from the dashboard under Settings → API Keys, or via the API Keys endpoint.

Scopes

API keys can be created with restricted scopes:

ScopeAccess
readRead-only access to queries, sessions, and domains
writeFull read/write access
adminOrganization management, billing, and user administration

Next steps