retailerapi / docs

Errors

Status codes, error shape, and how to handle each kind.

Error response shape

Errors return a JSON object with at minimum:

{
  "error": "human-readable message",
  "code": "machine-readable code"
}

The HTTP status code drives behavior; the error message is for logs; the code is what you branch on.

Status code reference

StatuscodeMeaningRetry?
400bad_requestInvalid identifier or query paramNo (fix client)
401unauthorizedMissing / malformed bearerNo (check key)
403forbiddenKey revoked, scope mismatch, or out of quotaNo
404not_foundIdentifier not in our catalogNo
402payment_requiredAccount past dueAfter billing fixed
429rate_limitedThrottle or monthly quota exceededYes (Retry-After)
500internal_errorOur problem; check status pageYes (with backoff)
502upstream_unavailableWalmart backend transient issueYes (with backoff)
503service_unavailableMaintenance or capacityYes (with backoff)
504upstream_timeoutWalmart backend slowYes (with backoff)

Customer-safe upstream messages

retailerapi never echoes raw upstream error messages back to your client. We map upstream failures to canonical messages:

  • 404 upstream — "Product not found"
  • 401 / 403 upstream — "Service authentication failed" (you don't see our internal auth issues)
  • 429 upstream — "Rate limited, retry shortly"
  • 5xx upstream — "Service temporarily unavailable"

Recommended retry policy

async function callWithRetry(url, opts, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const r = await fetch(url, opts);
    if (r.status < 500 && r.status !== 429) return r; // not retriable

    if (r.status === 429) {
      const retryAfter = Number(r.headers.get('Retry-After') ?? '5');
      await sleep(retryAfter * 1000);
      continue;
    }
    if (r.status >= 500 && attempt < maxRetries) {
      await sleep(2 ** attempt * 500); // exponential backoff
      continue;
    }
    return r; // give up
  }
}

Sentry / error tracking

retailerapi's own server errors are tracked in Sentry. We do NOT log your request bodies, only stack traces and route names. If you encounter a persistent 500 on a specific identifier, email hello@retailerapi.com with the identifier and we'll investigate.