Errors
The server returns these codes as x402 invalidReason or errorReason. The client throws them as Pq402Error.reason.
They are exported as ErrorCode from @pq402/core; the message text may change, the codes do not.
| Code | Means | Fix | Retry? |
|---|---|---|---|
insufficient_funds |
the escrow balance, or the position’s buffer and principal, cannot cover the price | deposit more, or fund the position | no |
invalid_pq402_budget_exceeded |
the agent budget for this period is used up | wait for the next period, or raise the budget | after the period |
invalid_pq402_key |
the payer has no ML-DSA-87 key with proof of possession, or is not the position’s beneficiary | register the key; pay from your own position | no |
invalid_pq402_signature |
the signature does not match the payer’s key on chain | sign with the key registered for payer |
no |
invalid_pq402_sealing |
a sealed body could not be opened, a party has no ML-KEM-1024 key, or a plaintext body was sent to a route that requires sealing | register both parties’ KEM keys; let the client seal | no |
invalid_pq402_request_hash |
the payment was signed for other request bytes than the server received | do not change the body or path after signing; check proxies that rewrite them | no |
invalid_pq402_replay |
this payment was already presented to this server | let the client sign a new one | no |
invalid_pq402_nonce_used |
the payment’s nonce is spent, or another action on the position came first | sign a new payment | yes, once |
invalid_pq402_expired |
the payment’s time window ended before it could settle | check the clocks; sign a new payment | yes |
invalid_pq402_not_yet_valid |
the payment’s time window has not started | check the client’s clock | after the clock is fixed |
invalid_pq402_chain_unavailable |
the chain could not be read, so the payment was refused rather than trusted | wait and retry; check the RPC and REST endpoints | yes |
invalid_transaction_state |
the settlement transaction failed | check the relayer’s window, QOR and gas cap | yes |
invalid_pq402_payload |
the payment header is malformed | use @pq402/client, or follow the wire format |
no |
invalid_pq402_requirements_mismatch |
the payment’s accepted differs from what the server offered |
pay one of the offered entries unchanged | no |
invalid_pq402_version |
the client and server speak different PQ-402 versions | upgrade the older side | no |
invalid_scheme |
the payment’s scheme is not offered on this route | pay with a scheme from the 402 |
no |
invalid_network |
the payment is for another network | pay on eip155:9800 |
no |
Client-side refusals
Section titled “Client-side refusals”Some errors happen before anything is signed. They carry no code:
| Message | Fix |
|---|---|
price … exceeds the limit … |
raise maxAmount, or do not pay that price |
the server offers no PQ-402 payment this client can make |
the route offers neither pq-erc20 nor pq-perennial |
sealing is for chain … |
set chainId to the server’s chain |
the gateway has no proven ML-DSA-87 key on chain |
the server must register its key |
the sealed response carries no receipt, or a receipt problem |
do not trust the answer: it did not come from the gateway you paid |