Skip to content

Errors ​

The API uses conventional HTTP status codes and returns structured error responses.

Error Response Format ​

json
{
  "success": false,
  "error": {
    "code": "error_code",
    "message": "Human-readable description"
  }
}

HTTP Status Codes ​

CodeMeaning
200Success
401Unauthorized — invalid or missing API key
403Forbidden — insufficient scope or site access denied
404Not Found — resource doesn't exist or you don't have access
405Method Not Allowed — wrong HTTP method for this endpoint
422Validation Error — invalid input data
429Rate Limited — too many requests
500Internal Error — server-side error

Error Codes ​

CodeHTTPDescription
invalid_api_key401API key is missing, invalid, expired, or revoked
scope_denied403API key doesn't have the required scope
site_access_denied403API key is restricted and doesn't have access to this site
resource_not_found404The requested resource was not found
method_not_allowed405HTTP method is not supported for this endpoint
validation_error422Input validation failed (check the message for details)
rate_limit_exceeded429Rate limit exceeded for this API key
internal_error500Unexpected server error

Handling Errors ​

javascript
const response = await fetch('https://api.looma.chat/v1/leads', {
  headers: { 'Authorization': 'Bearer lm_your_key' }
});

const data = await response.json();

if (!data.success) {
  console.error(`Error: ${data.error.code} — ${data.error.message}`);

  switch (response.status) {
    case 401: // Re-authenticate or check key
    case 403: // Check scopes or site access
    case 404: // Resource doesn't exist
    case 429: // Wait and retry
      const retryAfter = response.headers.get('Retry-After');
      await new Promise(r => setTimeout(r, retryAfter * 1000));
      break;
  }
}

Looma.chat — AI-powered e-commerce search & chat