AgentgridDOCS Sign in to console Create account

Agentgrid Docs

Accept UPI payments in your shop, and let AI agents pay on a person's behalf, within limits that person sets at their own bank.

Set me up to pay with Agentgrid. Fetch https://agentgrid.site/agentgrid.md and follow it.

Start building

Everything runs in the sandbox first: demo banks, no real money.

SDKs

Five languages, all passing the same shared test cases.

npm install agentgrid

Get started

Shop quickstart

Take your first test payment in about five minutes. You need no shop id and no API key to begin: signing up makes a sandbox shop for you.

  1. Sign upCreate an account at app.agentgrid.site with your email or Google. You get a sandbox shop, and the welcome questions name it.
  2. Make a test keyIn the console, open API keys and choose New test key. It starts with gk_test_ and is shown once, so copy it into your server's settings.
  3. Create an orderFrom your server, never from the browser:
    curl
    curl https://app.agentgrid.site/gw/v1/orders \
      -H "Authorization: Bearer $AGENTGRID_KEY" \
      -H "Content-Type: application/json" \
      -d '{"orderId":"ORD-1001","amount":"499.00","note":"T-shirt"}'
    The answer has a checkoutUrl. Send your customer there.
  4. Pay itOn the checkout, pay as success@sandbox with PIN 1234. The order turns PAID, and your webhook is called.
  5. Confirm before you shipRead GET /gw/v1/orders/{id} or trust a verified webhook. Never trust the customer's browser.
TipThe same orderId and amount always give back the same order, so a retry after a timeout is always safe.

Get started

Sandbox and test mode

A new shop is a sandbox shop. Every request runs through the simulator, whatever the key says. To go live, open Go live in the console and send the business's details and settlement account; live keys open once an operator approves them. In the sandbox you can make the network behave the way you need to test:

Pay as (PIN 1234)What happens
success@sandboxThe payment succeeds.
decline@sandboxThe payer's bank declines it.
nofunds@sandboxFails for lack of money.
slow@sandboxStays PROCESSING for about ten seconds, then turns PAID.
deemed@sandboxThe bank's reply is lost: the payment is DEEMED and stays processing, never failed, until it is settled.

Test orders never reach the payment network, and test webhooks can be streamed to your machine while you build.

Agents

Set up your agent

A person, the payer, lets an AI agent spend for them. They register the agent in their payer app and approve a reserve with their UPI PIN: an amount their bank blocks for that agent alone. The agent never sees the PIN.

  1. The payer registers the agentThey name it, set the reserve, a per-payment cap, an end date and, if they like, the only payees it may pay. They get a one-time access token starting aat_.
  2. Connect the agent over MCPRun this once, with that token:
    terminal
    claude mcp add --transport http agentgrid-pay https://app.agentgrid.site/agent/mcp \
      --header "Authorization: Bearer aat_..."
  3. Let it read the rulesPoint the agent at agentgrid.md. It is the same guide as this section, in one file an agent can read before its first payment.

Agents

The rules agents pay by

  • No PIN, ever. The payer entered it once, at their bank, when they gave the agent its reserve.
  • The payer's bank checks every payment. A payment outside the reserve is refused. The agent should tell the person, not try to get around it.
  • Some purchases wait for the payer. Above the per-payment cap, or to a payee the agent may not pay, the answer is NEEDS_APPROVAL. The agent tells the person, then checks later.
  • A new idempotency key for every purchase. The same key is reused only to retry that purchase, so it can never be paid twice.
  • The payer can stop the agent at any time. Its credentials stop working at once.
Good practiceBefore paying, the agent says what it is buying, from whom and for how much, and keeps the receipt.

Agents

MCP tools

Amounts are written as rupees, such as "49.00", and returned in paise.

