Skip to main content
Every rejection Rail402 returns carries a stable, machine-readable code and a non-empty, human-readable reason. Branch on the code; show or log the reason. A specific rejection may replace the default reason below with more detail, never with an empty string.
  • HTTP status is the status used when the code is returned as a transport-level error. Verification and settlement outcomes are always HTTP 200, as the x402 specification requires.
  • Retryable says whether sending the same request again, unchanged, can succeed later: after a delay, once a balance or trustline changes, or when capacity frees up. A code that is not retryable needs a different request, usually a newly signed payment.
Codes are stable. A code is never renamed or removed, and its HTTP status and retryability never change, without an entry in the changelog; the test suite pins all three for every code. Reasons may be reworded. The verification rules explain when each facilitator and cataloging code is returned and which test covers it. 185 codes in 7 groups.

HTTP transport

Returned with the listed HTTP status in error.code on every endpoint. On /verify and /settle the body also keeps the x402 response shape, with the code in invalidReason or errorReason. Defined in httpCodes (@rail402.dev/errors).

Access-key sign-up

Returned with the listed HTTP status in error.code by GET /keys/new and GET /keys/callback, the routes that issue access keys to signed-in GitHub accounts. Defined in keySignupCodes (@rail402.dev/errors).

Verification and settlement (exact on Stellar)

Returned by /verify in invalidReason (with isValid: false) and by /settle in errorReason (with success: false), always with HTTP 200 as the x402 specification requires. The status applies only when a code is carried by a transport-level error. Defined in exactStellarCodes (@rail402.dev/stellar).

Verification and settlement (upto on Stellar)

Returned by /verify in invalidReason and by /settle in errorReason for upto payments, with HTTP 200 like every verification and settlement outcome. An upto payment also returns the x402 standard codes listed under exact, such as insufficient_funds and settlement_pending. Defined in uptoStellarCodes (@rail402.dev/stellar).

Bazaar cataloging

Reported to the seller in the EXTENSION-RESPONSES header of /verify and /settle under the bazaar key, with status: rejected and the reason in rejectedReason. A cataloging rejection never affects the payment. Defined in bazaarCodes (@rail402.dev/bazaar).

Discovery API

Returned with the listed HTTP status in error.code by GET /discovery/resources and its detail routes, and for a malformed parameter of GET /discovery/search. Defined in bazaarCodes (@rail402.dev/bazaar).

Search API

Returned with the listed HTTP status in error.code by GET /discovery/search. Defined in searchCodes (@rail402.dev/search).

Client codes

The SDK (@rail402.dev/sdk), the seller helpers, the MCP server (rail402-mcp) and the CLI (rail402) raise their own codes on the caller’s side. The service never returns them. They share the fields above and add two:
  • Paid says whether money may have moved when the code was raised: none (nothing was signed, or the signed payment never reached the seller), not_settled (the seller or facilitator refused the payment), settled (the payment settled, then the resource failed) or unknown (a payment was sent and its outcome is not known yet; the budget keeps it pending until it is proven on chain or its authorization expires). The value on an error is authoritative; the table shows the default.
  • CLI exit is the exit status rail402 uses when it reports the code. See the CLI reference.
Do not simply repeat a call whose error says settled or unknown. A call made with an idempotency key can be repeated with the same key: a finished call returns its stored result without paying again, and one still running is refused with payment_in_progress. A key used again for another resource is refused with payment_request_invalid.

Refused payments

For client codes, retryable means that making the same call again can succeed. A paying call signs a new payment each time it runs, so this differs from a facilitator’s retryable, which says whether resending the same signed payment can succeed. A payment the seller or its facilitator refused is payment_rejected. Its retryable and paid come from the facilitator’s code the seller passed on (details.upstream.code), through one table, refusalOutcomes in @rail402.dev/sdk. The SDK’s PaymentError, the rail402-mcp tool error and the CLI’s error object carry the same values:
  • A refusal after which the payment may still settle, or may already have moved funds, is paid: "unknown", never retryable, and exits 5: settlement_pending, settle_exact_stellar_transaction_failed (also sent when a facilitator could not confirm the transaction in time), settle_*_stellar_transaction_submission_failed (also sent when the network already holds the same transaction), settle_*_stellar_settlement_in_progress, settle_*_stellar_idempotency_conflict and settle_upto_stellar_settled_elsewhere. So are the causes an exact transaction can fail with on chain without ending the payer’s authorization, since the network rolls the failure back, nonce included, and anyone who holds the payment can still land it until the authorization expires: insufficient_funds, invalid_transaction_state, and invalid_exact_stellar_payload_ with invalid_signature, smart_account_rejected, account_missing, payer_trustline_missing, recipient_trustline_missing, trustline_not_authorized, token_rejected or unauthorized_invocation. The budget keeps the payment pending until the chain proves its outcome.
  • Every other code of the exact and upto facilitator tables keeps the facilitator’s retryable with paid: "not_settled": a busy channel, a rate limit or a spent fee budget is retryable; a malformed payment or an expired settlement transaction is not. The code is the seller’s text, so it never makes a refusal more retryable than the facilitator’s table.
  • A code neither table has, or none, is retryable: false with paid: "not_settled".
