Approval receipts
When a request is approved, the agent gets a short-lived signed receipt, and the tool that does the work checks it before acting: this workspace, this action, these details, at most this amount.
Until now the agent was trusted twice: to act only on allowed: true, and to run what it asked about. An approval receipt removes the second. When a request is approved, the agent’s answer carries receipt, a short-lived string VariantGate signed. The agent hands it to the tool that does the work, such as a refund service, a deploy script or an MCP server, and the tool checks it before acting: this workspace, this action, these details, at most this amount.
So an agent that asks to refund €30 to order A-1001 and then calls the refund tool with €3,000, or with order B-2002, is refused by the tool itself, whether the agent is confused or a prompt injection is steering it.
When there is a receipt
The agent’s own reads carry one: the answer when it creates a request, GET /v1/requests/{id}, and the MCP tools. It is there only while the agent may act:
- Given once a person approves, or an
allowrule an owner wrote does. - Not given while the request waits, or once it is denied, expired or withdrawn.
- Not given while the workspace or the agent’s key is paused.
- Not given once the agent has reported how the action went: the work is done, and a new receipt would let it be done again.
- Not given more than an hour after the decision: an approval left unused that long has to be asked for again.
{
"id": "0196f1a0-55d2-7a11-b3e4-9f8e7d6c5b4a",
"status": "approved",
"allowed": true,
"amount": "30.00",
"currency": "EUR",
"receipt": "vgr1.eyJ2IjoxLCJraWQiOiI0ZjFj….3q2-Xk…",
…
}People reading the request in the inbox never see a receipt. A self-hosted server signs receipts only when RECEIPT_SIGNING_KEY is set.
Check it in the tool
Both SDKs check receipts without a network call. Install them as shown on SDK and command line. In TypeScript, verifyReceipt returns { ok: true, claims } or { ok: false, reason }:
import { verifyReceipt } from "@variantgate/agent/receipt";
import RECEIPT_KEYS from "./receipt-keys.json"; // from /v1/receipt-keys
const seen = new Set<string>(); // request ids this tool already acted on
export function refund(receipt: string, order: string, amount: string) {
const check = verifyReceipt(receipt, {
keys: RECEIPT_KEYS,
workspace: "YOUR_WORKSPACE_ID",
action: "refund.create",
details: { order, reason: "damaged" },
amount,
currency: "EUR",
seen, // optional: refuses a used receipt, and adds this one
});
if (!check.ok) throw new Error(`Refused: ${check.reason}`);
// ...now move the money
}In Python, verify_receipt takes the same settings as keyword arguments, also agent_key=, returns the claims and raises ReceiptError with the reason:
from variantgate import ReceiptError, verify_receipt
seen: set[str] = set() # request ids this tool already acted on
def refund(receipt: str, order: str, amount: str) -> None:
try:
verify_receipt(
receipt,
keys=RECEIPT_KEYS, # from /v1/receipt-keys
workspace="YOUR_WORKSPACE_ID",
action="refund.create",
details={"order": order, "reason": "damaged"},
amount=amount,
currency="EUR",
seen=seen, # optional: refuses a used receipt, and adds this one
)
except ReceiptError as refused:
raise RuntimeError(f"Refused: {refused}") from refused
# ...now move the moneyPass the details and amount the tool is about to use, taken from its own arguments, never from the receipt.
The signing keys
Receipts are signed with Ed25519. Fetch the public keys once, with no key needed, and pin the answer in the tool’s settings, so a check needs no call and nobody can swap the key in transit:
curl https://api.variantgate.com/v1/receipt-keys
{
"keys": [
{
"kid": "4f1c8a2e9b7d3065",
"alg": "Ed25519",
"public_key": "<the 32-byte public key, base64url>"
}
]
}What a passing check proves
- Signed by VariantGate
- The signature matches a pinned key.
- This workspace
- The receipt names the workspace id the tool pinned. Without this, a receipt from someone else's workspace with the same details would pass.
- This action
- The action name is the one approved.
- These details
- The details the tool is about to run hash to the approved details: SHA-256 of their canonical JSON.
- At most this amount
- The amount is at or below the approved amount, in the same currency. A person may have lowered it when approving.
- Still fresh
- Issued less than five minutes ago, with 30 seconds of leeway for clocks.
- Not used before
- Optional: pass a set of request ids already used, and a second use is refused.
A refusal comes with one reason: not a VariantGate receipt, signed by an unknown key, signature does not match, receipt is for another workspace, receipt is for another action, details differ from what was approved, this approval has an amount limit: pass the amount you will move, currency differs, amount is above what was approved, this approval states no amount, approved for another agent key, receipt has expired, receipt is from the future, or receipt was already used.
Five minutes, and once
The check runs offline, so a tool cannot see a pause that starts after the receipt was issued. That is why a receipt lasts five minutes: a pause stops new receipts at once, and the ones already out run out soon after. An agent that needs longer reads the request again for a fresh receipt, which it gets only while it is still allowed, and for at most an hour after the decision. After that it has to ask again.
Every fresh receipt for one request carries the same request id, so a tool that must act once per approval passes seen and keeps each id for at least an hour and ten minutes. Use durable storage, shared when the tool runs on more than one machine: an in-memory set forgets everything when the process restarts.
The format
vgr1.<payload>.<signature>. The payload is base64url, without padding, of these claims as UTF-8 JSON; the signature is Ed25519 over the ASCII bytes of vgr1.<payload>, also base64url without padding.
{
"v": 1,
"kid": "4f1c8a2e9b7d3065",
"rid": "0196f1a0-55d2-7a11-b3e4-9f8e7d6c5b4a",
"ws": "0196f19c-1b2a-7e45-8d3c-6a7b9c0d1e2f",
"key": "0196f1a0-0d0e-7a11-b3e4-5f6a7b8c9d0e",
"act": "refund.create",
"amt": "30.00",
"cur": "EUR",
"dig": "<sha-256 of the canonical details, lowercase hex>",
"iat": 1795000000,
"exp": 1795000300
}rid is the request, ws the workspace, key the agent key that asked, act the action, amt and cur the approved amount, dig the details hash, and iat and exp the times in seconds since 1970.
Canonical JSON
The API, the SDKs and your own code must hash the same bytes for the same details. Object keys are sorted by UTF-16 code unit (what a plain .sort() on keys does in JavaScript), there is no whitespace, strings are escaped as JSON.stringify escapes them, and a whole number is written without a fraction. This:
{"order":"A-1001","amount":"30.00","to":{"name":"Ana","email":"ana@example.com"},"items":[2,1.5,true,null]}is written as:
{"amount":"30.00","items":[2,1.5,true,null],"order":"A-1001","to":{"email":"ana@example.com","name":"Ana"}}Keep money, big numbers and fractions in strings, such as "30.00". A number JavaScript cannot hold exactly may be written differently by another language. That makes a check fail, never pass, but it fails a call that should have run.
What it does not do
A receipt protects only a tool that checks it. A tool that never calls verifyReceipt, or an agent that can reach the payment API directly, is not stopped by it. Put the check in the code that holds the credentials, and keep the credentials away from the agent.
Prior art
Binding an approval to the exact call is not a new idea. It is discussed in IETF individual drafts such as “EP Authorization Receipts” and “AI Attestation Receipts”, and in blog posts. Auth0’s CIBA async authorization returns an access token after a person approves, but that token is not bound to the arguments of one call. VariantGate ships receipts as part of the approval service, with checks in the TypeScript and Python SDKs.
Try it without signing up in the playground: send “Refund €30, then €3,000”, approve it, and change what the tool is about to run. See also Requests and Summary check.