Authentication
Authenticate API requests with Bearer tokens using your API key.
All API requests require authentication using a Bearer token. Generate an API key from your dashboard and include it in the Authorization header.
Note: API access requires a Hobby plan or above with active billing.
Generating an API Key
- Go to your team workspace dashboard
- Click API Keys in the sidebar
- Click Create API Key
- Copy the generated key
Using Your API Key
Include the key in the Authorization header:
curl -X POST 'https://your-domain.com/api/v1/chat' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"chatbotId": "uuid", "messages": [{"role": "user", "content": "Hello"}]}'
Header Format
Authorization: Bearer YOUR_API_KEY
Testing Your Key
Verify your API key works with the auth endpoint:
curl 'https://your-domain.com/api/v1/auth' \ -H 'Authorization: Bearer YOUR_API_KEY'
Success Response (200):
{
"id": "account-uuid",
"name": "Your Workspace",
"email": "[email protected]"
}
Invalid Key (401):
{
"message": "Missing or invalid Authorization header"
}
API Key Security
Best Practices
- Never expose keys in client-side code - API keys should only be used server-side
- Use environment variables - Don't hardcode keys in your code
- Rotate keys periodically - Delete old keys and create new ones
- Use descriptive names - Know which key is used where
Key Format
Keys are 32 random bytes encoded as base64url.
Managing API Keys
View All Keys
See all keys in Workspace > API Keys.
Delete Keys
Remove keys you no longer need:
- Go to API Keys
- Find the key
- Click Delete
- Confirm deletion
Deleted keys stop working immediately.
Error Responses
| Status | Message | Cause |
|---|---|---|
| 401 | Missing or invalid Authorization header | Header not provided |
| 401 | Invalid API key | Key is incorrect |
| 403 | API access requires a Hobby plan or above with active billing | Plan or billing status does not allow API access |
| 403 | Chatbot does not belong to this account | Agent ID does not belong to the API key's account |
Environment Setup
Node.js
const API_KEY = process.env.AGENTKIT_API_KEY;
const response = await fetch('https://your-domain.com/api/v1/chat', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
chatbotId: 'your-chatbot-id',
messages: [{ role: 'user', content: 'Hello' }],
}),
});
Python
import os
import requests
API_KEY = os.environ.get('AGENTKIT_API_KEY')
response = requests.post(
'https://your-domain.com/api/v1/chat',
headers={
'Authorization': f'Bearer {API_KEY}',
'Content-Type': 'application/json',
},
json={
'chatbotId': 'your-chatbot-id',
'messages': [{'role': 'user', 'content': 'Hello'}],
},
)
cURL
export AGENTKIT_API_KEY="your-api-key"
curl -X POST 'https://your-domain.com/api/v1/chat' \
-H "Authorization: Bearer $AGENTKIT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"chatbotId": "uuid", "messages": [{"role": "user", "content": "Hello"}]}'