X-API-Key header of every request.
API key basics
API keys are tied to your tenant account and have full access to all resources within that account. Each key has:- Name: A label to identify the key’s purpose
- Prefix: First 8 characters shown for identification (e.g.,
rl_live_a1b2...) - Scopes: Optional permission restrictions (coming soon)
- Expiration: Optional expiration date
Creating API keys
Via the dashboard
- Sign in to app.relayai.dev
- Navigate to Settings > API Keys
- Click Create API Key
- Enter a descriptive name (e.g., “Production Server”, “CI/CD Pipeline”)
- Copy the key immediately
Via the API
Create keys programmatically using an existing key:The full
key value is only returned on creation. Store it securely.Using API keys
Include the key in theX-API-Key header:
Listing API keys
View all keys for your account:Revoking API keys
Revoke a key to immediately invalidate it:Security best practices
Environment variables
Never hardcode API keys in your source code. Use environment variables:Python
Git ignore
Add API key files to your.gitignore:
.gitignore
Rotate keys regularly
Create new keys periodically and revoke old ones:- Create a new key
- Update your applications to use the new key
- Verify everything works
- Revoke the old key
Use descriptive names
Name keys by their purpose to make auditing easier:- “Production API Server”
- “CI/CD Pipeline”
- “Local Development - John’s Laptop”
- “Monitoring Service”
Set expiration dates
For temporary or time-limited access, set an expiration:Error responses
401 Unauthorized
Returned when:- No
X-API-Keyheader is provided - The API key is invalid or revoked
- The API key has expired
Troubleshooting
| Issue | Solution |
|---|---|
| ”Invalid or missing API key” | Verify the key is correct and hasn’t been revoked |
| ”API key expired” | Create a new key |
| Request works in curl but not in code | Check for extra whitespace or encoding issues in the key |
