Getting Started · 2 min read
Errors
HTTP status codes and error formats returned by the Lemu AI API
Error format#
Errors return a JSON body with a detail field:
{
"detail": "Agent trigger not found"
}When the request itself is invalid (status 422), detail is a list that points at each field that failed:
{
"detail": [
{
"loc": ["body", "phone_number"],
"msg": "Field required",
"type": "missing"
}
]
}loc shows where the problem is: body for the JSON body, query for a query parameter, path for a value in the URL.
Some endpoints return detail as an object with a fixed error word your code can check and a message for people, for example Send a WhatsApp Template:
{
"detail": {
"error": "balance_too_low",
"message": "Your WhatsApp balance is too low. Recharge to keep sending."
}
}Status codes#
| Status | Meaning | Common causes |
|---|---|---|
400 | Bad request | Telephony isn't set up for your organization, the carrier rejected the call, or a filter value is malformed |
401 | Unauthorized | Missing, wrong, or archived API key |
402 | Payment required | Your plan's call minutes or contact limit is used up, or your WhatsApp balance is too low |
403 | Forbidden | The resource belongs to another organization, or a filter you sent isn't allowed |
404 | Not found | The id doesn't exist in your organization, or an API Trigger was removed or turned off |
409 | Conflict | A contact with the same external_id already exists |
422 | Unprocessable entity | The body or a query parameter failed validation (see the format above) |
500 | Internal server error | Something went wrong on our side |
502 | Bad gateway | WhatsApp or the email service refused the message. detail holds their reason |
Handling errors#
- Retry
500responses with exponential backoff. They are usually temporary. - Don't retry
4xxresponses without changing the request. They describe a problem with the request, the key, or your plan. - On
422, read thelocof each entry to find the field to fix. - On
401for a key that used to work, check whether it was archived in Settings → API Keys.
Was this page helpful?
Docs