Payment Gateway

Accept payments from AI agents on your API. Two paths: fully managed or DIY.

The Opportunity

Thousands of AI agents need access to APIs — search, email, data, compute, storage. Most agents have IndieGent wallets with USDC ready to spend. If your API accepts IndieGent payments, you instantly have access to the entire agent economy.


Option A: Managed (We Handle Everything)

List your API on the IndieGent marketplace. We proxy requests, handle billing, and settle to your wallet. You focus on your API. We handle the payments.

How it works

  1. Register your API with IndieGent (name, wallet address, price per request)
  2. We add your service to the marketplace
  3. Agents call POST /services/your-service/endpoint
  4. IndieGent charges the agent's wallet, proxies the request to your API
  5. USDC settles to your wallet in ~2 seconds

What you get

  • Listed in the IndieGent service catalog — discoverable by all agents
  • Automatic billing — agents are charged from their wallet per request
  • Settlement in USDC to your wallet
  • Usage analytics in the business dashboard
  • No payment code to write

Register your API

curl -X POST https://api.indiegent.com/gateway/register \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Search API",
    "wallet_address": "0xYourWalletOnBase",
    "price_per_request": 0.005,
    "webhook_url": "https://your-api.com/indiegent-webhook",
    "description": "AI-native search with semantic understanding"
  }'

Response includes your ig_gw_ gateway key and a ready-to-use 402 response snippet.


Option B: DIY (Self-Hosted Integration)

Keep full control. Add IndieGent payments directly to your API in three steps. No marketplace listing required.

Step 1: Return 402 when payment is needed

When an unauthenticated or unpaid request hits your API, return:

// Your API endpoint handler
app.get("/search", (req, res) => {
  const txHash = req.headers["x-payment-tx"];

  if (!txHash) {
    // No payment — tell the agent how to pay
    return res.status(402).json({
      error: "payment_required",
      amount: "0.005",
      token: "USDC",
      chain: "base",
      recipient: "0xYourWalletOnBase",
      memo: crypto.randomUUID(), // unique per request for idempotency
      instructions: "https://indiegent.com/.well-known/agent-pay.md"
    });
  }

  // Has payment — verify and serve (Step 2)
});

Step 2: Verify the payment

When the agent retries with X-Payment-Tx, verify the transaction is real:

// Option A: Use IndieGent's verify endpoint (easiest)
const verification = await fetch(
  "https://api.indiegent.com/gateway/verify",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      gateway_key: "ig_gw_your_key_here",
      tx_hash: txHash,
      expected_amount: "0.005",
      expected_recipient: "0xYourWalletOnBase",
    }),
  }
);

const result = await verification.json();
if (result.verified) {
  // Payment confirmed — serve the request
  return res.json({ results: [...] });
}

// Option B: Verify on-chain yourself (no dependency on IndieGent)
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";

const client = createPublicClient({ chain: base, transport: http() });
const receipt = await client.getTransactionReceipt({ hash: txHash });

// Decode USDC Transfer event, verify recipient and amount
// This gives you full independence — no call to IndieGent needed

Step 3: Serve the request

Once verified, process the request normally. The USDC is already in your wallet.


Complete DIY Example

Express.js middleware

import express from "express";

const PRICE = "0.005"; // $0.005 per request
const WALLET = "0xYourWalletOnBase";
const GATEWAY_KEY = "ig_gw_your_key_here";

// Payment middleware — drop this before any paid endpoint
async function requirePayment(req, res, next) {
  const txHash = req.headers["x-payment-tx"];

  if (!txHash) {
    return res.status(402).json({
      error: "payment_required",
      amount: PRICE,
      token: "USDC",
      chain: "base",
      recipient: WALLET,
      instructions: "https://indiegent.com/.well-known/agent-pay.md",
    });
  }

  // Verify payment
  const check = await fetch(
    "https://api.indiegent.com/gateway/verify",
    {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        gateway_key: GATEWAY_KEY,
        tx_hash: txHash,
        expected_amount: PRICE,
        expected_recipient: WALLET,
      }),
    }
  );

  const result = await check.json();
  if (!result.verified) {
    return res.status(402).json({ error: "Payment not verified" });
  }

  next(); // Payment confirmed — proceed to handler
}

const app = express();

// Free endpoint
app.get("/health", (req, res) => res.json({ status: "ok" }));

// Paid endpoint
app.get("/search", requirePayment, (req, res) => {
  // This only runs if payment was verified
  res.json({ results: ["..."] });
});

Edge / Serverless

// Works with any edge framework (Hono, itty-router, etc.)
const app = new Hono();

const PRICE = "0.005";
const WALLET = "0xYourWalletOnBase";

app.get("/search", async (c) => {
  const txHash = c.req.header("X-Payment-Tx");

  if (!txHash) {
    return c.json({
      error: "payment_required",
      amount: PRICE,
      token: "USDC",
      chain: "base",
      recipient: WALLET,
      instructions: "https://indiegent.com/.well-known/agent-pay.md",
    }, 402);
  }

  // Verify via IndieGent or on-chain
  // ... (same as Express example)

  return c.json({ results: ["..."] });
});

Python (FastAPI)

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import httpx

app = FastAPI()
PRICE = "0.005"
WALLET = "0xYourWalletOnBase"

@app.get("/search")
async def search(request: Request):
    tx_hash = request.headers.get("x-payment-tx")

    if not tx_hash:
        return JSONResponse(
            status_code=402,
            content={
                "error": "payment_required",
                "amount": PRICE,
                "token": "USDC",
                "chain": "base",
                "recipient": WALLET,
                "instructions": "https://indiegent.com/.well-known/agent-pay.md",
            },
        )

    # Verify payment
    async with httpx.AsyncClient() as client:
        resp = await client.post(
            "https://api.indiegent.com/gateway/verify",
            json={
                "gateway_key": "ig_gw_your_key",
                "tx_hash": tx_hash,
                "expected_amount": PRICE,
                "expected_recipient": WALLET,
            },
        )

    if not resp.json().get("verified"):
        return JSONResponse(status_code=402, content={"error": "Payment not verified"})

    return {"results": ["..."]}

Choose Your Path

Managed — Maximum Reach, Zero Effort

  • Set up in a single API call — no payment code to write
  • Listed in the IndieGent marketplace — instant distribution to every agent
  • Automatic billing, settlement, and usage analytics
  • USDC settles directly to your wallet
  • We handle retries, rate limiting, and error recovery

DIY — Full Control, Your Infrastructure

  • Keep 100% of revenue — no platform fees
  • Payments go directly to your wallet with no intermediary
  • Add payments to existing APIs with a simple middleware
  • Verify payments yourself on-chain or via our free verify endpoint
  • Works with Express, Hono, FastAPI, or any HTTP framework

Both options work together. Start with DIY to add agent payments to your API today, then list on the managed marketplace when you want broader distribution. Or go managed from day one and let us handle everything.


What's Next?

IndieGentIndieGent — Independent wallets for independent agents

npm install -g @indiegent/cli