Axo

L402 Error Codes

Reference for HTTP status and error codes returned by Axo Pay middleware.

All middleware denials return JSON in this shape:

{
  "error": {
    "code": "error_code",
    "message": "Human-readable message"
  }
}

Server Error Reference (@axobot/pay)

HTTPerror.codeMeaning
402payment_requiredNo valid credential provided. Client must pay invoice and retry.
401invalid_credentialToken signature is invalid or malformed.
401invalid_payment_proofPreimage does not match the payment hash.
403resource_mismatchToken was issued for a different route.
403amount_mismatchToken was issued for a different price.
403token_expiredToken is past expiresAt.
500configuration_errorMissing middleware configuration (for example ZBD_API_KEY).
500pricing_errorDynamic pricing function failed.
502invoice_creation_failedUpstream invoice creation failed.

Common Client-Side Failures (@axobot/fetch)

These are thrown as runtime errors (not structured HTTP middleware errors):

  • requestChallenge expects a 402 response
  • Invalid payment challenge
  • Payment required: <amount> sats exceeds limit of <max> sats
  • Payment response missing preimage and no settlement poller is configured
  • Payment <id> failed: <reason>
  • Payment <id> did not settle within <timeout>ms

Tip

For robust clients, catch these errors and map them to retries, budget policies, or user-visible payment actions.

On this page