Every non-2xx response from the SohoPay API carries the same JSON envelope and a stable machine-readable code. This page lists all codes, what causes them, and how to recover — branch your error handling on error.code, never on the message text.

Error envelope

  • code — stable identifier from the table below. New codes may be added; treat unknown codes on a 5xx as retryable and unknown codes on a 4xx as terminal.
  • message — human-readable detail. Log it, don’t parse it.
  • request_id — attach this to any support ticket so the team can trace the exact request.

Error codes

Both INSUFFICIENT_CREDIT and AML_DECLINED return 402 Payment Required — always branch on the code, not the status. One is recoverable by the operator; the other is a compliance decision.

Retry strategy

Not every error deserves a retry. Classify by code: Retryable — back off exponentially (e.g. 1s, 2s, 4s, 8s, capped), reusing the same Idempotency-Key on POSTs so a retry can never double-execute:
  • RATE_LIMITED — but honor the Retry-After header instead of your own schedule.
  • INTERNAL — and any other 5xx, plus network timeouts.
Retryable after you change something — the same request will fail forever; fix the condition first:
  • INSUFFICIENT_CREDIT — raise limits or add collateral.
  • AGENT_NOT_ALLOWLISTED — allowlist the agent.
  • WITHDRAWAL_GATED, OUTSTANDING_BALANCE — clear the outstanding credit.
  • ORDER_EXPIRED — create a new order (a new ord_ ID, so a new idempotency key too).
Never retry — terminal outcomes:
  • INVALID_API_KEY, INVALID_AGENT — configuration bugs; fix your setup.
  • AML_DECLINED, AGENT_REVOKED — compliance or lifecycle decisions; retrying just burns rate limit.
Retrying AML_DECLINED in a loop looks like evasion behavior and can escalate the flag on the wallet. Handle it as a terminal state and route it to a human — see AML Screening.
A minimal classification in TypeScript:
Patterns for handling declines inside a live payment flow — including surfacing them to agents mid-conversation — are covered in the error handling guide.

Next steps

Error Handling Guide

Decline and retry patterns inside the payment flow.

Troubleshooting

Step-by-step fixes for the most common failures.

Webhook Events

Failure events like payment.failed and agent.aml_declined.