API Keys
Managing SwiftClaw API keys
API Keys
API keys authenticate your requests to SwiftClaw agents.
Creating API Keys
Via CLI
# Create new API key
swiftclaw keys create my-agent --name production
# Output:
# API Key: sk_live_abc123...
# Name: production
# Created: 2024-03-08 10:30:00Via Dashboard
- Navigate to your agent
- Click "Settings" → "API Keys"
- Click "Create New Key"
- Enter key name
- Copy and save the key securely
Save Immediately: API keys are only shown once. Store them securely.
Using API Keys
REST API
curl https://api.swiftclaw.io/agents/my-agent/invoke \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'Python SDK
from swiftclaw import SwiftClaw
client = SwiftClaw(api_key="sk_live_abc123...")
response = client.agents.invoke(
agent="my-agent",
message="Hello"
)Node.js SDK
import { SwiftClaw } from '@swiftclaw/sdk';
const client = new SwiftClaw({
apiKey: 'sk_live_abc123...'
});
const response = await client.agents.invoke({
agent: 'my-agent',
message: 'Hello'
});Managing API Keys
List Keys
# List all keys
swiftclaw keys list my-agent
# Output:
# NAME KEY CREATED LAST USED
# production sk_live_abc123... 2024-03-01 10:00 2024-03-08 09:30
# staging sk_live_def456... 2024-03-05 14:30 2024-03-07 16:45Rotate Keys
# Create new key
swiftclaw keys create my-agent --name production-v2
# Update your application
# Verify new key works
# Revoke old key
swiftclaw keys revoke my-agent --key sk_live_abc123...Revoke Keys
# Revoke specific key
swiftclaw keys revoke my-agent --key sk_live_abc123...
# Revoke by name
swiftclaw keys revoke my-agent --name productionKey Permissions
Read-Only Keys
# Create read-only key
swiftclaw keys create my-agent \
--name readonly \
--permissions readFull Access Keys
# Create full access key
swiftclaw keys create my-agent \
--name admin \
--permissions read,write,deleteKey Metadata
Add metadata to keys for tracking:
swiftclaw keys create my-agent \
--name production \
--metadata environment=production,team=backendRate Limits
API keys have rate limits:
- Live Keys: 1000 requests/minute
- Test Keys: 10000 requests/minute
Check rate limit status:
swiftclaw keys status my-agent --key sk_live_abc123...Security Best Practices
1. Use Environment Variables
# .env
SWIFTCLAW_API_KEY=sk_live_abc123...2. Never Commit Keys
Add to .gitignore:
.env
.env.local
*.key3. Rotate Regularly
Set up automatic rotation:
swiftclaw keys rotate my-agent \
--interval 90d \
--auto4. Monitor Usage
Set up alerts for unusual activity:
swiftclaw alerts create \
--agent my-agent \
--metric api-key-usage \
--threshold 1000 \
--window 1hTroubleshooting
Invalid API Key
Error: 401 Unauthorized - Invalid API keySolutions:
- Verify key is correct
- Check key hasn't been revoked
- Ensure key has required permissions
Rate Limit Exceeded
Error: 429 Too Many RequestsSolutions:
- Implement exponential backoff
- Reduce request rate
- Upgrade to higher tier
Next Steps
How is this guide ?
Last updated on