Skip to content

Agent payments (x402)

This page is for developers who want to sell their API, content endpoints, or tool services to AI agents. Once integrated, any agent with a wallet can pay per request to call your API: no accounts, no cards, no human checkout page — payment completes in a single HTTP 402 round trip.

Taria Pay's agent payments are compatible with the x402 v2 open standard, so mainstream x402 clients (such as @x402/fetch) can pay out of the box.

How this differs from ordinary payments

  • Non-custodial: funds go directly from the agent's wallet to the payout wallet you configure — they never pass through the Taria Pay pool, and there's nothing to withdraw.
  • No full business verification: sign up, configure a payout wallet, and you're live.
  • Gas covered by the platform: agents only need to hold stablecoins (USDC), not ETH; on-chain gas is paid by Taria Pay's relayer.

Standard flow

text
agent
  -> calls your paid endpoint (no payment)
your service (Taria Pay middleware)
  -> returns 402 + PAYMENT-REQUIRED (amount, token, payout address)
agent
  -> signs an EIP-3009 transfer authorization with its wallet (offline signature, not on-chain)
  -> retries the request with PAYMENT-SIGNATURE
Taria Pay
  -> verifies the signature, runs replay checks, settles on-chain (agent wallet -> your wallet)
your service
  -> releases the business response + PAYMENT-RESPONSE (with settlement tx and signed receipt)

Before you start

You'll need:

  • A Taria Pay merchant account and API key
  • A payout wallet address you control (EVM)
  • A Node.js server (Express or a compatible framework)

Supported scope (current version):

  • Tokens: USDC (EURC also works); USDT is not supported yet
  • Pricing: fixed per-request or dynamic per-request, with amounts in the token's minor units (USDC has 6 decimals, so 10000 = 0.01 USDC)

Step 1: Create a paid endpoint

An "endpoint" describes one chargeable resource: price, chain, token, and payout wallet.

bash
curl -s -X POST https://api.tariapay.com/merchant/v1/agent/endpoints \
  -H "x-api-key: $TARIAPAY_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "name": "market-data",
    "resourceUrl": "https://api.yoursite.com/v1/market-data",
    "chainId": 8453,
    "currency": "USDC",
    "payoutAddress": "0xYourPayoutWallet",
    "pricingMode": "fixed",
    "amountMinor": "10000"
  }'

Note the endpoint.id in the response.

Optional parameters:

  • pricingMode: "dynamic" — your server sets the price on each request (via the middleware's amountMinor callback).
  • releasePolicyincluded (default: release as soon as the transaction is included on-chain, about 2 seconds) or confirmed (wait for full confirmations before releasing, suited to high-value content).

Step 2: Add the payment middleware to your route

bash
npm install @tariapay/sdk
js
import express from "express";
import { x402PaymentRequired } from "@tariapay/sdk/x402";

const app = express();

app.get(
  "/v1/market-data",
  x402PaymentRequired({
    apiKey: process.env.TARIAPAY_API_KEY,
    endpointId: process.env.TARIAPAY_ENDPOINT_ID,
  }),
  (req, res) => {
    // Reaching here means the payment has settled; settlement details are in req.tariaPayment.
    res.json({ data: "...", paidTx: req.tariaPayment?.txHash });
  },
);

The middleware automatically handles issuing the 402 challenge, forwarding the payment credential for settlement, and writing the PAYMENT-RESPONSE receipt header. Keep the API key server-side only.

Step 3: Test a paid call

Use the example agent client from the repository (or any x402 v2 client):

bash
# examples/paid-api-demo contains a complete runnable example
AGENT_PRIVATE_KEY=0xAgentWalletKey node agent.mjs https://api.yoursite.com/v1/market-data

The agent wallet only needs to hold USDC on the corresponding chain. The first request returns 402; the client signs and retries, and the successful response carries a PAYMENT-RESPONSE header containing the settlement transaction hash and a platform-signed receipt.

Settlement and reconciliation

  • Funds arrive directly in your payout wallet; you can see every incoming payment on a block explorer by looking up your payoutAddress.
  • Every successful settlement produces a signed receipt containing the amount, payer, and transaction hash, EIP-191-signed with the platform's receipt key — independently verifiable and auditable.
  • Merchants with webhooks configured receive the agent_payment.settled event (using the same webhook signing and retry mechanism as everything else — see Receiving payment results).
  • Check the status of a single payment: GET /merchant/v1/agent/challenges/:challengeId.

Pricing

Free during beta (usage is metered but not billed). Planned pricing: the first 1,000 settlements each month are free; beyond that, each settlement costs max($0.005, transaction amount × 0.3%), deducted monthly from a prepaid balance, with lower unit prices at higher volume.

Things to note

  • The payout address is snapshotted when a challenge is issued: changing an endpoint's payoutAddress does not affect challenges already issued.
  • A payment authorization can only be used once (double replay protection: on-chain nonce + platform-side check); if an agent retries a payment that has already settled, it simply gets the original receipt back with no double charge.
  • Under releasePolicy: "included" there is a tiny chain-reorg window; use confirmed when selling high-value content.