Yes, but it is not as simple as changing a URL by hand. It depends on whether the service you are calling has built-in facilitator routing.
A real example: if an x402 facilitator goes down and you are using a hardcoded single facilitator, your agent will get stuck. The x402-next-failover middleware is designed to fix this. It lets you configure multiple facilitators and switch automatically by priority.
First: Know Which Path You Are On
Case A: You Are the Developer of an x402 Service
You run your own API and accept x402 payments from users. In this case, you decide which facilitator to use.
What to do: Configure multiple facilitator candidates in your own service. When one is unavailable, automatically switch to the next one.
How to do it:
Use
x402-next-failoverto createfacilitators.config.ts. Configure priorities from high to low:
export const facilitators: FacilitatorConfig[] = [
// Primary facilitator
{
id: "x402-rs",
url: "https://facilitator.x402.rs",
priority: 1,
timeoutMs: 5000,
},
// Backup facilitator
{
id: "payai-network",
url: "https://facilitator.payai.network",
priority: 2,
timeoutMs: 5000,
},
// Third backup (Coinbase CDP, requires API Key)
{
id: "coinbase-cdp",
type: "coinbase-cdp",
apiKeyId: process.env.CDP_API_KEY_ID,
apiKeySecret: process.env.CDP_API_KEY_SECRET,
priority: 3,
timeoutMs: 10000,
},
];Then import createPaymentMiddlewareWithFailover in your middleware and it will switch automatically.
Done when: After the primary facilitator returns 503 or times out, you can see a failover event in the logs and the next priority facilitator is called.
Case B: You Are the Caller of an x402 Service (Using an Agent to Call an API)
You only need to pay. The facilitator is decided by the service side. If the server does not configure failover, you cannot switch it.
How to check:
Check the
facilitatorUrlfield in the 402 response from the API.If the server returns a hardcoded
facilitatorUrl, you can only use that address. There is no choice.If the server returns a dynamic
facilitatorUrl, you can try to replace it. But note: after replacement, the commitment check in the settlement contract may fail. That is because settlement parameters likesalt,payTo, andfacilitatorFeeare bound to the facilitator specified by the server.
High-risk warning: The x402 protocol has a security design. The
nonceparameter must equal the commitment hash of all settlement parameters. If you replace the facilitator, the parameter binding check will fail, and the transaction will revert. So if you are the caller, do not replace the facilitator specified by the server unless you fully understand the x402 settlement architecture.
Tool Comparison
| Tool | Use Case | Switching Mechanism |
|---|---|---|
| x402-next-failover | Next.js server that receives x402 requests | Automatically switches by priority level |
| P402 Router | Paid APIs and proxy payments | Dynamic routing based on service health in real time |
| Routex | Multi-chain payment routing | Automatically selects chain by fee, speed, and finality |
| @delegare/x402 | Express service with dual-track payments (crypto + fiat) | Falls back to Stripe when the crypto path is unavailable |
Common Failure Reasons
1. A hardcoded facilitator URL with no fallback. The code writes https://facilitator.stacksx402.com directly. If the service is down, all requests fail.
2. The facilitator path is wrong. Real case: x402.ts calls /api/v1/settle, but the relay actually exposes /settle. All payment verifications get 404, which is treated as relayError and returns 503. This "facilitator is not down but the path is wrong" case is more common than a real outage.
3. You changed the facilitator but did not configure the matching API Key. A Coinbase CDP facilitator needs CDP_API_KEY_ID and CDP_API_KEY_SECRET. If the environment variables are not set, the backup facilitator cannot be used.
Final Check
If you are configuring multiple facilitators, run an outage test:
Deliberately write the primary facilitator URL incorrectly, for example add one extra character.
Make an x402 request.
Watch the logs. You should see the primary facilitator time out or return 404, then automatically switch to priority 2.
Verification channel: The logs show failover records such as Switching from x402-rs to payai-network, and the transaction finally succeeds through the backup facilitator. If all facilitators are unavailable, return a clear error code like 503, not a silent failure.


