Authentication
AgentGate uses organization API keys to authenticate all API requests. This page explains how to create, use, and manage your API keys.Overview
- All API requests require authentication via API key
- Keys are scoped to an organization, not individual users
- Keys can have limited scopes for security
- Use the
Authorizationheader with Bearer token format
Organization API Keys
Key Format
AgentGate API keys follow this format:org_prefix identifies it as an organization keylive_indicates a production key- The remaining characters are a unique identifier
Creating API Keys
1
Access API Key Settings
Log in to your AgentGate Dashboard and navigate to Settings → API Keys.
2
Create New Key
Click Create API Key and provide a descriptive name (e.g., “Production Backend”, “CI/CD Pipeline”).
3
Select Scopes
Choose the permissions your key needs. Use the principle of least privilege—only grant scopes that are necessary.
4
Copy and Store
Copy your API key immediately. It won’t be shown again. Store it securely in your environment variables or secrets manager.
Key Scopes and Permissions
API keys can be scoped to limit their capabilities:| Scope | Description |
|---|---|
work-orders:write | Create work orders |
work-orders:read | Read work order details |
runs:read | Read run status and results |
runs:write | Cancel runs |
credits:read | Check credit balance |
webhooks:read | List and view webhooks |
webhooks:write | Create, update, delete webhooks |
templates:read | List and view templates |
templates:write | Create, update, delete templates |
* | Full access (wildcard) |
Using API Keys
Header Format
Include your API key in theAuthorization header:
Examples
Security Best Practices
Never Commit Keys to Source Control
Use Environment Variables
Store keys in environment variables and access them in your code:Minimum Necessary Scopes
Create keys with only the scopes needed for their specific use case:- Backend service:
work-orders:write,runs:read,webhooks:write - Monitoring dashboard:
runs:read,credits:read - CI/CD integration:
work-orders:write,runs:read
Rotate Keys Periodically
Rotate API keys regularly and immediately if you suspect compromise:- Create a new API key with the same scopes
- Update your applications to use the new key
- Verify applications work with the new key
- Revoke the old key
Key Rotation
When to Rotate
- Regularly: Every 90 days as a best practice
- Immediately: If a key may have been exposed
- On team changes: When team members leave
Zero-Downtime Rotation
1
Create New Key
Create a new API key with identical scopes to the existing key.
2
Update Applications
Deploy your applications with the new API key.
3
Verify
Confirm all applications work correctly with the new key.
4
Revoke Old Key
Delete the old API key from the dashboard.
Troubleshooting
Common Errors
401 Unauthorized - Invalid API Key
401 Unauthorized - Invalid API Key
401 Unauthorized - Missing API Key
401 Unauthorized - Missing API Key
403 Forbidden - Insufficient Permissions
403 Forbidden - Insufficient Permissions
The API key doesn’t have the required scope.Solutions:
- Check the key’s scopes in the dashboard
- Create a new key with the required scopes
- Review the endpoint’s required scopes in the API reference
Debugging Steps
- Verify the header format:
Authorization: Bearer <key> - Check key validity: Ensure the key exists in your dashboard
- Confirm scopes: Match required scopes with your key’s scopes
- Test with cURL: Isolate issues by testing directly with cURL