Verify Agent402 signed receipt
POST /api/receipt-verifyVerify the cryptographic signature on an Agent402 signed receipt (a compact JWS, EdDSA over Ed25519) against the receipt keys this server publishes. Send POST /api/receipt-verify with the required field receipt and pay $0.001 per call over x402 or MPP, or call it free by solving a proof-of-work challenge. It returns a JSON object with valid, reason, detail, kid, record and 3 more.
Optionally send the answer text (body) or its SHA-256 (bodySha256), and the request (method, path, body), to check them against what the receipt signs. Returns valid, the key id, a reason when invalid, and the signed fields: route, amount, rail, network, payer, transaction and issue time (trust them only when valid is true). With no published key, every receipt reads unknown_kid. For on-chain settlement of an x402 payment use x402-verify; for an HMAC JWT use jwt-verify.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
receipt | string | yes | The receipt: the compact JWS from the receipt response header, a trailer, or the receipt line that ends a streamed answer. Up to 4096 characters. |
body | string | no | Optional: the answer text exactly as received (up to 65,536 characters; send bodySha256 for a longer one); its SHA-256 must match the receipt's. Up to 65536 characters. |
bodySha256 | string | no | Optional, instead of body: the answer's SHA-256 in hex. Up to 64 characters. |
request | object | no | Optional: { method, path, body } of the call as sent; its digest must match the receipt's. |
Free call, no wallet
This tool runs free with proof of work: fetch a challenge, solve the sha256 puzzle (16 leading zero bits, a fraction of a second of CPU), and resend with the X-Pow-Solution header. JavaScript:
import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=receipt-verify")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/receipt-verify", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "Content-Type": "application/json" }, body: JSON.stringify({"receipt":"eyJhbGciOiJFZERTQSIsImtpZCI6ImRvY3MtZXhhbXBsZSIsInR5cCI6ImFnZW50NDAyLXJlY2VpcHQrandzIn0.eyJ2IjoxLCJpZCI6ImRvY3NFeGFtcGxlUmVjZWlwdDAwMDEiLCJpc3MiOiJodHRwczovL2FnZW50NDAyLnRvb2xzIiwiaWF0IjoiMjAyNi0xMS0yNlQwMDowMDowMC4wMDBaIiwibWV0aG9kIjoiUE9TVCIsInBhdGgiOiIvYXBpL2hhc2giLCJzbHVnIjoiaGFzaCIsInJlcXVlc3RTaGEyNTYiOiJkNDJmZGQ5NjZhZDJjYzU2NDFiYmU4NDg4ODBjM2YxYjIxZTE3NWZjNDBhNGQwNmY5NzViMjQ4YmQ5M2ViNTIyIiwicmVzcG9uc2VTaGEyNTYiOiIyNDNmY2NlN2U5OGVkNDI1NTFiYzM1YjA0OGI3NDMxNzJmZmY5ZWVkMWQyYTJhZWM1NTQwNWQwOTU0Y2ZiYTc2IiwicHJpY2VVc2QiOm51bGwsInJhaWwiOiJjcmVkaXRzIiwibmV0d29yayI6bnVsbCwicGF5ZXIiOm51bGwsInNldHRsZW1lbnQiOm51bGwsInJlcGxheSI6ZmFsc2V9.-GMHkVPAi3tJaEKoUi_s3WMKy3_vYHEsVmHvt7GpP-v7SOkZ1eH4T5_Lz3beJyP_yWmIcJSGf-56cw7Pz1pRDw"}) });Python, standard library only:
import hashlib, json, urllib.request
def zero_bits(digest):
n = 0
for b in digest:
if b:
return n + 8 - b.bit_length()
n += 8
return n
c = json.load(urllib.request.urlopen("https://agent402.tools/api/pow/challenge?slug=receipt-verify"))
n = 0
while zero_bits(hashlib.sha256(f"{c['challenge']}:{n}".encode()).digest()) < c["difficulty"]:
n += 1
req = urllib.request.Request("https://agent402.tools/api/receipt-verify", method="POST", data="{\"receipt\":\"eyJhbGciOiJFZERTQSIsImtpZCI6ImRvY3MtZXhhbXBsZSIsInR5cCI6ImFnZW50NDAyLXJlY2VpcHQrandzIn0.eyJ2IjoxLCJpZCI6ImRvY3NFeGFtcGxlUmVjZWlwdDAwMDEiLCJpc3MiOiJodHRwczovL2FnZW50NDAyLnRvb2xzIiwiaWF0IjoiMjAyNi0xMS0yNlQwMDowMDowMC4wMDBaIiwibWV0aG9kIjoiUE9TVCIsInBhdGgiOiIvYXBpL2hhc2giLCJzbHVnIjoiaGFzaCIsInJlcXVlc3RTaGEyNTYiOiJkNDJmZGQ5NjZhZDJjYzU2NDFiYmU4NDg4ODBjM2YxYjIxZTE3NWZjNDBhNGQwNmY5NzViMjQ4YmQ5M2ViNTIyIiwicmVzcG9uc2VTaGEyNTYiOiIyNDNmY2NlN2U5OGVkNDI1NTFiYzM1YjA0OGI3NDMxNzJmZmY5ZWVkMWQyYTJhZWM1NTQwNWQwOTU0Y2ZiYTc2IiwicHJpY2VVc2QiOm51bGwsInJhaWwiOiJjcmVkaXRzIiwibmV0d29yayI6bnVsbCwicGF5ZXIiOm51bGwsInNldHRsZW1lbnQiOm51bGwsInJlcGxheSI6ZmFsc2V9.-GMHkVPAi3tJaEKoUi_s3WMKy3_vYHEsVmHvt7GpP-v7SOkZ1eH4T5_Lz3beJyP_yWmIcJSGf-56cw7Pz1pRDw\"}".encode(), headers={"X-Pow-Solution": f"{c['token']}:{n}", "Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(req)))Example request
curl -i -X POST https://agent402.tools/api/receipt-verify \
-H "Content-Type: application/json" \
-d '{"receipt":"eyJhbGciOiJFZERTQSIsImtpZCI6ImRvY3MtZXhhbXBsZSIsInR5cCI6ImFnZW50NDAyLXJlY2VpcHQrandzIn0.eyJ2IjoxLCJpZCI6ImRvY3NFeGFtcGxlUmVjZWlwdDAwMDEiLCJpc3MiOiJodHRwczovL2FnZW50NDAyLnRvb2xzIiwiaWF0IjoiMjAyNi0xMS0yNlQwMDowMDowMC4wMDBaIiwibWV0aG9kIjoiUE9TVCIsInBhdGgiOiIvYXBpL2hhc2giLCJzbHVnIjoiaGFzaCIsInJlcXVlc3RTaGEyNTYiOiJkNDJmZGQ5NjZhZDJjYzU2NDFiYmU4NDg4ODBjM2YxYjIxZTE3NWZjNDBhNGQwNmY5NzViMjQ4YmQ5M2ViNTIyIiwicmVzcG9uc2VTaGEyNTYiOiIyNDNmY2NlN2U5OGVkNDI1NTFiYzM1YjA0OGI3NDMxNzJmZmY5ZWVkMWQyYTJhZWM1NTQwNWQwOTU0Y2ZiYTc2IiwicHJpY2VVc2QiOm51bGwsInJhaWwiOiJjcmVkaXRzIiwibmV0d29yayI6bnVsbCwicGF5ZXIiOm51bGwsInNldHRsZW1lbnQiOm51bGwsInJlcGxheSI6ZmFsc2V9.-GMHkVPAi3tJaEKoUi_s3WMKy3_vYHEsVmHvt7GpP-v7SOkZ1eH4T5_Lz3beJyP_yWmIcJSGf-56cw7Pz1pRDw"}'Without payment this returns HTTP 402 Payment Required with the exact price for receipt-verify; any x402 v2 or MPP client pays it and retries.
Watch a call get paid
POST /api/receipt-verify$0.001 USDCPAYMENT-SIGNATUREon 14 chains200 OKAgent402-ReceiptEd25519Example response
{
"valid": false,
"reason": "unknown_kid",
"detail": "The receipt names a key id this server does not publish.",
"kid": "docs-example",
"record": {
"v": 1,
"id": "docsExampleReceipt0001",
"iss": "https://agent402.tools",
"iat": "2026-11-26T00:00:00.000Z",
"method": "POST",
"path": "/api/hash",
"slug": "hash",
"requestSha256": "d42fdd966ad2cc5641bbe848880c3f1b21e175fc40a4d06f975b248bd93eb522",
"responseSha256": "243fcce7e98ed42551bc35b048b743172fff9eed1d2a2aec55405d0954cfba76",
"priceUsd": null,
"rail": "credits",
"network": null,
"payer": null,
"settlement": null,
"replay": false
},
"fields": {
"route": "POST /api/hash",
"slug": "hash",
"priceUsd": null,
"rail": "credits",
"network": null,
"payer": null,
"transaction": null,
"issuedAt": "2026-11-26T00:00:00.000Z",
"issuer": "https://agent402.tools",
"id": "docsExampleReceipt0001",
"replay": false
},
"keys": [],
"keySet": "/.well-known/agent402-receipt-key.json"
}| Field | Type | Always present | In the example |
|---|---|---|---|
valid | boolean | yes | false |
reason | string | yes | unknown_kid |
detail | string | yes | The receipt names a key id this server does not publish. |
kid | string | yes | docs-example |
record | object | yes | 15 fields: v, id, iss, iat, method, path and 9 more |
fields | object | yes | 11 fields: route, slug, priceUsd, rail, network, payer and 5 more |
keys | array | yes | 0 items in the example |
keySet | string | yes | /.well-known/agent402-receipt-key.json |
From an MCP client
catalog.call {
"slug": "receipt-verify",
"params": {
"receipt": "eyJhbGciOiJFZERTQSIsImtpZCI6ImRvY3MtZXhhbXBsZSIsInR5cCI6ImFnZW50NDAyLXJlY2VpcHQrandzIn0.eyJ2IjoxLCJpZCI6ImRvY3NFeGFtcGxlUmVjZWlwdDAwMDEiLCJpc3MiOiJodHRwczovL2FnZW50NDAyLnRvb2xzIiwiaWF0IjoiMjAyNi0xMS0yNlQwMDowMDowMC4wMDBaIiwibWV0aG9kIjoiUE9TVCIsInBhdGgiOiIvYXBpL2hhc2giLCJzbHVnIjoiaGFzaCIsInJlcXVlc3RTaGEyNTYiOiJkNDJmZGQ5NjZhZDJjYzU2NDFiYmU4NDg4ODBjM2YxYjIxZTE3NWZjNDBhNGQwNmY5NzViMjQ4YmQ5M2ViNTIyIiwicmVzcG9uc2VTaGEyNTYiOiIyNDNmY2NlN2U5OGVkNDI1NTFiYzM1YjA0OGI3NDMxNzJmZmY5ZWVkMWQyYTJhZWM1NTQwNWQwOTU0Y2ZiYTc2IiwicHJpY2VVc2QiOm51bGwsInJhaWwiOiJjcmVkaXRzIiwibmV0d29yayI6bnVsbCwicGF5ZXIiOm51bGwsInNldHRsZW1lbnQiOm51bGwsInJlcGxheSI6ZmFsc2V9.-GMHkVPAi3tJaEKoUi_s3WMKy3_vYHEsVmHvt7GpP-v7SOkZ1eH4T5_Lz3beJyP_yWmIcJSGf-56cw7Pz1pRDw"
}
}On the hosted connector at https://agent402.tools/mcp, catalog.call runs receipt-verify free (rate-limited, no wallet). Local install: npx -y agent402-mcp@0.17.1.
Errors and behavior
receiptis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. Some calls are paid before they run; a failed one can be retried free with the same payment, or is refunded. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Free tier: no outbound network call leaves the server for this tool, so proof-of-work (16 leading zero bits of sha256) pays for it.
- A
GETorHEADto /api/receipt-verify returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.001" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/receipt-verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"receipt": "eyJhbGciOiJFZERTQSIsImtpZCI6ImRvY3MtZXhhbXBsZSIsInR5cCI6ImFnZW50NDAyLXJlY2VpcHQrandzIn0.eyJ2IjoxLCJpZCI6ImRvY3NFeGFtcGxlUmVjZWlwdDAwMDEiLCJpc3MiOiJodHRwczovL2FnZW50NDAyLnRvb2xzIiwiaWF0IjoiMjAyNi0xMS0yNlQwMDowMDowMC4wMDBaIiwibWV0aG9kIjoiUE9TVCIsInBhdGgiOiIvYXBpL2hhc2giLCJzbHVnIjoiaGFzaCIsInJlcXVlc3RTaGEyNTYiOiJkNDJmZGQ5NjZhZDJjYzU2NDFiYmU4NDg4ODBjM2YxYjIxZTE3NWZjNDBhNGQwNmY5NzViMjQ4YmQ5M2ViNTIyIiwicmVzcG9uc2VTaGEyNTYiOiIyNDNmY2NlN2U5OGVkNDI1NTFiYzM1YjA0OGI3NDMxNzJmZmY5ZWVkMWQyYTJhZWM1NTQwNWQwOTU0Y2ZiYTc2IiwicHJpY2VVc2QiOm51bGwsInJhaWwiOiJjcmVkaXRzIiwibmV0d29yayI6bnVsbCwicGF5ZXIiOm51bGwsInNldHRsZW1lbnQiOm51bGwsInJlcGxheSI6ZmFsc2V9.-GMHkVPAi3tJaEKoUi_s3WMKy3_vYHEsVmHvt7GpP-v7SOkZ1eH4T5_Lz3beJyP_yWmIcJSGf-56cw7Pz1pRDw"
}),
});No wallet yet? Fund a first one with USDC on Base, no ETH needed, or run npx -y agent402-mcp@0.17.1 wallet new to make one on this computer: it stores the key and prints the address and the config, never the key.
Related tools
Verify x402 settlement
Confirm a USDC payment actually settled: given a tx hash (and network), returns whether it succeeded and the USDC.
Verify B20 token
Boolean verdict with reasons: is this address a real factory-issued B20 on Base?
Rate a call you paid for
Tell this server whether a call you paid for delivered what it promised.
Transaction status
Check the confirmation status of a transaction by hash on Base/Polygon/Arbitrum One/OP Mainnet/Ethereum/Celo/Avalanche.
SQL execution certificate verify
Verify an Ed25519 execution certificate against the exact SQL statement you are about to run - the gate your database.
Audit report (one wallet's paid history, signed)
An audit report of your own wallet's paid history here, a record of every paid call: each call over a window of up.