New Chargeflow docs. Everything for merchants, platforms, and the API in one place.
ResourcesAPI Fundamentals

Error Handling

HTTP error codes returned by the Chargeflow API, what causes each one, how to resolve them, and the health check endpoint for verifying your key.

This page explains the HTTP error codes returned by the Chargeflow API, which of them are safe to retry, and how to retry correctly.

Retry safety at a glance

StatusCauseRemedyRetry-safe?
400Malformed JSON, wrong types, missing fieldsFix the request body/paramsNo - fix first
401Not returned by the Chargeflow API today: authentication failures return 403Treat as a credentials problemNo - fix first
403Missing, invalid, or revoked x-api-key; malformed signature/headers; or a valid key without access to the resourceDiagnose with GET /health-check/access-key (below)No - fix first
404Wrong URL or ID, or resource deletedVerify the URL and IDNo - fix first
429Rate limit exceededBack off and retry; honor Retry-After if presentYes - after waiting
500Unexpected server errorRetry with backoff; contact support with requestId if persistentYes - with backoff
502Temporary gateway/upstream issueRetry with backoff; check the status pageYes - with backoff

GET requests are always safe to repeat. Before retrying a write (POST) request, check whether it succeeded; full idempotency semantics are not published yet - see Idempotency for status.

Request IDs

Every API response includes a requestId field with a unique identifier for that request. Include this requestId when contacting Chargeflow support; it allows the team to locate and diagnose your request quickly.

HTTP error codes

Retry with backoff

Paste-ready retry helpers for the retry-safe statuses (429, 500, 502). Both honor Retry-After when present and fall back to exponential backoff with jitter.

retry.ts
const RETRYABLE = new Set([429, 500, 502]);

async function fetchWithRetry(url: string, init: RequestInit = {}, maxAttempts = 5) {
  for (let attempt = 1; ; attempt++) {
    const res = await fetch(url, init);
    if (!RETRYABLE.has(res.status) || attempt === maxAttempts) return res;

    const retryAfter = Number(res.headers.get('retry-after'));
    const backoff = 2 ** attempt * 500 + Math.random() * 500; // exponential + jitter
    const waitMs = retryAfter > 0 ? retryAfter * 1000 : backoff;
    await new Promise((r) => setTimeout(r, waitMs));
  }
}

Health check endpoint

Two endpoints, two different questions. Each answers exactly one:

QuestionCallAnswer
Is the API up? (availability)GET /public/2025-04-01/health-check200 "OK" means the service is reachable. No API key required, and none is checked.
Is my key valid? (authentication)GET /public/2025-04-01/health-check/access-key200 "OK" means the key is valid and active. 403 {"message":"Forbidden"} means it is missing, invalid, or revoked.
May I call this resource? (authorization)the endpoint itselfA 403 from the endpoint while /health-check/access-key returns 200 is an entitlement or signature problem, not a credentials problem.
Terminal
# Availability: no credentials involved
curl -X GET https://api.chargeflow.io/public/2025-04-01/health-check

# Credentials: is this key valid and active?
curl -X GET https://api.chargeflow.io/public/2025-04-01/health-check/access-key \
  -H "x-api-key: YOUR_API_KEY"
Response
"OK"

Both return the bare string "OK", so a 200 is the whole signal.

Next steps

Was this page helpful?

On this page

llms.txt