Learn how to handle errors when working with the Lightfast API.
Error Response Format
All errors follow a consistent JSON structure:
| Field | Description |
|---|---|
error | Error code (uppercase) |
message | Human-readable error description |
requestId | Unique request ID for debugging |
Error Codes
INVALID_JSON (400)
The request body contains invalid JSON.
Common causes:
- Malformed JSON syntax
- Missing closing brackets or quotes
- Invalid escape sequences
VALIDATION_ERROR (400)
Request parameters failed schema validation.
Common causes:
- Missing required fields (e.g.,
queryfor search) - Invalid parameter types
- Values outside allowed ranges (e.g.,
limit > 100)
UNAUTHORIZED (401)
Authentication failed or was not provided.
Common causes:
- Missing
Authorizationheader - Invalid API key
- Expired or revoked API key
- Incorrect
Bearerprefix
FORBIDDEN (403)
The authenticated user does not have access to the organization.
Common causes:
- User is not a member of the organization
- API key does not have access to the requested resource
NOT_FOUND (404)
The requested resource does not exist.
Common causes:
- Invalid resource ID
- Content ID does not exist
METHOD_NOT_ALLOWED (405)
The HTTP method is not supported for this endpoint.
Solution: All API endpoints use POST method.
CONFIG_ERROR (500)
The organization is not properly configured.
Solution: Ensure the organization has connected sources and completed initial indexing.
INTERNAL_ERROR (500)
An unexpected server error occurred.
Solution: Retry with exponential backoff. If the error persists, contact support with the requestId.
Error Handling Examples
Basic Error Handling
Retry with Exponential Backoff
TypeScript Error Types
Error Code Reference
| Code | Status | Description | Retry? |
|---|---|---|---|
INVALID_JSON | 400 | Invalid JSON body | No |
VALIDATION_ERROR | 400 | Schema validation failed | No |
UNAUTHORIZED | 401 | Authentication failed | No |
FORBIDDEN | 403 | Access denied | No |
NOT_FOUND | 404 | Resource not found | No |
METHOD_NOT_ALLOWED | 405 | Wrong HTTP method | No |
CONFIG_ERROR | 500 | Organization not configured | No |
INTERNAL_ERROR | 500 | Server error | Yes |
Next Steps
- Authentication — API key setup and security
- POST /v1/search — Search API reference
- API Overview — Getting started guide