API Keys
API keys provide programmatic access to Atlas services for backend services and automation scripts.
What is an API Key?
An API key is a secret credential that:
Authenticates backend services and scripts
Associates requests with a specific project
Inherits the project's team service policy
Enables service-to-service communication
┌─────────────────────────────────────────────────────────────────────────────┐
│ API KEY STRUCTURE │
└─────────────────────────────────────────────────────────────────────────────┘
API Key: sk-llm-api-a1b2c3d4e5f6g7h8i9j0...
├─┘├──────┘├──────────────────────┘
│ │ │
│ │ └── Random secret (32+ characters)
│ │
│ └── Project identifier (optional, for readability)
│
└── Prefix (sk- = secret key)
Associated Data:
┌─────────────────────────────────────────────────────────────────────────┐
│ project_id: 5ac942ba-0290-48a7-be6e-7ea58cd40b68 │
│ team_id: ab2785b2-b5d0-4926-92fb-00aae5ec860a │
│ org_id: 4047160a-abb2-497c-bf0c-3f4ab7cb0b16 │
│ created_by: [email protected] │
│ created_at: 2025-01-15T10:30:00Z │
│ expires_at: 2026-01-15T10:30:00Z (optional) │
│ status: active │
│ last_used: 2025-01-20T14:30:00Z │
└─────────────────────────────────────────────────────────────────────────┘API Key Lifecycle
Creation
Storage (Security)
⚠️ Critical: The API key is hashed before storage. The original key cannot be recovered.
Usage
Revocation
When an API key is compromised or no longer needed:
Authentication Flow
When a request includes an API key:
API Key vs JWT Token
Use Case
Backend services, scripts
Web browsers, SPAs
Authentication
X-Atlas-API-Key header
Authorization: Bearer header
Expiration
Optional, can be years
24 hours
Revocation
Immediate
Wait for expiration
Context
Project-level
User-level with selected project
Permissions
Team policy only
Full RBAC
Refresh
Generate new key
Refresh token
Managing API Keys
Admin Dashboard
Access at: /admin/api-keys
Name
Key identifier
Project
Associated project
Team
Associated team
Status
active/revoked/expired
Created
Creation date
Expires
Expiration date (if set)
Last Used
Last usage timestamp
Actions
Create
Generate new API key
View
See key details (not the key itself)
Revoke
Immediately disable key
Delete
Remove key record
Security Best Practices
Storage
Store in environment variables
Hardcode in source code
Use secrets manager
Commit to git
Encrypt at rest
Store in plain text files
Rotate regularly
Share keys between services
Access Control
One key per service/environment
Share keys across services
Set expiration dates
Create keys that never expire
Revoke unused keys
Leave old keys active
Audit key usage
Ignore usage patterns
Operations
Monitor for anomalies
Ignore usage spikes
Alert on failures
Ignore 401 errors
Rotate after incidents
Keep compromised keys
Document key ownership
Create orphan keys
Code Examples
Python
JavaScript/TypeScript
cURL
Troubleshooting
"401 Unauthorized: Invalid API key"
Causes:
Key doesn't exist
Key is malformed
Typo in key
Solutions:
Verify key is correct (check for extra spaces)
Generate new key if unsure
Check key format starts with
sk-
"401 Unauthorized: API key revoked"
Causes:
Admin revoked the key
Key was compromised
Solutions:
Generate new API key
Update your service configuration
"401 Unauthorized: API key expired"
Causes:
Key passed its expiration date
Solutions:
Generate new API key
Consider longer expiration or no expiration
"403 Forbidden: Service not allowed"
Causes:
Key's team doesn't have access to the service
Solutions:
Check team's service policy
Add service to team's allowed_services
Use key from different team
"API key not working in production"
Causes:
Using dev key in production
Environment variable not set
Key not deployed
Solutions:
Verify correct environment
Check deployment configuration
Verify key is for production project
Last updated