Skip to main content

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 lastUsedAt timestamp
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 the api_keys table:
Source Reference: /home/daytona/workspace/source/api/src/db/schema.ts:5-16

How API Keys Work

Key Generation

When you create an API key:
  1. A cryptographically secure random key is generated
  2. The first 14 characters are stored as keyPrefix for identification
  3. The full key is hashed using SHA-256 and stored as keyHash
  4. The raw key is returned only once
The raw API key is shown only once during creation. Store it securely - ActumX cannot recover lost keys.

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

  1. Client Request: Include API key in the Authorization header
  1. Server Validation: ActumX hashes the provided key and looks up the hash
  1. Request Processing: If valid and not revoked, the request proceeds
  2. Usage Tracking: The lastUsedAt timestamp is updated

API Key Lifecycle

1. Creation

Create an API key via the API or dashboard:
Response:
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:
Response:

4. Revocation

Revoke a key if it’s compromised or no longer needed:
Response:
Revoked keys:
  • Cannot authenticate new requests
  • Remain visible in your key list (with revokedAt timestamp)
  • Cannot be un-revoked (create a new key instead)
Revoking a key immediately invalidates it. Any applications using that key will lose access.

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
DON’T:
  • Commit keys to version control
  • Hardcode keys in source code
  • Share keys via email or chat
  • Log keys in application logs

Key Rotation

  1. Create a new API key
  2. Update your application to use the new key
  3. Verify the new key works
  4. Revoke the old key
Rotate API keys every 90 days or immediately if compromised.

Key Naming

Use descriptive names to track key usage:
  • Production Server
  • Staging Environment
  • CI/CD Pipeline
  • Local Development - John
  • Mobile App - iOS
This helps you identify which key to revoke if issues arise.

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 user
  • create(request, payload): Generate new API key
  • revoke(request, id): Revoke an existing key
Source Reference: /home/daytona/workspace/source/api/src/modules/api-keys/service.ts

Validation

Key creation validates the name:

Cryptographic Functions

ActumX uses custom crypto utilities:
Source Reference: /home/daytona/workspace/source/api/src/lib/crypto.ts

Context Service

The ApiKeyContextService extracts and validates keys from requests:
Source Reference: /home/daytona/workspace/source/api/src/services/api-key-context.service.ts

Usage Tracking

API keys track two timestamps:
  1. createdAt: When the key was created (never changes)
  2. lastUsedAt: Most recent API request using this key
This helps you:
  • 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

  1. Never commit keys to version control
  2. Use environment variables for key storage
  3. Name keys descriptively (e.g., “Production API”, “Staging Bot”)
  4. Rotate keys every 90 days
  5. Revoke compromised keys immediately
  6. Create separate keys per environment
  7. Monitor lastUsedAt to identify unused keys
  8. 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