The Prisme.ai API uses a robust authentication system to secure access to resources. This guide explains how authentication works and how to implement it in your API requests.Documentation Index
Fetch the complete documentation index at: https://prismeai-docs-next.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Authentication Methods
- JWT Authentication
- Access Tokens
- API Keys
JSON Web Tokens (JWTs) are the primary authentication method for web clients and interactive sessions.
Obtain a JWT
JWTs are issued in two scenarios:Response contains a JWT:
- OpenID Connect (OIDC) authentication: After authenticating with the OIDC server (the api-gateway), clients receive an authorization code that can be exchanged for a JWT. Find your current JWT in the
access-tokencookie sent to thehttps://api.studio.prisme.ai/v2/meAPI after opening any Prisme.ai page - Anonymous authentication: The
/v2/login/anonymousendpoint initiates unauthenticated sessions and returns a JWT.
JWT Token Details
JWT Structure and Signing
JWT Structure and Signing
JWTs issued by Prisme.ai are signed tokens with the following characteristics:
- Algorithm: Defined by
JWKS_ALG(default: RS256) - Key Type: Defined by
JWKS_KTY(default: RSA) - Key Size: Defined by
JWKS_SIZE(default: 2048 bits)
JWT Key Rotation
JWT Key Rotation
The api-gateway automatically handles JWT key rotation:
- JWTs are signed using a JSON Web Key (JWK) that is stored in the api-gateway database
- JWKs are automatically rotated according to
JWKS_ROTATION_DAYS(default: 30 days) - When a JWK is rotated, it remains available for verification of existing JWTs
- Rotated JWKs are removed after
ACCESS_TOKENS_MAX_AGE(default: 30 days) once all their signed JWTs should have expired - Events (
gateway.jwks.updatedandruntime.jwks.updated) synchronize all api-gateway and runtime instances when JWKs are rotated or removed
Public Keys
Public Keys
Public keys for verifying JWTs are available at:This endpoint returns the public keys in JWKS (JSON Web Key Set) format, which can be used to verify token signatures.
Authentication Modes Summary
| Mode | Caller | Token Format |
|---|---|---|
| User Session | Browser / frontend | OIDC Bearer token or access-token cookie |
| API Key | External integrations | iak_{orgSlug}_{uuid} in x-prismeai-api-key header |
| Access Token | Programmatic clients | at: prefixed token in Authorization header |
| Cross-Workspace Call | Other workspaces | Identified by run.sourceWorkspaceId (injected by runtime) |
Active Organization
Every authenticated user has an active organization that scopes permissions and resources. It is resolved on each request:- URL path (
/v2/orgs/:orgSlug/...) takes priority - Then the session-persisted
activeOrgSlug - Falls back to the user’s first organization membership
PUT /v2/user/active-org.
Authentication Flow
- Client Authentication: The client authenticates via OIDC or anonymous login to obtain a JWT
- API Gateway Validation: Requests are sent to the api-gateway with the JWT or access token
- Header Transformation: The api-gateway validates the token and adds an
x-prismeai-user-idheader - Internal Routing: The request is forwarded to the appropriate microservice with the user context
- Authorization Check: The target microservice checks if the authenticated user has the required permissions
Context Available in Automations
When building automations, the following context variables are available from the authenticated request:Session Context
| Variable | Description |
|---|---|
{{session.id}} | Session ID |
{{session.org.slug}} | Active organization slug |
{{session.org.name}} | Organization name |
{{session.org.role.slug}} | User’s role slug in the active org |
{{session.org.role.permissions}} | Role permission strings (array) |
{{session.org.role.scopes}} | Role scope strings (array) |
{{session.org.groups}} | Groups the user belongs to in this org |
{{session.org.settings}} | Org settings (e.g. LLM governance) |
{{session.org.subscription}} | Org subscription object |
User Context
| Variable | Description |
|---|---|
{{user.id}} | User ID (read-only) |
{{user.email}} | User email |
{{user.role}} | Workspace CASL role (e.g. owner, editor) — not the org role |
{{user.orgSlugs}} | Array of all org slugs the user belongs to (read-only) |
Run Context
| Variable | Description |
|---|---|
{{run.permissions}} | Org permissions as a nested object ({product: {resource: {action: true}}}) |
{{run.scopes}} | Raw scopes array from org role |
{{run.correlationId}} | Request correlation ID |
{{run.sourceWorkspaceId}} | Source workspace ID (for cross-workspace calls) |
user.role is the workspace-level role (from CASL security rules), not the organization role. The organization role is in session.org.role.Token Security
Token Storage
- Store tokens securely (not in localStorage for browser applications)
- Use HttpOnly cookies where possible
- For mobile apps, use secure storage mechanisms
- For server applications, use environment variables or secure vaults
Token Transmission
- Always use HTTPS/TLS for API communication
- Use Authorization header rather than query parameters
- Don’t include tokens in URLs or log them
- Implement CSRF protection for cookie-based authentication
Token Management
- Implement token refresh strategies
- Set appropriate token expiration times
- Have processes for token revocation
- Regularly rotate long-lived tokens
Error Handling
- Handle 401 (Unauthorized) responses properly
- Don’t expose detailed error information to clients
- Implement rate limiting for authentication failures
- Log authentication failures for security monitoring
Authentication Configuration
- Environment Variables
JWT and authentication behavior can be configured with these environment variables:
| Variable | Description | Default Value |
|---|---|---|
JWKS_ROTATION_DAYS | Rotation period in days | 30 |
JWKS_KTY | JWK Algorithm family | RSA |
JWKS_ALG | JWK signature algorithm | RS256 |
JWKS_SIZE | JWK size | 2048 |
ACCESS_TOKENS_MAX_AGE | JWT expiration time in seconds | 2592000 (30 days) |
Code Examples
- Node.js
- Python
- cURL
Next Steps
Error Handling
Learn about common API errors and how to handle them
Rate Limits
Understand the API’s rate limiting policies
Security
Read about our security recommendations and best practices