Authentication Methods
CaseXchange exposes two distinct API surfaces, each with its own authentication mechanism:| API | Auth method | Header | Use case |
|---|---|---|---|
Public API (/api/public/v1/...) | API key | X-API-Key: cxp_std_... | Third-party integrations, data syncs, automations |
Internal API (/api/v1/...) | JWT Bearer token | Authorization: Bearer <jwt> | CaseXchange dashboard, API key management |
- The CaseXchange web dashboard
- Creating and managing Public API keys via
POST /api/v1/public-api-keys
Most third-party integrations should use the Public API with API key authentication. See the Quickstart to get started. JWT authentication is only needed for CaseXchange dashboard access and API key management.
Overview
JWT authentication is used by the CaseXchange web dashboard and by server integrations that need to manage API keys.POST /api/v1/auth/loginexchanges credentials for an access token.- HttpOnly cookies (
auth_token,refresh_token_id) are also set for browser clients. - Use
POST /api/v1/auth/refresh-sessionto rotate short-lived tokens.
Login Flow
- Collect email/password from the integration user.
- Send the payload to
/api/v1/auth/login. - Cache the returned JWT for Authorization headers.
- Store refresh identifiers securely.
The
accessToken should be used in the Authorization: Bearer <token> header for subsequent Internal API requests. The refreshToken can be used to obtain a new access token when it expires. HttpOnly cookies are also set for browser-based clients.Using Tokens
Include the JWT in every Internal API request:Refresh Sessions
- Endpoint:
POST /api/v1/auth/refresh-session - Requires the
refresh_token_idcookie (for browser clients) or refresh token in the request body (for server-to-server). - Returns a brand new JWT access token and rotates refresh identifiers.
- Access tokens expire after 15 minutes (configurable via
JWT_EXPIRES_IN). - Refresh tokens expire after 7 days (configurable via
JWT_REFRESH_EXPIRES_IN).
Browser-based Refresh (Cookie-based)
For browser clients, the refresh endpoint automatically uses therefresh_token_id cookie:
auth_token- New JWT access tokenrefresh_token_id- New refresh token identifier
Server-to-Server Refresh
For server integrations, include the refresh token in the request:Creating Public API Keys via JWT
After authenticating with JWT, you can programmatically create Public API keys. This is the same mechanism the CaseXchange dashboard uses under the hood.Create a key
READ_ONLY, STANDARD, FULL. See the Quickstart for a breakdown of what each tier permits.
Response:
Switch to API key authentication
Once you have a Public API key, use theX-API-Key header for all Public API calls:
Internal API Error Codes
All Internal API errors follow the standard error response format:no_token— Missing Authorization headertoken_expired— Access token exceeded its TTLtoken_invalid— Token signature or claims invalidrate_limited_email/rate_limited_ip— Too many login attemptsaccount_not_fully_activated— User account is inactiveaccount_inactive_login_attempt— Login attempt on inactive account
400— Bad Request (validation errors, invalid token)401— Unauthorized (authentication failed)403— Forbidden (account inactive)