Overview
Activepieces API supports two authentication methods:- API Keys - Best for server-to-server integrations
- JWT Tokens - Used for user sessions and authenticated requests
API Keys
API keys are platform-scoped credentials for programmatic access to the Activepieces API.Creating an API Key
API keys can be created via the platform dashboard or API:- Navigate to Platform Settings → API Keys
- Click “Create API Key”
- Provide a display name
- Copy the generated key (starts with
sk-)
API Key Format
API keys follow this format:sk-abc123def456...xyz789
Using API Keys
Include the API key in theAuthorization header with the Bearer scheme:
API Key Security
- API keys are hashed using SHA-256 before storage
- Only the last 4 characters are stored in plaintext for identification
- Keys track
lastUsedAttimestamp for auditing - Keys are scoped to a specific platform
Managing API Keys
- List API Keys
- Delete API Key
JWT Tokens
JWT (JSON Web Token) tokens are used for user authentication and session management.Obtaining a JWT Token
Users can obtain JWT tokens through sign-in:Using JWT Tokens
Include the JWT token in theAuthorization header:
JWT Token Structure
JWT tokens contain the principal information:Token Expiration
- Default expiration: 7 days
- Engine tokens: 100 years (long-lived for flow execution)
- Worker tokens: 100 years (for internal worker processes)
Token Versioning
Tokens include atokenVersion to enable session invalidation:
- Each user has a
tokenVersionstored in their identity - When a token is verified, the version is checked
- Incrementing the version invalidates all existing tokens
- Useful for security events (password reset, logout all devices)
Authentication Headers
Required Headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer <token> | API key or JWT token |
Content-Type | application/json | Required for POST/PUT requests |
Optional Headers
| Header | Description |
|---|---|
ap-parent-run-id | Parent run ID for nested flow executions |
ap-fail-parent-on-failure | Whether to fail parent run on child failure |
Authentication Errors
Invalid Bearer Token (401)
- Token is malformed or corrupted
- Token signature verification failed
- Token has expired
Session Expired (401)
- Token version mismatch (user logged out)
- User account is inactive
- User identity is not verified
Authorization Error (403)
- Insufficient permissions for the requested operation
- Attempting to access resources in a different project/platform
Security Best Practices
Secure API Key Storage
Secure API Key Storage
- Store API keys in environment variables or secure vaults
- Never commit API keys to version control
- Rotate API keys periodically
- Use different API keys for different environments
Token Handling
Token Handling
- Store JWT tokens securely (e.g., HTTP-only cookies)
- Implement token refresh logic before expiration
- Clear tokens on logout
- Validate token expiration on the client side
Network Security
Network Security
- Always use HTTPS in production
- Implement IP allowlisting for sensitive operations
- Monitor API key usage via
lastUsedAttimestamps - Set up alerts for suspicious authentication patterns
Permission System
Activepieces uses a role-based permission system:Principal Types
USER- Regular user with project-scoped permissionsSERVICE- API key with platform-scoped permissionsENGINE- Internal engine execution contextWORKER- Internal worker process
Common Permissions
| Permission | Description |
|---|---|
READ_FLOW | View flows |
WRITE_FLOW | Create/update flows |
UPDATE_FLOW_STATUS | Enable/disable flows |
READ_RUN | View flow runs |
WRITE_RUN | Trigger/retry flow runs |
READ_APP_CONNECTION | View connections |
WRITE_APP_CONNECTION | Create/update connections |
WRITE_PROJECT | Update project settings |
Code Examples
Next Steps
Flows API
Start creating and managing flows
Projects API
Manage projects and team settings