Errors

How EzPays reports failures.

Every error response uses the same envelope:

{
  "error": {
    "code": "validation_error",
    "message": "amount: must be a positive integer in minor units, as a string",
    "request_id": "req_2f8a4d9c1e0b4a5c",
    "details": [
      { "path": ["amount"], "message": "must be a positive integer in minor units, as a string" }
    ]
  }
}
  • code — stable, machine-readable identifier. Branch on this.
  • message — human-readable. Never branch on the text.
  • request_id — quote this in support tickets.
  • details — optional structured info; shape depends on the code.

Error codes

CodeHTTPMeaning
validation_error400Request body or query failed schema validation.
unauthorized401Missing or invalid API key.
payment_rejected402Payment provider declined the operation.
forbidden403Authenticated but missing scope.
not_found404The targeted resource doesn't exist (or belongs to a different tenant).
method_not_allowed405HTTP method not supported on this path.
idempotency_conflict409Idempotency-Key reused with a different body.
rate_limited429Too many requests; honor the Retry-After header.
internal500Unexpected server error. Safe to retry with idempotency.
provider_unavailable502Upstream payment provider failed; safe to retry.

Retry policy

CodeSafe to retry?Strategy
internal, provider_unavailable, rate_limitedYesExponential backoff (start 1s, max 60s, with jitter); always reuse the same Idempotency-Key.
validation_error, forbidden, not_found, idempotency_conflictNoFix the request and try again.
unauthorizedAfter fixingRotate or fix the key.

Tips

  • Always log request_id from error responses; we can match it to server-side traces.
  • details for validation_error is an array of { path, message } items — easy to surface at the field level in your UI.