Error Handling
RxScale APIs share most of their error formats. This page documents the error formats, HTTP status codes, and common error scenarios, and says where an API differs.HTTP Status Codes
Error Response Formats
RxScale APIs use three error response formats depending on the error type.Standard Error
Most errors return a simple error string:"Resource not found"— Resource doesn’t exist or you lack access"Bad request"— Generic error; the reason is recorded only in RxScale’s logs, not in the response. In the External Pharmacy API it also covers requests RxScale refuses, such as changing the status of a cancelled order — see External Pharmacy API Error Responses"Missing required parameters: from and to"— Specific missing parameter info
Authentication Error
Authentication failures, and permission failures in the Management API and the Public API, return a code and description:
The External Pharmacy API does not use
permission_denied: a key without the required permission gets 403 with {"error": "Permission denied"}. See External Pharmacy API Error Responses.
Validation Error
Schema validation failures return field-level error details:External Pharmacy API Error Responses
The External Pharmacy API returns the error responses below. Rely on the HTTP status code, and treat the body as additional information.{"error": "Bad request"} is a generic error. The reason is recorded only in RxScale’s logs, not in the response. Besides unexpected errors, it covers:
- requests RxScale refuses, for example changing the status of a cancelled order;
- on endpoints that take a request body (except
complete_order), a body that is not valid JSON or is sent withoutContent-Type: application/json; - a group-wide API key without a
pharmacy_uid, or with apharmacy_uidoutside its pharmacy group.
PATCH /pharmacy_orders/{uid}/complete_order has three more 400 variants:
{"error": ["Invalid JSON in request body"]}— the request body is not valid JSON. Hereerroris a list.{"error": {...}, "pharmacy": {"uid": "...", "display_name": "..."}}— the request body failed validation, for example because of an unsupportedcarrier.pharmacyidentifies the pharmacy the request was for.{"error": "<message>"}— you sent tracking links for an order that is already completed.
Common Error Scenarios
401 — Missing API Key
401 — Missing API Key
Request:Response:Fix: Include the
X-API-Key header in your request.403 — Insufficient Permissions
403 — Insufficient Permissions
Request: Trying to write with a read-only API key.Management API and Public API — use External Pharmacy API:Fix: Check your API key’s permissions. You may need to create a new key with the required permissions.
code to detect this error; description is human-readable text:404 — Resource Not Found
404 — Resource Not Found
Request: Accessing a resource with an invalid UID or without access.Fix: Verify the resource UID is correct. If you’re sure the UID is valid, check that your API key has permission to access the resource.
400 — Validation Error
400 — Validation Error
Request: Submitting an invalid request body.Fix: Check each field listed in the error and provide valid values.
409 — Duplicate Resource
409 — Duplicate Resource
Request: Creating a resource that already exists.Fix: The resource already exists. Use a GET request to retrieve it, or use PATCH to update it.
413 — Request Body Too Large
413 — Request Body Too Large
Request: A body above the 32 MiB cap.Fix: Split the payload across several requests.
429 — Rate Limit Exceeded
429 — Rate Limit Exceeded
You’ve exceeded the rate limit. The response body is HTML, not JSON:No
Retry-After or X-RateLimit-* headers are sent. Fix: Wait at least one second
— a full rate-limit window — then retry. See Rate Limits for details
and best practices.Best Practices
Always check the HTTP status code first
Always check the HTTP status code first
The status code tells you the error category. Parse the response body for details only after checking the status.
Handle 404 defensively
Handle 404 defensively
A
404 can mean the resource doesn’t exist OR you lack access. Don’t assume which — verify your API key permissions alongside the resource UID.Implement exponential backoff for 429
Implement exponential backoff for 429
When rate limited, wait and retry with increasing delays. Never retry immediately in a tight loop.
Log the full error response
Log the full error response
For debugging, log the entire response body including status code and headers. RxScale support may ask for these details.