Skip to main content

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
Each API key is scoped to your user account and can be revoked independently.

API Key Format

ActumX API keys follow this format:
Example: xk_live_a1b2c3d4e5f6...
The key generation uses cryptographically secure random bytes. See api/src/lib/crypto.ts:15-17.

Creating API Keys

1

Create a New API Key

Make a POST request to generate a new API key:
Response:
Critical: Save the apiKey value immediately! It cannot be retrieved after creation.
2

Store the API Key Securely

Store your API key in a secure location:Environment Variable:
Configuration File (.env):
.env
Never commit API keys to version control. Add .env to your .gitignore.

Using API Keys

Bearer Token Authentication

Include your API key in the Authorization 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):
Response:
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:
Revocation is immediate. Any requests using the revoked key will fail with a 401 error.

Key Implementation Details

How API Keys are Stored

From api/src/modules/api-keys/service.ts:39-53:
  1. Generate a random API key using newApiKey()
  2. Extract the first 14 characters as the keyPrefix (for display)
  3. Hash the full key using SHA-256
  4. Store only the hash in the database (never the plain key)
  5. Return the plain key to the user (only once)

Authentication Flow

When you make an authenticated request:
  1. Extract the API key from the Authorization header
  2. Hash the provided key
  3. Look up the key by its hash in the database
  4. Verify it’s not revoked (revokedAt is null)
  5. Update lastUsedAt timestamp
  6. 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 keys

Troubleshooting

Possible Causes:
  • API key is missing from the request
  • API key format is incorrect
  • API key has been revoked
  • API key was never created successfully
Solutions:
  • Verify the Authorization header format: Bearer xk_live_...
  • List your API keys to check if the key exists and is not revoked
  • Create a new API key if needed
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)
API keys cannot be retrieved after creation for security reasons.Solution:
  1. Revoke the lost key
  2. Create a new key
  3. Update your application configuration

Next Steps

Top Up Credits

Add credits to your account for using paid endpoints

Make Paid Requests

Learn how to use x402 payment protocol