Authentication
Securely authenticate your requests with AMP API keys.
API Keys
AMP uses API keys to authenticate requests. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, etc.
Key Format
AMP API keys follow this format:
amp_sk_live_1234567890abcdefamp_- Prefix identifying this as an AMP keysk_- Indicates this is a secret keylive_- Environment (live or test)- The rest is your unique key identifier
Getting Your API Key
- Sign up at amp-protocol.dev
- Navigate to your dashboard
- Click "API Keys" in the sidebar
- Create a new key or copy an existing one
💡 Tip: You can have multiple API keys for different environments (development, staging, production).
Using API Keys
TypeScript / JavaScript
Pass your API key when initialising the client:
import { AMP } from '@amp-protocol/client';
const amp = new AMP({
apiKey: process.env.AMP_API_KEY,
});Python
from amp_protocol import AMP
import os
amp = AMP(api_key=os.environ.get("AMP_API_KEY"))REST API
Include the API key in the Authorization header:
curl https://api.amp-protocol.dev/v1/context \
-H "Authorization: Bearer amp_sk_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"userId": "user_123",
"task": "build a feature"
}'Test Mode vs Live Mode
AMP provides two environments for development and production:
Test Mode
Keys start with amp_sk_test_
- Free unlimited requests
- Data is isolated from production
- Perfect for development and testing
- Profiles reset monthly
Live Mode
Keys start with amp_sk_live_
- Production environment
- Real user profiles and data
- Metered billing applies
- Data persists indefinitely
Environment Variables
Store your API keys in environment variables to keep them secure:
# Development
AMP_API_KEY=amp_sk_test_1234567890abcdef
# Production (use different .env.production file)
AMP_API_KEY=amp_sk_live_9876543210fedcba⚠️ Security Warning:
- Never commit
.envfiles to version control - Add
.envto your.gitignore - Rotate keys immediately if they're exposed
- Use different keys for each environment
Key Management Best Practices
Rotation
Rotate your API keys regularly (every 90 days recommended):
- Generate a new key in your dashboard
- Update your environment variables
- Deploy the changes
- Delete the old key after confirming the new one works
Scope Limitation
Create separate API keys for different services or team members. This allows you to:
- Track usage per service
- Revoke access without affecting other services
- Set different rate limits per key
Monitoring
Monitor your API key usage in the dashboard:
- Request volume and rate
- Error rates
- Unusual patterns or spikes
- Geographic distribution of requests
Rate Limits
API keys are subject to rate limits based on your plan:
| Plan | Requests/Second | Monthly Limit |
|---|---|---|
| Starter | 10 req/s | 100,000 |
| Pro | 100 req/s | 1,000,000 |
| Enterprise | Custom | Unlimited |
When you exceed rate limits, you'll receive a 429 Too Many Requests response. Implement exponential backoff to handle this gracefully.
Troubleshooting
401 Unauthorized
If you receive a 401 error:
- Check that your API key is correctly set in environment variables
- Ensure the Authorization header is properly formatted
- Verify the key hasn't been deleted or revoked
- Check that you're using the correct environment (test vs live)
403 Forbidden
If you receive a 403 error:
- Your key may not have permission for this operation
- Your account may have restrictions
- Contact support if the issue persists