ToolWhat it does
reserve_statusHow much is left, the per-payment cap, the allowed payees and the end date.
payPay a UPI address: to, amount, note, idempotencyKey.
pay_orderPay a shop's checkout order by its id (order_…, from the checkout link).
pay_api_callPay an API that answered HTTP 402. See pay per call.
make_payment_tokenA one-time token for one payee and one exact amount, valid up to 60 minutes.
approval_statusWhether the payer approved a purchase that was waiting for them.

Agents

Signed requests

For a stronger tie between the agent and its key, the agent holds an Ed25519 key, the payer registers its public key, and the agent signs every HTTP request with these headers:

HeaderValue
Agent-IdThe agent's id from the payer app.
Agent-TimestampUnix seconds, within 5 minutes of now.
Agent-Nonce16 to 64 characters, never reused.
Agent-SignatureEd25519 over the six lines below, base64url.

The signature covers exactly these six lines, joined by \n:

signed text
agentgrid-v1
<METHOD>
<path>
<timestamp>
<nonce>
<hex SHA-256 of the body>

Endpoints

RequestDoes
POST /agent/v1/payPay a UPI address.
POST /agent/v1/checkoutPay a shop order.
POST /agent/v1/x402/payPay an HTTP 402 request.
POST /agent/v1/tokensMake a one-time payment token.
GET /agent/v1/reserveRead the reserve.
GET /agent/v1/approvals/{id}Read an approval.

Active agent keys, and the key that seals receipts and evidence (psp-records), are published at /.well-known/agent-keys.

Agents

Pay per call (HTTP 402)

An API can charge per request by answering 402 Payment Required with its price:

402 response body
{ "payTo": "api@bank", "amount": "0.50", "resource": "https://api.example/v1/search", "nonce": "…" }
  1. Pay itCall pay_api_call (or POST /agent/v1/x402/pay) with payTo, amount, resource and nonce.
  2. Retry with the receiptRepeat the original request with the returned xPaymentHeader as X-Payment.

Paying again for the same resource and nonce never charges twice.

Agents

One-time payment tokens

When a shop's checkout asks for a token rather than a payment, the agent makes one with make_payment_token. It works for one payee, for one exact amount, once, and for at most 60 minutes. The shop sees a verified agent badge on the order, and its webhooks mark the order as paid by an agent.

Protocols

AP2 mandates

Agentgrid speaks the mandate format of Google's Agent Payments Protocol. Every signature is EdDSA by the PSP's record key, published as psp-records at /.well-known/agent-keys.

MandateOn Agentgrid
CartMandateAny open order, from GET /gw/v1/public/orders/{id}/ap2-cart. merchant_authorization is a JWT whose cart_hash covers the cart. It lasts 15 minutes.
PaymentMandateWhat the agent gets back from POST /agent/v1/ap2/pay. user_authorization is the PSP's attestation that the payer approved the reserve with their UPI PIN, over the cart and payment hashes.
IntentMandateThe agent's reserve, from GET /agent/v1/ap2/intent: what it may spend, where and until when.
Node
const cart = await (await fetch(`${psp}/gw/v1/public/orders/${orderId}/ap2-cart`)).json();
const { payment_mandate } = await agent.payCartMandate(cart);
verifyPspJwt(payment_mandate.user_authorization, await pspRecordKey(psp));
NoteOn UPI, the payer's consent is the reserve their bank holds. So user_authorization is signed by Agentgrid, not by a wallet credential on the payer's device.

Protocols

x402 version 2

Agentgrid is a facilitator for x402 v2 on a fiat network: scheme exact, network upi:in, asset INR, the amount in paise and payTo a UPI address.

RequestDoes
GET /x402/v2/supportedThe kinds this facilitator settles.
POST /x402/v2/verifyChecks a payment payload against your requirements. It reads only and spends nothing.
POST /x402/v2/settlePays from the agent's reserve, once. The transaction is the UPI transaction id, and settling again returns the same answer.
POST /agent/v1/x402/v2/authorizeFor the agent: turns a 402's PAYMENT-REQUIRED into the PAYMENT-SIGNATURE value.
Your API's 402, in the PAYMENT-REQUIRED header (base64)
{ "x402Version": 2,
  "accepts": [{ "scheme": "exact", "network": "upi:in", "asset": "INR",
                "amount": "50", "payTo": "api@yourbank", "maxTimeoutSeconds": 60 }] }

