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.
Service Accounts
Service accounts allow non-interactive processes, background workers, schedulers, cleanup jobs, and automated pipelines, to authenticate with CRAFT using machine identity. Service accounts authenticate against the master realm in Keycloak (not the organization realm), which gives them platform-level access scoped by explicit organization and project headers.Detection
The platform identifies a request as coming from a service account when:- The client ID in the JWT begins with the
svc-prefix (e.g.,svc-data-pipeline) - The JWT contains the
serviceAccountrealm role - The authentication was performed against the Keycloak master realm
Authentication Flow
Obtain a Client Credentials Token
Service accounts use the OAuth 2.0 Client Credentials grant, no user interaction required.Response:
Pass Service Account Context Headers
Service account JWTs do not carry tenant context. Pass these required headers:
X-Org-Id, the organization context (required; replaces the realm-derived org in user tokens)X-Project-ID, the project scope for project-scoped endpoints (required when applicable)
X-On-Behalf-Of: <user-id> (optional).Creating a Service Account
Create a Confidential Client in Keycloak
In the Keycloak master realm admin console:
- Navigate to Clients → Create client
- Set Client ID with the
svc-prefix (e.g.,svc-nightly-cleanup) - Set Client Protocol:
openid-connect - Set Access Type:
confidential - Enable Service Accounts Enabled
- Save and note the generated client secret
Assign the serviceAccount Role
In the client’s Service Account Roles tab:
- Select Realm Roles
- Assign the
serviceAccountrole
Use Cases
| Use Case | Example |
|---|---|
| Scheduled data pipelines | Nightly data ingestion jobs that create agents and data connections |
| Background cleanup | Purging expired sessions, rotating secrets, archiving old artifacts |
| Workflow orchestration | Prefect workflows that call platform APIs to register results |
| Automated testing | CI/CD pipelines that create isolated test resources per run |
| Inter-service communication | Solution services calling platform APIs |
Token Expiry and Rotation
Service account tokens are short-lived (configurable, default 1 hour). Background workers should implement automatic token refresh:Related
Authentication
Overview of all authentication methods including user tokens and OIDC.
Authorization
How permissions are checked for service account requests.
Projects
Project-level isolation and the X-Project-ID header.

