What is an x402 Resource Server?

2 min read Updated

An x402 resource server is any HTTP server that requires payment for access to its resources using the x402 protocol. It responds with HTTP 402 and payment requirements when an unpaid request arrives, then serves the resource after verifying payment via a facilitator or locally.

WHY IT MATTERS

The x402 protocol is designed to make monetising HTTP resources trivially easy for server operators. With the reference TypeScript SDK, adding payment requirements to an Express or Hono endpoint takes a single line of middleware:

app.use(paymentMiddleware({ "GET /weather": { accepts: [...], description: "Weather data" } }))

The middleware handles the entire flow: returning 402 with structured payment requirements for unpaid requests, forwarding payment payloads to the facilitator for verification, calling the facilitator's settle endpoint after fulfilling the request, and returning the payment response header with settlement confirmation.

Resource servers don't need to understand blockchain mechanics. They define what they charge (amount, accepted tokens/networks) and delegate verification and settlement to a facilitator. SDKs exist for Express, Hono, Next.js, Python, and Go.

This architecture means any existing API can become payable — data feeds, LLM inference endpoints, premium content, computational services — without accounts, API keys, or subscription management. The x402 Foundation reports over 75 million transactions and 22,000+ sellers already in the ecosystem.

HOW POLICYLAYER USES THIS

PolicyLayer's endpoint auto-discovery feature detects when your agents encounter new x402 resource servers. It automatically creates spending policies using your configured defaults — so agents can explore paid APIs safely while you maintain budget control over every new vendor.

FREQUENTLY ASKED QUESTIONS

How much code does it take to add x402 to an API?
One line of middleware with the reference SDKs. The paymentMiddleware function wraps your existing routes, handles 402 responses, and coordinates with the facilitator. SDKs are available for Express, Hono, Next.js, Python, and Go.
Does the resource server need a wallet?
The server specifies a recipient address in its payment requirements — this is where funds are settled. The server itself doesn't need to manage keys; the facilitator handles settlement to the specified address.
Can I charge different prices for different endpoints?
Yes. Payment requirements are configured per-route, so /premium-data might cost $1 per request while /basic-data costs $0.01. Each route can also accept different networks and tokens.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.