Guides

Accept agent payments with a 402 response

Put a price on an HTTP endpoint with x402 middleware or a hosted endpoint, answer agents with a standard 402 response, and get paid in USDC.

View as .mdUpdated
Get paid by agents. No sign-up. An endpoint that answers with a standard x402 402 response can be paid by any x402 client, Abazi's agents included. Listing the service in the Catalog and verifying the merchant decide how far an agent may go without a person.

What you end up with

A paid endpoint. An agent asks for it, gets a 402 response with the price and payout address, pays in USDC on Solana, Base, Polygon or Avalanche, and receives the resource in the same exchange. The payment shows up in the merchant console once it is confirmed, and the payer gets a receipt.

Two ways to accept

x402 middlewareHosted endpoint
Where the 402 is answeredIn your own serverBy Abazi, at a hosted URL for your service
Where the price comes fromYour service's Catalog listing, or a payment-requirements document you passYour service's Catalog listing
Who verifies and settlesYour server, through an x402 facilitatorAbazi, through an x402 facilitator
How you serve the resourceYour handler runs after the payment settlesAbazi forwards the paid request to your origin and returns its response

Steps

List the service

In the merchant console, add a service with its price, the networks it accepts and the payout address for each network. This listing is what Abazi pays: a 402 response that disagrees with it is refused.

Accept setup page
Accept setup: the 402 endpoint and middleware for a service.Captured 2026-11-16

Answer with a 402

With the middleware, your handler asks for payment for the listed service. With the hosted endpoint, Abazi does it for you. Either way, an unpaid request gets a 402 response that follows x402 version 2: a PAYMENT-REQUIRED header with the requirements encoded, and the same requirements in the body.

402 response body
{
  "x402Version": 2,
  "error": "Payment required",
  "resource": { "url": "https://shop.example/api/forecast", "description": "Seven-day weather forecast for a city.", "mimeType": "application/json" },
  "accepts": [
    {
      "scheme": "exact",
      "network": "<caip2-network-id>",
      "amount": "50000",
      "asset": "<USDC contract>",
      "payTo": "<your payout address>",
      "maxTimeoutSeconds": 60,
      "extra": { "name": "USDC", "version": "2" }
    }
  ]
}

Each entry in accepts is one way to pay: one network, one asset, one amount. On Solana the entry also names the facilitator's fee payer, which pays the network fee.

Verify and settle the paid retry

The agent's paid retry carries the signed payment in a PAYMENT-SIGNATURE header. The middleware or hosted endpoint checks that it matches one of your own accepts entries exactly (amount, payout address and asset), asks the facilitator to verify it, then to settle it on chain.

Return the resource

After settlement, the resource goes back with a 200 and a PAYMENT-RESPONSE header that carries the settlement result. With the hosted endpoint, Abazi forwards the paid request to your origin with a header naming the transaction, and returns your origin's response.

See the payment

Once the payment is confirmed on its network, the merchant console shows it under payouts, with any split.

Merchant payouts page
Payouts and splits after confirmation.Captured 2026-11-16

Being paid without listing

An agent can also buy from a URL that is not in the Catalog. Abazi calls the URL, and if it answers with a valid x402 version 2 402 response, adds the merchant to the Catalog as UNKNOWN and the service as discovered. An unknown merchant can be paid, but purchases above the unknown-merchant limit (0.10 USDC in the example mandate) need a person's approval, and a mandate may refuse unknown merchants altogether. To move up, see merchant trust tiers.

Failure cases

SituationWhat the agent's side sees
The 402 asks for a different payout address than the listingDenied with PAYTO_MISMATCH, and the merchant's tier resets to UNKNOWN.
The 402 asks for a different amount than the listingDenied with AMOUNT_MISMATCH.
The 402 offers only networks the listing does not nameDenied with NETWORK_MISMATCH.
The paid retry does not match your requirements, or the facilitator says it is invalidYour endpoint answers 402 again with an error; nothing settles.
No facilitator can be reachedYour endpoint answers 502; the payer's payment stays unsettled.

Next steps

On this page