API Keys
The CommodityAI API uses API keys for authentication. All API requests must include your API key in the request headers.Getting Your API Key
- Log in to your CommodityAI dashboard
- Navigate to Settings → API Keys
- Click Generate New API Key
- Copy and securely store your API key
Authentication Header
Include your API key in theAuthorization header of every request:
Request Format
All API requests should:- Use HTTPS
- Include the
Authorizationheader with your API key - Use query parameters for filtering and pagination
Example Request
Company Scope
All API operations are automatically scoped to your company. You can only access:- Source record definitions and records that belong to your company
- Custom object definitions and records that belong to your company
API Key Types
CommodityAI provides two types of API keys:- Live Keys (
cai_live_...): Access production data - Test Keys (
cai_test_...): Access test environment data (coming soon)
Error Responses
When authentication fails, you’ll receive a401 Unauthorized response:
| Status Code | Error | Description |
|---|---|---|
401 | Unauthorized | Invalid or missing API key |
403 | Forbidden | API key lacks required permissions |
429 | Too Many Requests | Rate limit exceeded |
API Key Management
Security Best Practices
- Rotate regularly: Generate new API keys periodically
- Use environment variables: Store API keys in environment variables, not in code
- Separate keys for environments: Use different API keys for development, staging, and production
- Monitor usage: Review API key usage in the dashboard regularly
Revoking API Keys
To revoke an API key:- Go to Settings → API Keys
- Click Revoke next to the key you want to disable
- Update any applications using that key with a new one
Revoking an API key immediately invalidates it. Any applications using the revoked key will start receiving
401 Unauthorized errors.