Errors

Standard error envelope, complete code reference, and retry guidance.

Every non-2xx response returns a machine-readable JSON envelope. Never parse error text — key off error.code.

Error envelope

{
  "error": {
    "code": "payment_declined",
    "message": "The card issuer declined the charge.",
    "type": "provider_error",
    "doc_url": "https://asset-avenue-platform.lovable.app/docs/errors.html#payment_declined",
    "request_id": "req_01HR2X8YQ4T5B0G6ZP",
    "param": "payment_method",
    "retryable": false
  }
}
FieldDescription
codeStable machine identifier. Safe to switch on.
messageHuman message. Not localized. Do not display raw to end users.
typeHigh-level category (see below).
request_idInclude in support tickets. Also returned as X-Request-Id header.
paramPresent when a specific field caused the error.
retryabletrue if the client MAY retry with backoff.

Error types

TypeHTTPMeaning
authentication_error401Missing/invalid API key or OAuth token.
authorization_error403Key is valid but lacks scope, or IP not allow-listed.
invalid_request_error400 / 404 / 409Malformed payload, missing field, or unknown resource.
idempotency_error409Idempotency key reused with a different payload.
rate_limit_error429Client exceeded its quota. Respect Retry-After.
provider_error402 / 502Underlying provider (Stripe, Bridge, Compose, Monerium) declined or failed.
compliance_error451Blocked by AML, sanctions, KYC, or risk rules.
api_error500 / 503QashX-side failure. Retryable with backoff.

Code reference

CodeTypeRetryableNotes
invalid_api_keyauthentication_errorNoRotate via /admin/developers.
expired_api_keyauthentication_errorNoKey past expires_at. Provision a new one.
ip_not_allowedauthorization_errorNoCaller IP outside key ip_allowlist.
insufficient_scopeauthorization_errorNoKey lacks the required scope (e.g. payments:write).
missing_parameterinvalid_request_errorNoparam names the missing field.
invalid_parameterinvalid_request_errorNoField failed validation.
resource_not_foundinvalid_request_errorNoUnknown ID or reference.
idempotency_conflictidempotency_errorNoSame key, different body. See idempotency.
payment_declinedprovider_errorNoIssuer declined. Show generic message to payer.
insufficient_fundsprovider_errorNoSource balance too low.
provider_unavailableprovider_errorYesRetry with exponential backoff.
rate_limitedrate_limit_errorYesHonor Retry-After header.
aml_blockedcompliance_errorNoSanctions/AML hit. Do not retry.
kyc_requiredcompliance_errorNoPayer must complete verification.
internal_errorapi_errorYesRetry with backoff; include request_id in support tickets.
service_unavailableapi_errorYesPlanned maintenance or overload.

Retry guidance

Only retry when error.retryable === true or on network/timeout errors. Use exponential backoff with jitter:

attempt 1  →  wait 500 ms
attempt 2  →  wait 1 s
attempt 3  →  wait 2 s
attempt 4  →  wait 4 s
attempt 5  →  wait 8 s   (cap; then fail)

Always send the same Idempotency-Key on retries of POST/PUT/DELETE so the operation is not duplicated.

Never retry 4xx without inspecting retryable. Retrying a payment_declined in a loop is treated as abuse and can trip rate limits.