What are API Keys?
API keys in ActumX are used to authenticate requests to protected endpoints, including:- x402 paid endpoints
- MCP (Model Context Protocol) tools
- Protected resources and agent operations
API Key Format
ActumX API keys follow this format:xk_live_a1b2c3d4e5f6...
The key generation uses cryptographically secure random bytes. See
api/src/lib/crypto.ts:15-17.Creating API Keys
Using API Keys
Bearer Token Authentication
Include your API key in theAuthorization header:
MCP Tool Authentication
For MCP (Model Context Protocol) endpoints, use the same Bearer token:Listing API Keys
View all your API keys (active and revoked):Only the key prefix is shown in the list. The full key is never retrievable after creation.
Revoking API Keys
Revoke a key to immediately prevent it from authenticating requests:Key Implementation Details
How API Keys are Stored
Fromapi/src/modules/api-keys/service.ts:39-53:
- Generate a random API key using
newApiKey() - Extract the first 14 characters as the
keyPrefix(for display) - Hash the full key using SHA-256
- Store only the hash in the database (never the plain key)
- Return the plain key to the user (only once)
Authentication Flow
When you make an authenticated request:- Extract the API key from the
Authorizationheader - Hash the provided key
- Look up the key by its hash in the database
- Verify it’s not revoked (
revokedAtisnull) - Update
lastUsedAttimestamp - Proceed with the request
Security Best Practices
Rotate Keys Regularly
Create new keys and revoke old ones periodically to minimize exposure
Use Descriptive Names
Name keys by purpose (e.g., “Production API”, “CI/CD Pipeline”) for easy identification
Revoke Unused Keys
Immediately revoke keys that are no longer needed or may be compromised
Monitor Usage
Check
lastUsedAt timestamps to identify inactive or suspicious keysTroubleshooting
401 Unauthorized Error
401 Unauthorized Error
Key Not Working After Creation
Key Not Working After Creation
Check:
- Ensure you copied the entire key (including
xk_live_prefix) - Verify there are no extra spaces or line breaks
- Confirm you’re using the latest key (not an old one)
Cannot Retrieve Lost Key
Cannot Retrieve Lost Key
API keys cannot be retrieved after creation for security reasons.Solution:
- Revoke the lost key
- Create a new key
- Update your application configuration