# 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.

<ShortProductTruth>**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.</ShortProductTruth>

## What you end up with [#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 [#two-ways-to-accept]

| | x402 middleware | Hosted endpoint |
| --- | --- | --- |
| Where the 402 is answered | In your own server | By Abazi, at a hosted URL for your service |
| Where the price comes from | Your service's Catalog listing, or a payment-requirements document you pass | Your service's Catalog listing |
| Who verifies and settles | Your server, through an x402 facilitator | Abazi, through an x402 facilitator |
| How you serve the resource | Your handler runs after the payment settles | Abazi forwards the paid request to your origin and returns its response |

## Steps [#steps]

<Steps>
<Step>

### List the service [#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.

<Screenshot id="merchant-checkout" />

</Step>
<Step>

### Answer with a 402 [#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.

```json title="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.

</Step>
<Step>

### Verify and settle the paid retry [#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.

</Step>
<Step>

### Return the resource [#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.

</Step>
<Step>

### See the payment [#see-the-payment]

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

<Screenshot id="merchant-payouts" />

</Step>
</Steps>

## Being paid without listing [#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 (<Limit name="unknownMerchantLimit" /> in the example mandate) need a person's approval, and a mandate may refuse unknown merchants altogether. To move up, see [merchant trust tiers](/docs/concepts/merchant-trust-tiers).

## Failure cases [#failure-cases]

| Situation | What the agent's side sees |
| --- | --- |
| The 402 asks for a different payout address than the listing | Denied with <ReasonCode code="PAYTO_MISMATCH" />, and the merchant's tier resets to UNKNOWN. |
| The 402 asks for a different amount than the listing | Denied with <ReasonCode code="AMOUNT_MISMATCH" />. |
| The 402 offers only networks the listing does not name | Denied with <ReasonCode code="NETWORK_MISMATCH" />. |
| The paid retry does not match your requirements, or the facilitator says it is invalid | Your endpoint answers 402 again with an error; nothing settles. |
| No facilitator can be reached | Your endpoint answers 502; the payer's payment stays unsettled. |

## Next steps [#next-steps]

<Cards>
  <Card title="Merchant trust tiers" href="/docs/concepts/merchant-trust-tiers" description="Learn how a merchant goes from UNKNOWN to KNOWN to VERIFIED, and what each unlocks." />
  <Card title="Accept" href="/docs/products/accept" description="Read what the Accept product covers, from middleware to hosted checkout." />
  <Card title="Split a payment" href="/docs/guides/split-a-payment" description="Share each confirmed payment between a platform and its merchants." />
</Cards>

