Skip to main content
The CharityStack API uses standard HTTP status codes to indicate success or failure. Every error response includes a JSON body with a human-readable message, and validation errors include a details array listing all problems at once so you can fix them in a single request.

Error response format

All error responses follow one of two shapes depending on whether multiple validation errors were found. Single error:
Validation errors (multiple issues):
When the API returns "Validation failed", inspect the details array to see all issues at once and correct your request in one round-trip.

HTTP status codes

403 Forbidden and 404 Not Found are intentionally distinct. A 403 means the record exists but belongs to a different merchant account; a 404 means no matching record was found at all.

Rate limit headers

Every API response includes the following headers so you can monitor your usage: Check X-RateLimit-Remaining proactively in long-running batch jobs to avoid hitting the limit unexpectedly.

Handling errors in code

The examples below show a recommended error-handling pattern that checks the status code, parses the error body, and retries with exponential backoff on 429 and 500 responses.

Best practices

Status codes tell you the category of the problem immediately. Parse error and details from the body for the specific message, but key your error-handling logic on the status code.
Retrying immediately after a rate limit or server error usually makes things worse. Wait at least 1 second before the first retry and double the wait on each subsequent attempt. For 429 responses, prefer to wait until the time indicated by X-RateLimit-Reset.
Client errors in the 4xx range — bad parameters, missing auth, conflicts — won’t resolve on their own. Fix the underlying problem in your code rather than retrying the same request.
When logging errors, include the relevant resource ID, the status code, and the full error/details body. This makes debugging much faster when tracing a specific failed request.