Intents Checkout quickstart
Create an invoice, send the customer to checkout, and get told when it is paid.
Set up Intents Checkout with your AI agent
Paste this into Claude Code, Cursor, Codex or any coding agent, at your app's root:
Read https://intents.fi/docs/agent-setup/checkout.md and follow it.Adds an invoice route, a verified webhook handler and a pay button, then proves it with a test payment. Test keys only: no money moves.
Three things: create an invoice, send the customer to the url it comes back with, and handle the
invoice.paid webhook. Everything below runs against a ik_test_ key, so no money moves.
No account yet? Sign up with Google, GitHub, Discord, X, your wallet or email; setup hands you a test key in a couple of minutes. See the Intents Checkout overview for going live.
1. Create an invoice
Section titled “1. Create an invoice”An invoice is priced in USD. The customer pays in whatever they hold; you receive one settlement asset, a USD stablecoin or native Bitcoin, at your own address.
curl https://api.intents.fi/v0/invoices \ -X POST \ -H 'authorization: Bearer $INTENTS_SECRET_KEY' \ -H 'x-intents-affiliate: <x-intents-affiliate>' \ -H 'content-type: application/json' \ -d '{ "amount": "49.00", "settlement": { "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "address": "0x6A3fB91c7D8e45A2b0C1fE97D3a8B52c4e7F10dA" }, "reference": "order_1042", "description": "Pro plan — 1 month", "customerEmail": "ana@example.com", "successUrl": "https://northwood.example/thanks" }'const response = await fetch("https://api.intents.fi/v0/invoices", { method: "POST", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, "content-type": "application/json", }, body: JSON.stringify({ "amount": "49.00", "settlement": { "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "address": "0x6A3fB91c7D8e45A2b0C1fE97D3a8B52c4e7F10dA" }, "reference": "order_1042", "description": "Pro plan — 1 month", "customerEmail": "ana@example.com", "successUrl": "https://northwood.example/thanks" }),});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.post( "https://api.intents.fi/v0/invoices", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"}, json={ "amount": "49.00", "settlement": { "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "address": "0x6A3fB91c7D8e45A2b0C1fE97D3a8B52c4e7F10dA" }, "reference": "order_1042", "description": "Pro plan — 1 month", "customerEmail": "ana@example.com", "successUrl": "https://northwood.example/thanks" },)response.raise_for_status()data = response.json()The response (a real test-mode invoice; the client secret is cut short):
{ "id": "inv_9Q8t8jmDz9rSqE_Bds4rz96cuUZUf4wb", "status": "open", "mode": "test", "amount": "49.00", "currency": "USD", "reference": "order_1042", "description": null, "customerEmail": null, "settlement": { "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "address": "0x362239F4334464f68445691F6358B7cad827E431", "amountExpected": "49000000", "amountNet": "48804000" }, "fee": { "bps": 40, "amount": "196000" }, "absorbRouteCost": false, "priceLock": null, "url": "https://pay.intents.fi/c/inv_9Q8t8jmDz9rSqE_Bds4rz96cuUZUf4wb", "successUrl": null, "cancelUrl": null, "metadata": {}, "overpaid": false, "needsReview": false, "payer": null, "txs": { "origin": [], "settlement": [], "refund": [] }, "channel": null, "attempts": [], "expiresAt": "2026-11-25T16:09:51.509Z", "paidAt": null, "createdAt": "2026-11-25T15:39:51.520Z", "updatedAt": "2026-11-25T15:39:51.520Z", "clientSecret": "inv_9Q8t8jmDz9rSqE_Bds4rz96cuUZUf4wb_secret_…"}Three fields to keep:
id— your handle on the invoice from here on.url— where you send the customer. Nothing to build.clientSecret— shown once, and only needed if you build your own checkout. We keep a hash of it and cannot tell it to you later.
amountExpected and amountNet are integer strings in the settlement asset’s base units, not
decimals: 49000000 is $49.00 of a six-decimal stablecoin. Do the maths in BigInt, never a
float. If you settle in BTC they are sats, locked from live
quotes when the invoice is created (priceLock), so match your orders on amount, the USD price.
reference is your idempotency key
Section titled “reference is your idempotency key”reference is your own order ID, unique per merchant and mode (test and live keys never share one). Sending the same one twice returns 200
with the invoice that already exists instead of creating a second one, so a retried create can
never charge a customer twice. On a replay clientSecret comes back null, because it is stored
as a hash.
Use a fresh reference for a genuine retry: order_1042.2.
2. Send the customer to the checkout
Section titled “2. Send the customer to the checkout”Redirect to invoice.url. The hosted page handles the whole payment: picking a token, showing a
QR code and the exact amount, warning about the chain, taking a refund address, counting down to
expiry and showing the paid state.
const invoice = await createInvoice(cart);await db.orders.update(cart.id, { invoiceId: invoice.id });return Response.redirect(invoice.url, 303);Pass successUrl on create and the page sends the customer back to you when it is done. Do not
treat a return to successUrl as proof of payment: it only means the browser came back. The
webhook is the proof.
3. Find out when it is paid
Section titled “3. Find out when it is paid”Register an endpoint once, subscribed to the invoice events:
curl https://api.intents.fi/v0/webhooks \ -X POST \ -H 'authorization: Bearer $INTENTS_SECRET_KEY' \ -H 'content-type: application/json' \ -d '{ "url": "https://northwood.example/hooks/intents" }'const response = await fetch("https://api.intents.fi/v0/webhooks", { method: "POST", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, "content-type": "application/json", }, body: JSON.stringify({ "url": "https://northwood.example/hooks/intents" }),});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.post( "https://api.intents.fi/v0/webhooks", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"}, json={ "url": "https://northwood.example/hooks/intents" },)response.raise_for_status()data = response.json()Then verify and handle. The signature scheme and the retry behaviour are on the webhooks page; the short version:
import { createHmac, timingSafeEqual } from "node:crypto";
export async function POST(request: Request) { const body = await request.text(); // the raw bytes, not the parsed JSON const header = request.headers.get("x-intents-signature") ?? ""; if (!verify(process.env.INTENTS_WEBHOOK_SECRET!, body, header)) { return new Response("bad signature", { status: 400 }); }
const event = JSON.parse(body); if (event.type === "invoice.paid") { // Duplicates and out-of-order delivery are normal. Make this idempotent. await fulfil(event.data.reference, { invoiceId: event.data.id, late: event.late === true }); } return new Response(null, { status: 204 });}
function verify(secret: string, body: string, header: string): boolean { const parts = Object.fromEntries(header.split(",").map((kv) => kv.split("="))); const timestamp = Number(parts.t); if (!Number.isInteger(timestamp) || !parts.v1) return false; if (Math.abs(Date.now() / 1000 - timestamp) > 300) return false; const expected = createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex"); const a = Buffer.from(expected, "hex"); const b = Buffer.from(parts.v1, "hex"); return a.length === b.length && timingSafeEqual(a, b);}invoice.paid fires when the money has settled to your address, and only then. The data of
every invoice event is byte-for-byte what GET /v0/invoices/{id} returns, so there is one shape
to parse.
If you would rather poll
Section titled “If you would rather poll”curl https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw \ -H 'authorization: Bearer $INTENTS_SECRET_KEY'const response = await fetch("https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw", { method: "GET", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, },});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.get( "https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},)response.raise_for_status()data = response.json()Poll no faster than every two seconds while a customer is watching, and back off to ten seconds after five minutes. The invoice carries its own expiry, so there is nothing to time out yourself.
4. The states you have to handle
Section titled “4. The states you have to handle”| Status | What happened | What to do |
|---|---|---|
open |
nothing sent yet | wait |
processing |
money seen, not settled | wait; do not fulfil |
underpaid |
less arrived than asked | the customer can top up against the same address until expiry |
paid |
settled to your address | fulfil |
expired |
nobody paid in time | create a new invoice with a new reference |
canceled |
you called it off | nothing |
Returned payments arrive minus network costs. When a payment can’t complete (it came in after expiry, or short and never topped up), it goes back to the payer’s refund address, less the network costs of sending it back. In a live test, 2.5 USDT sent came back as 2.2 USDT. The payment page says so next to the refund address field.
Two flags ride along on a paid invoice:
overpaid— more than 0.5% too much arrived. The money is yours; what to refund is your call.needsReview— a human should look. Usually a late payment: it settled after expiry, so the invoice ispaidandinvoice.paidcarrieslate: true. You decide whether to fulfil.
Both show in the dashboard, and needsReview emails you.
5. Cancel what you no longer want
Section titled “5. Cancel what you no longer want”curl https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel \ -X POST \ -H 'authorization: Bearer $INTENTS_SECRET_KEY'const response = await fetch("https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel", { method: "POST", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, },});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.post( "https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},)response.raise_for_status()data = response.json()Only an open invoice can be cancelled. Anything else returns
INVOICE_NOT_OPEN.
Going live
Section titled “Going live”- Swap
ik_test_forik_live_, and register a live webhook endpoint — endpoints are per mode. - Check the settlement address on the dashboard against the one in your wallet, character by character.
- Make your webhook handler idempotent, and store
invoice.idagainst your own order. - Pay yourself $5 for real, from a phone, on the chain your customers will actually use.
What this does not do
Section titled “What this does not do”- No custody. The money goes customer → protocol → your address. We never hold it.
- No chargebacks. A settled payment is settled.
- No fiat payout. You receive a USD stablecoin or native Bitcoin at your own address, and choose your own off-ramp.