ChumiAI Docs
All requests to the ChumiAI API must be authenticated using your API key. This guide covers how to include your key in requests and handle authentication errors.
Include your API key in the X-API-Key HTTP header with every request.
curl -X GET "https://api.chumiai.app/api/v1/whatsapp/templates" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"The API key must be sent as a header, not as a query parameter or in the request body. This ensures the key doesn't get logged in URLs or cached by intermediaries.
Here's how to include the API key in common frameworks and languages:
const response = await fetch("https://api.chumiai.app/api/v1/whatsapp/templates", {
method: "GET",
headers: {
"X-API-Key": process.env.CHUMIAI_API_KEY,
"Content-Type": "application/json",
},
});
const data = await response.json();import requests
import os
response = requests.get(
"https://api.chumiai.app/api/v1/whatsapp/templates",
headers={
"X-API-Key": os.environ["CHUMIAI_API_KEY"],
"Content-Type": "application/json",
}
)
data = response.json()$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.chumiai.app/api/v1/whatsapp/templates");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: " . getenv("CHUMIAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);If authentication fails, the API will return one of these error responses:
Returned when no API key is provided or the key is invalid.
{
"error": "Unauthorized",
"message": "Missing or invalid API key. Provide a valid key in the X-API-Key header.",
"statusCode": 401
}Returned when your API key is valid but doesn't have the required scope for the requested action.
{
"error": "Forbidden",
"message": "Your API key does not have the required scope: whatsapp:send",
"statusCode": 403
}Returned when you've exceeded the rate limit for your plan.
{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Please retry after 60 seconds.",
"statusCode": 429,
"retryAfter": 60
}All API requests use the following base URL and standard headers:
| Header | Value | Required |
| :--- | :--- | :--- |
| X-API-Key | Your API key | Yes |
| Content-Type | application/json | Yes (for JSON bodies) |
| Accept | application/json | Recommended |
Base URL:
https://api.chumiai.appAll endpoints are relative to this base URL. For example, sending a template message would be:
POST https://api.chumiai.app/api/v1/whatsapp/send-template
Need an API Key?
If you haven't created an API key yet, follow the API Keys Setup guide to generate one.