Skip to main content

Error handling

The Flex Forward API uses standard HTTP status codes and structured error responses. This page covers the error formats, status code meanings, and guidance for handling failures.

Error response formats

The API returns three error response shapes depending on the type of failure. Understanding which shape to expect helps you write correct error-parsing logic.

Standard error

Returned for authentication failures, not-found errors, and server errors:

Validation error

Returned for request validation failures (HTTP 400). Includes a details array with field-level error information:
Each entry in details contains:

HTTP status codes

Validation errors (400)

Validation errors indicate that the request body does not meet the API schema requirements. The response always includes a details array with specific field paths. Common causes:
  • Missing required fields (shipment.shipTo, courier, idempotencyKey)
  • Invalid field formats (country code, email, phone number)
  • Invalid numeric values (weight must be greater than 0)
Fix all validation errors listed in the details array before retrying. The same idempotencyKey can be reused after a 400 response because no label was created.

Authentication errors (401 / 403)

401 Unauthorized

The x-rr-apikey or x-rr-apitoken header is missing or invalid:
Verify that both headers are present:

403 Forbidden

The credentials are valid but the caller does not have access to the requested resource. This occurs when attempting to retrieve a label or tracking information that belongs to a different account:

Downstream courier errors (502)

When the courier service returns an error, the API responds with HTTP 502. The label is persisted in the database with status: failed and includes the courier error details:
The error object contains:
A 502 response means the label request reached the courier and was rejected. Before retrying, review the error message — some courier errors (e.g., address validation) are not transient and require request changes.

Retryable vs non-retryable errors

See Idempotency and Retries for the recommended retry strategy.

Troubleshooting

All POST requests must include Content-Type: application/json. Without it, the request body will not be parsed and the API returns a 400 error.
All requests must use HTTPS. Verify you are using the correct environment URL: https://api.flexforward.com (production) or https://sandbox.flexforward.com (development).
The id parameter in GET /labels/{id} and GET /tracking/{id} must be a valid UUID. Passing a tracking number or other identifier format will return a 404 error.
A status: failed response with HTTP 201 or 200 means the label was persisted but the courier rejected the request. Check the error object for the courier’s error message. Common causes: invalid address, unsupported destination, or courier account configuration issues.