LemuAIDocs

Getting Started · 2 min read

Errors

HTTP status codes and error formats returned by the Lemu AI API

Open in ChatGPTOpen in ClaudeMarkdown

Error format#

Errors return a JSON body with a detail field:

JSON
{
  "detail": "Agent trigger not found"
}

When the request itself is invalid (status 422), detail is a list that points at each field that failed:

JSON
{
  "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:

JSON
{
  "detail": {
    "error": "balance_too_low",
    "message": "Your WhatsApp balance is too low. Recharge to keep sending."
  }
}

Status codes#

StatusMeaningCommon causes
400Bad requestTelephony isn't set up for your organization, the carrier rejected the call, or a filter value is malformed
401UnauthorizedMissing, wrong, or archived API key
402Payment requiredYour plan's call minutes or contact limit is used up, or your WhatsApp balance is too low
403ForbiddenThe resource belongs to another organization, or a filter you sent isn't allowed
404Not foundThe id doesn't exist in your organization, or an API Trigger was removed or turned off
409ConflictA contact with the same external_id already exists
422Unprocessable entityThe body or a query parameter failed validation (see the format above)
500Internal server errorSomething went wrong on our side
502Bad gatewayWhatsApp or the email service refused the message. detail holds their reason

Handling errors#

  • Retry 500 responses with exponential backoff. They are usually temporary.
  • Don't retry 4xx responses without changing the request. They describe a problem with the request, the key, or your plan.
  • On 422, read the loc of each entry to find the field to fix.
  • On 401 for a key that used to work, check whether it was archived in Settings → API Keys.