A JSON-RPC error of rail402-mcp carries the same fields in its data, with paid: "none". 140 codes in 15 groups.

Buyer payments

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in paymentCodes (@rail402.dev/sdk).

Buyer discovery

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in discoveryClientCodes (@rail402.dev/sdk). Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in mcpTargetCodes (@rail402.dev/sdk).

Stellar RPC and transactions

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in networkCodes (@rail402.dev/sdk).

Outbound requests (SSRF and egress)

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in egressCodes (@rail402.dev/safe-fetch).

Signing keys

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in keyCodes (@rail402.dev/sdk).

Account setup

Thrown by @rail402.dev/sdk as a PaymentError with code, reason, retryable, paid and details. For these codes, retryable means that making the same call again, which signs a new payment, can succeed; for payment_rejected, retryable and paid follow the facilitator’s code, as Refused payments above explains. Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in accountCodes (@rail402.dev/sdk).

Seller helpers

Thrown by @rail402.dev/sdk/seller as a SellerError when a route or tool declaration is invalid, and reported as findings by validateListing and checkSellerOrigin. The rail402 seller commands print them in their JSON output. Defined in sellerCodes (@rail402.dev/sdk/seller).

rail402-mcp tool layer

Returned by the rail402-mcp tools as isError: true with structuredContent.error carrying the same fields. These codes come from the tool layer itself, around the SDK. Defined in toolCodes (@rail402.dev/mcp).

rail402-mcp protocol errors

Returned by the rail402-mcp server as a JSON-RPC error (-32601, -32602 or -32603) whose data carries { code, reason, retryable, paid }, for a request that never reaches a tool. An unknown tool is the same kind of error, with tool_unknown. Nothing is paid. Defined in rpcCodes (@rail402.dev/mcp).

Hosted MCP endpoint startup

Printed by rail402-mcp --hosted as one JSON line on stderr when it refuses to start, with exit status 78. Nothing is served. Defined in hostedCodes (@rail402.dev/mcp).

rail402 command line

Printed by the rail402 command line in the error object of its JSON output, with the exit status shown. Defined in cliCodes (@rail402.dev/cli).

Playground server

Returned by the Playground server as { error: { code, reason, retryable, details } }. A relay refusal means nothing reached the seller. Defined in playgroundServerCodes (@rail402.dev/playground/codes).

Playground page

Shown by the Playground page in the browser, next to the codes of the packages above, which it shows unchanged. Defined in playgroundClientCodes (@rail402.dev/playground/codes).

Explorer pages and read API

Returned by the Explorer’s read API as { error: { code, reason, retryable } } with the listed HTTP status, and shown on its error pages. The Explorer only reads public ledgers, so nothing is paid. Defined in explorerCodes (@rail402.dev/explorer/codes).

Coverage

Every code in the tables above, service and client alike, is checked against what the test suites and the recorded conformance runs actually produce: a recorder notes each code raised while pnpm test and pnpm test:integration run, and each rejection a recorded run reports. pnpm codes:coverage --write records the result in tools/conformance/codes-coverage.json; a code that nothing produces must have a reason here, or the unit tests fail. Recorded on 2026-11-07 at commit 032afcc878eb: 315 of 317 registered codes are produced by a test or a recorded run. Raised while the suites ran: unit tests 238, integration tests 150; reported by conformance runs 98; named only in a test’s assertions (refusals built as plain values, which the recorder does not see) 44. The 2 codes that neither produces, and why: Registered since this record was made, not yet measured: key_signup_account_refused, key_signup_account_too_new, key_signup_cancelled, key_signup_closed, key_signup_limit_reached, key_signup_provider_failed, key_signup_state_invalid, key_signup_too_soon.