Skip to main content

Error handling

This page describes the HTTP status codes, the error response format, and best practices for handling errors in the Flixer Pro API.

HTTP status codes

Error response format

Error responses follow the standard NestJS format with three fields:
Fields:
  • statusCode — The HTTP status code (matches the response status)
  • message — A human-friendly error description. For validation errors this can be an array of strings (one per field that fails)
  • error — The HTTP status text (e.g. Bad Request, Unauthorized)
Every response also includes an X-Request-Id header. Keep this value and mention it in support requests — it makes it possible to trace the request on the server side.

Common errors

400 — Bad Request (Validation error)

Causes:
  • A required field is missing (e.g. customerName or title when creating a lead)
  • A field value does not meet the rules (e.g. a field that is too long)
Solutions:
  1. Read the message field of the response — it describes which field is causing the problem
  2. Validate required fields on the client side before sending them
  3. Consult the endpoint documentation for the field requirements

401 — Unauthorized (Not Authenticated)

Causes:
  • The X-API-Key header is missing from the request
  • The API key is invalid or has been revoked
Solutions:
  1. Make sure you send the header:
  2. Check that the key has not been revoked in Settings > API keys
  3. Create a new key if needed

403 — Forbidden (Insufficient Scope)

Causes:
  • The key is valid, but lacks the scope this endpoint requires (e.g. leads:write for creating a lead)
Solutions:
  1. Check which scope the endpoint requires (see Authentication)
  2. Create a key with the correct scopes, or use a key with the full scope

429 — Too Many Requests (Rate Limit)

Causes:
  • Too many requests were sent in a short period
Solutions:
  1. Implement retry logic with exponential backoff (see below)
  2. Reduce the frequency of your requests; do not poll more often than necessary

500 — Internal Server Error (Server Error)

Causes:
  • An unexpected error in the server application
Solutions:
  1. These errors are usually temporary — implement retry logic with exponential backoff
  2. Wait a few seconds and try again
  3. If the problem persists, mention the X-Request-Id to the support team

Error handling in code

JavaScript/TypeScript

Python

Retry strategy

Implement exponential backoff for 5xx errors and 429:
Only repeat requests when it is safe to do so. GET requests are idempotent and always safe to repeat. Be careful with POST /leads: only repeat after a 5xx or a network error (where the lead probably was not created), not after a 400/401/403.

Best practices

  1. Always check response.ok — do not assume every request succeeds
  2. Read the message field — on a 400 it tells you exactly what went wrong
  3. Keep the X-Request-Id — indispensable for support requests
  4. Exponential backoff — for 5xx and 429, with jitter
  5. Set timeouts — prevent requests from hanging indefinitely
  6. Use minimal scopes — limit the impact if a key leaks