Authentication¶
All API requests (except the health check) require authentication via an API key.
Getting an API key¶
- Register for an Icana.AI account
- Log in to your dashboard
- Go to Settings → API Keys
- Click Create API Key and give it a name
- Copy the key immediately — it is only shown once
For more details on managing keys, see the API Keys dashboard guide.
Using your API key¶
Include your API key in the X-API-Key header with every request:
Key format¶
API keys follow the format sk_test_ or sk_live_ followed by a random string:
Verifying your key¶
Test that your key is valid by calling the usage endpoint:
curl -s -o /dev/null -w "%{http_code}" \
https://api.icana.ai/api/v1/usage \
-H "X-API-Key: sk_test_your_api_key_here"
| Response | Meaning |
|---|---|
200 |
Key is valid and active |
401 |
Key is invalid, revoked, or missing |
Security best practices¶
Keep your API key secret
Your API key grants access to your account and will incur charges for usage. Treat it like a password.
- Never commit keys to version control. Use environment variables instead:
- Never expose keys in client-side code. API calls should always be made from your server.
- Rotate keys regularly. You can create up to 3 keys at a time, making it easy to rotate without downtime.
- Revoke compromised keys immediately via the API Keys page in your dashboard.
Error responses¶
If authentication fails, you'll receive a 401 Unauthorized response:
See the Errors page for all error codes.