Memeputer

Building X402 Resources

This guide is for developers who want to build X402-compatible resources that work seamlessly with x402.jobs workflows.

What is an X402 Resource?

An X402 resource is an HTTP endpoint that implements the X402 payment protocol. When a client makes a request, the server responds with a 402 Payment Required status, the client pays, and then receives the actual response.

Integration with x402.jobs

When you register your resource on x402.jobs, users can:

  • Discover your resource in the marketplace
  • Add it to their workflows
  • Chain it with other resources
  • Run automated jobs that call your resource

Key Concepts

1. The 402 Response

Your endpoint should return a 402 Payment Required response with payment details:

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "solana",
    "maxAmountRequired": "50000",
    "resource": "https://api.example.com/generate",
    "payTo": "YourWalletAddress...",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "outputSchema": {
      "input": { ... },
      "output": { ... }
    }
  }]
}

2. Synchronous vs Asynchronous

Resources can be:

  • Synchronous: Return the result immediately after payment
  • Asynchronous (LRO): Return a status URL to poll for the result

For operations that take more than a few seconds (AI generation, media processing, etc.), use the Long Running Operations pattern.

3. Output Schema

Define your input fields and output structure in the outputSchema so x402.jobs can:

  • Generate forms for user input
  • Display results properly
  • Enable field mapping between nodes

Next Steps