What are API Keys?
API keys are authentication credentials that grant programmatic access to the ActumX API. Each key:- Uniquely identifies your requests
- Is associated with your user account
- Can be named for easy identification
- Can be revoked at any time
- Tracks usage via
lastUsedAttimestamp
API keys use bearer token authentication via the
Authorization header.API Key Structure
An API key has the following properties:Database Schema
API keys are stored in theapi_keys table:
/home/daytona/workspace/source/api/src/db/schema.ts:5-16
How API Keys Work
Key Generation
When you create an API key:- A cryptographically secure random key is generated
- The first 14 characters are stored as
keyPrefixfor identification - The full key is hashed using SHA-256 and stored as
keyHash - The raw key is returned only once
Key Format
API keys follow this format:- Prefix:
actumx_+ 14 random characters (stored for display) - Full Length: Approximately 40-50 characters
- Encoding: Alphanumeric characters
Authentication Flow
- Client Request: Include API key in the
Authorizationheader
- Server Validation: ActumX hashes the provided key and looks up the hash
- Request Processing: If valid and not revoked, the request proceeds
-
Usage Tracking: The
lastUsedAttimestamp is updated
API Key Lifecycle
1. Creation
Create an API key via the API or dashboard:API key creation requires authentication via session cookie (web dashboard) or existing API key.
2. Usage
Use your API key to authenticate all requests:3. Monitoring
List all your API keys to monitor usage:4. Revocation
Revoke a key if it’s compromised or no longer needed:- Cannot authenticate new requests
- Remain visible in your key list (with
revokedAttimestamp) - Cannot be un-revoked (create a new key instead)
Security Best Practices
Key Storage
DO:- Store keys in environment variables
- Use secret management services (AWS Secrets Manager, HashiCorp Vault)
- Encrypt keys at rest in your application
- Commit keys to version control
- Hardcode keys in source code
- Share keys via email or chat
- Log keys in application logs
Key Rotation
- Create a new API key
- Update your application to use the new key
- Verify the new key works
- Revoke the old key
Rotate API keys every 90 days or immediately if compromised.
Key Naming
Use descriptive names to track key usage:Production ServerStaging EnvironmentCI/CD PipelineLocal Development - JohnMobile App - iOS
Least Privilege
Create separate keys for different environments:ActumX currently doesn’t support key-level permissions, but using separate keys per environment aids in tracking and revocation.
Implementation Details
Service Layer
The API key service handles all key operations: Key Functions:list(request): Retrieve all API keys for authenticated usercreate(request, payload): Generate new API keyrevoke(request, id): Revoke an existing key
/home/daytona/workspace/source/api/src/modules/api-keys/service.ts
Validation
Key creation validates the name:Cryptographic Functions
ActumX uses custom crypto utilities:/home/daytona/workspace/source/api/src/lib/crypto.ts
Context Service
TheApiKeyContextService extracts and validates keys from requests:
/home/daytona/workspace/source/api/src/services/api-key-context.service.ts
Usage Tracking
API keys track two timestamps:- createdAt: When the key was created (never changes)
- lastUsedAt: Most recent API request using this key
- Identify unused keys (revoke them)
- Detect unexpected usage patterns
- Audit key activity
Error Handling
Common API key errors:Example Error Response
Integration Examples
Node.js
Python
cURL
Best Practices Summary
- Never commit keys to version control
- Use environment variables for key storage
- Name keys descriptively (e.g., “Production API”, “Staging Bot”)
- Rotate keys every 90 days
- Revoke compromised keys immediately
- Create separate keys per environment
- Monitor
lastUsedAtto identify unused keys - Store keys in secret management systems
Next Steps
Managing API Keys
Step-by-step guide to creating and managing keys
Dashboard - API Keys
Manage keys in the web dashboard
API Reference
View detailed API key endpoints
Authentication
Learn about ActumX authentication methods