Skip to main content
Every error from the Ecommerce API follows a consistent JSON envelope so you can handle failures the same way across every endpoint. Whether the problem is a missing session, a validation failure, or a rate-limit hit, the response body always has "success": false alongside a human-readable message, a structured errors array with field-level detail when applicable, and a requestId you can include in support requests.

Error Response Format

All error responses use the following envelope structure:
boolean
required
Always false for error responses.
string
required
A short, human-readable summary of what went wrong. Suitable for logging; not guaranteed to be stable across API versions, so do not use it for programmatic branching — use the HTTP status code instead.
array
Present on validation errors. Each element has a field (the request property that failed) and a message describing the constraint violation.
string
An opaque identifier for the specific request. Include this value when contacting support to help correlate server-side logs to your issue.

HTTP Status Codes

The API uses standard HTTP semantics. Match on the status code first, then inspect the response body for detail.

Common Error Scenarios

A 401 response means the API could not associate your request with a valid session. The most common causes are:
  • No cookie sent — your HTTP client is not forwarding the session cookie. In fetch, ensure you pass credentials: 'include'; in axios, set withCredentials: true.
  • Session expired — sessions have a server-controlled lifetime. When a 401 occurs on a request that previously worked, treat it as a signal to redirect the user to log in.
  • Session revoked — another device or an admin action revoked the session. The user must log in again.
Example response:
Recovery: Call POST /auth/login or POST /auth/register to obtain a fresh session, then replay the original request.
A 403 on a write request almost always means the x-csrf-token header is absent, stale, or does not match the CSRF cookie the server has on file.
  • Missing header — every POST, PATCH, and DELETE request must include x-csrf-token. Read-only GET requests do not require it.
  • Stale token — CSRF tokens are bound to the session. If the session was refreshed or the token cookie expired, the previously fetched token is no longer valid.
  • Mismatched value — the server compares the x-csrf-token header against the CSRF cookie using the double-submit pattern. Any mismatch results in a 403.
Example response:
Recovery: Call GET /auth/csrf-token to obtain a fresh token, then retry the write request with the new value in x-csrf-token.
A 400 response means your request payload, query parameters, or path parameters did not pass schema validation. The errors array pinpoints every failing field so you can correct them all in a single retry.Example — invalid registration payload:
Recovery: Iterate over the errors array, surface the messages to the user or fix the values programmatically, and resubmit the request.
The API enforces rate limits to protect reliability. Login and registration endpoints apply brute-force protection — accounts are locked out after 10 consecutive failed attempts for 15 minutes. General endpoint rate limits apply across all routes.When you hit a limit, the response includes a Retry-After header specifying the number of seconds to wait before retrying.Example response:
Recovery strategy:
  1. Read the Retry-After header value (in seconds).
  2. Wait for the specified duration before retrying — do not immediately retry or you will continue receiving 429 responses.
  3. For login brute-force lockouts, wait the full 15-minute window before attempting again, or advise the user to reset their password.
  4. In automated clients, implement exponential backoff with jitter to avoid thundering-herd retries.
A 409 response indicates the request is valid but conflicts with the current state of a resource. The two most common scenarios are:Duplicate email on registration:
Direct the user to log in or use the password-reset flow instead of registering again.Insufficient stock on cart or order:
Reduce the requested quantity or remove the item. Refresh the product variant to show the user the current available stock before they try again.
The 410 Gone status code is specifically used for expired or already-used tokens — email verification links and password reset OTPs. A 410 is distinct from a 404 (resource never existed) and signals that the token existed but is no longer valid. To recover, request a fresh token: use POST /auth/email-verification/resend for verification emails, or restart the password reset flow.