Agent Pay

A simple standard for agents to pay for services. No complex integration — just a 402 response.

The Problem

Your API needs to charge AI agents for access. But agents don't have credit cards, and setting up billing on both sides is complex. You just want to say “pay me $0.50” and have the agent handle it.

The Solution

Return an HTTP 402 response with payment details and a link to agent-pay.md — a plain-English document that any AI agent can read and follow. The agent reads the instructions, pays from its IndieGent wallet, and retries the request. Done.


For Service Providers

Step 1: Return a 402 response

When an agent needs to pay, return:

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "payment_required",
  "amount": "0.50",
  "currency": "USD",
  "recipient": "0xYourWalletAddress",
  "memo": "search-query-abc123",
  "instructions": "https://indiegent.com/.well-known/agent-pay.md"
}

Step 2: Verify payment on retry

When the agent retries, it includes proof of payment in the header:

GET /your-endpoint
X-Payment-Tx: 0xabc123def456...

Verify the payment is real:

// Use IndieGent's free verification endpoint
const check = await fetch("https://api.indiegent.com/gateway/verify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    gateway_key: "ig_gw_your_key",
    tx_hash: txHash,
    expected_amount: "0.50",
    expected_recipient: "0xYourWallet",
  }),
});

const result = await check.json();
if (result.verified) {
  // Payment confirmed — serve the request
}

Response fields

FieldRequiredDescription
errorYesMust be "payment_required"
amountYesDollar amount to pay (e.g. "0.50" for 50 cents)
currencyYes"USD" — paid in USDC (1:1 with dollars)
recipientYesYour wallet address
memoNoOptional reference (e.g. request ID)
instructionsYesURL to agent-pay.md

For Agent Developers

Using the SDK (Recommended)

If your agent uses the IndieGent SDK, 402 responses are handled automatically. Your agent calls an API, gets a 402, pays, retries — all behind the scenes. You just get the result.

import { IndieGent } from "@indiegent/sdk";

const agent = new IndieGent({
  apiKey: process.env.INDIEGENT_API_KEY,
});

// If this API returns 402, the SDK handles payment automatically
const data = await agent.fetch("https://api.example.com/search?q=hello");
// You just get the result — no payment code needed

Manual handling

If you're not using the SDK, here's the flow:

  1. Call the API as normal
  2. If you get a 402, parse the amount and recipient
  3. Send a USDC payment from your IndieGent wallet
  4. Retry the request with X-Payment-Tx: 0x... header

See the SDK documentation for the simplest integration path.


The .well-known Files

IndieGent hosts two discovery files that agents and services can reference:

agent-pay.md

https://indiegent.com/.well-known/agent-pay.md

A plain-English document written for AI agents. Contains step-by-step payment instructions. Any AI can read this and follow the instructions — no special protocol or SDK needed.

agent-pay.json

https://indiegent.com/.well-known/agent-pay.json

Machine-structured version for agents that prefer structured data over prose.


Why Plain English?

AI agents are language models. They're great at reading text and following instructions. By using a plain-English document as the payment “standard,” we meet AI agents where they are. No SDK to install. No binary protocol. The agent reads the doc, understands what to do, and does it.

This is the same reason robots.txt, security.txt, and llms.txt work — simple text files at well-known URLs that machines can discover and understand.


Protocol Compatibility

IndieGent wallets can pay via multiple payment standards. The SDK handles all of them automatically:

  • Agent Pay — IndieGent's native format (JSON body + plain-English instructions)
  • MPP — Machine Payments Protocol (IETF standard)
  • x402 — Coinbase's payment protocol

Your agent doesn't need to know which protocol an API uses — the SDK detects it automatically and pays the right way.

IndieGent— Independent wallets for independent agents

npm install -g @indiegent/cli