Documentation Index
Fetch the complete documentation index at: https://docs.emergence.ai/llms.txt
Use this file to discover all available pages before exploring further.
API Authentication
All CRAFT API endpoints require authentication via JWT tokens issued by Keycloak. This page covers how to obtain tokens, authenticate requests, and handle token refresh.Authentication Methods
- User Tokens (OIDC)
- Client Credentials
- Development Tokens
For interactive applications, use the OIDC Authorization Code flow with PKCE:After the user authenticates, exchange the code:
- Redirect the user to the Keycloak authorization endpoint
- Exchange the authorization code for tokens
- Include the access token in API requests
Using the Token
Include the access token in theAuthorization header of every API request:
Required Headers
| Header | Required | Description |
|---|---|---|
Authorization | Always | Bearer <access-token> |
X-Project-ID | Most endpoints | UUID of the target project |
Content-Type | Write operations | application/json |
The
X-Project-ID header determines which project the request is scoped to. A single JWT token can access multiple projects within the same organization. The project ID is never embedded in the JWT.Token Refresh
Access tokens have a short lifetime (typically 5 minutes). Use the refresh token to obtain new access tokens without re-authentication:Refresh Strategy
Monitor token expiry
Track the
exp claim in the JWT payload. Plan to refresh when 75% of the token lifetime has elapsed.Proactive refresh
Refresh the token before it expires to avoid 401 errors during in-flight requests.
SDK Authentication
The auto-generated SDKs handle token management:- Python
- TypeScript
Token Claims
The JWT access token contains these claims used by the platform:| Claim | Platform Usage |
|---|---|
sub | Unique user identifier for audit logs |
iss | Organization ID derived from realm in the issuer URL |
groups | Mapped to OpenFGA roles for permission checks |
exp | Token expiration validation |
Error Responses
Authentication failures return structured error responses:| Status | Code | Description |
|---|---|---|
401 | UNAUTHENTICATED | No token provided or token signature invalid |
401 | TOKEN_EXPIRED | Access token has expired; refresh and retry |
403 | FORBIDDEN | Token is valid but user lacks permission for this operation |
429 | RATE_LIMIT_EXCEEDED | Too many requests; check Retry-After header |
Next Steps
API Overview
Review the full API structure, endpoints, and rate limits.
Error Codes
Understand all error response formats and troubleshooting steps.
SSO Integration
Configure SSO for enterprise identity providers.
RBAC Configuration
Set up roles and permissions for API access control.