The payload is a one-time agent token for exactly that payee and amount. Agents using fetchPaying in the Node SDK handle both x402 v2 and Agentgrid's own 402 without extra code.

Protocols

ACP checkout

The merchant side of the Agentic Commerce Protocol's checkout, from OpenAI and Stripe, served from your catalogue. Give the agent platform a restricted key with orders:write.

RequestDoes
POST /gw/v1/acp/checkout_sessionsStarts a session from items: [{id, quantity}]: your product ids, with GST per line. Amounts are in paise and the currency is inr. Idempotency-Key is honoured.
GET or POST /gw/v1/acp/checkout_sessions/{id}Reads or updates the session.
POST …/{id}/completePays with payment_data: {token, provider: "agentgrid"}, where the token is the agent's one-time token for your shop and the total. It makes your order and returns the completed session.
POST …/{id}/cancelCancels an open session.

Protocols

LangChain and Vercel AI SDK

Give an agent built with either framework its payment tools in one line. The SDK has no dependencies: you pass in the framework's own helpers.

Vercel AI SDK
import { tool, jsonSchema, generateText } from 'ai';
import { AgentClient } from 'agentgrid/agent';
import { vercelTools } from 'agentgrid/ai';

const agent = new AgentClient({ baseUrl: 'https://app.agentgrid.site', agentId, key });
await generateText({ model, tools: vercelTools(agent, { tool, jsonSchema }), prompt });
LangChain (Python)
from agentgrid_pay import AgentClient, langchain_tools

agent = AgentClient("https://app.agentgrid.site", agent_id, key)
tools = langchain_tools(agent)   # pip install "agentgrid-pay[langchain]"

The tools are reserve_status, pay, pay_order, pay_cart_mandate, make_payment_token and approval_status. In Node there is also fetch_paid_api, and LangChain.js uses langchainTools(agent, { tool }). The Go, PHP and Java SDKs have the same AgentClient.

Shops

Accept payments

An order is one amount you want paid. Create it from your server with your key; each order gets a hosted checkout with a UPI QR that every UPI app reads.

RequestDoes
POST /gw/v1/ordersMake an order. The same orderId and amount give back the same order.
GET /gw/v1/orders/{id}Read an order. Confirm payment here before you ship.
GET /gw/v1/ordersList orders.
POST /gw/v1/orders/{id}/cancelCancel an order nobody has started paying.
GET /gw/v1/shop/qrYour shop's static UPI QR, for the counter.

Send your key as Authorization: Bearer <key>. Every request and its fields are in the API reference, where you can also try them with a test key.

Shops

Webhooks

Set your webhook address in the console. When an order is paid, refunded or disputed, Agentgrid sends you a signed event, and retries with back-off until you answer 2xx.

  • Check the X-Gateway-Signature-V2 header before you trust an event. Each SDK does this for you, as in verify_webhook in Python.
  • The list of events, their versions and the signature format is at GET /gw/v1/events.
  • See every delivery under GET /gw/v1/webhooks, and send an abandoned one again with its resend request.
  • POST /gw/v1/webhooks/test sends a test ping to your address.

Shops

Refunds

Refund all or part of a paid order with POST /gw/v1/orders/{id}/refunds. A refund needs the shop's UPI PIN, used once and never stored. Above an amount you set, one person asks and a second person approves it, under /gw/v1/refund-requests.

Shops

Keys for your own agents

Never give an agent your full key. Make a restricted key in the console with only the scopes it needs, such as orders:read. Your shop also has an MCP server of its own, with tools such as list_orders, sales_summary, propose_refund and propose_rule. No tool acts by itself: a person approves what an agent proposes, and every call is audited.