Ilana Docs
API

Error Handling

Error Response Format

All error responses follow this shape:

{
  "error": "Human-readable error message",
  "code": "ERROR_CODE"
}
FieldTypeDescription
errorstringHuman-readable error description
codestringMachine-readable error code for programmatic handling

Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid embed token
FORBIDDEN403Token is valid but the requesting domain is not allowed
NOT_FOUND404Bot not found or disabled
RATE_LIMITED429Too many requests for this (botId, domain) pair
MESSAGE_CAP_EXCEEDED429Monthly message limit reached for the organization's plan
INVALID_REQUEST400Malformed request body or missing required fields
INTERNAL_ERROR500Unexpected server error
SERVICE_UNAVAILABLE503Service temporarily unavailable

MESSAGE_CAP_EXCEEDED

When the monthly message cap is exceeded, the error response includes additional fields:

{
  "error": "MESSAGE_CAP_EXCEEDED",
  "code": "MESSAGE_CAP_EXCEEDED",
  "tier": "free",
  "limit": 100,
  "resetAt": "2026-03-01T00:00:00.000Z"
}
FieldTypeDescription
tierstringThe organization's plan name
limitnumberMonthly message limit for the plan
resetAtstringISO 8601 timestamp when the limit resets

Security

The runtime validates requests in this exact order:

  1. Parse the Origin header
  2. Verify the embed token signature and expiration
  3. Compare the token's domain claim to the Origin host
  4. Check the database allowlist for (botId, domain)
  5. Apply rate limits per (botId, domain)

Auth errors always return a generic "Unauthorized" message to prevent information leakage about which bots or domains exist.