# Agent decision receipts, the specification

> The open format of an Immiscible receipt: a signed token that says which agent was allowed to do what, under which rule, for which party and basket, and whether a person approved. Anyone may implement it; the reference verifiers are MIT licensed.

Source: https://immiscible.fly.dev/docs/security/receipt-spec

A receipt is the portable proof of one decision: an agent asked to act, a rule (and sometimes a person) allowed it, and this is exactly what was allowed. This page is the format, written so that anyone can issue or check one without our code. Anyone may implement it, with no permission and no fee. The reference verifiers, in JavaScript and Python, are MIT licensed in [efr7-7/immiscible-sdks](https://github.com/efr7-7/immiscible-sdks), and both are tested against the same vectors as the server. The ledger and checkpoint formats are in [the evidence format](https://immiscible.fly.dev/docs/security/evidence-spec.md).

The key words MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119. Format names start `assay.` for historical reasons and are kept so that receipts issued earlier still verify.

## The token

A receipt is a JWS in compact serialisation (RFC 7515), signed with Ed25519 (RFC 8032, `alg` `EdDSA`).

| Header | Value |
|---|---|
| `alg` | MUST be `EdDSA` (a verifier MAY also accept `Ed25519` as a name for it). A verifier MUST refuse any other value before doing any cryptography, so `none` and HMAC confusion fail early |
| `typ` | MUST be `assay-receipt+jwt` (a verifier MAY accept an `application/` prefix and any letter case) |
| `kid` | MUST name a key in the issuer's published key set |
| `crit` | MUST NOT be present |

Each of the three parts MUST be the canonical base64url encoding of its bytes, with no padding; the signature MUST be exactly 64 bytes. A token longer than 8,192 characters MUST be refused.

## Claims

| Claim | Type | Required | Meaning |
|---|---|---|---|
| `iss` | string | yes | the issuer's base URL. A verifier MUST compare it with the issuer it chose to trust, never fetch keys from it |
| `sub` | string | yes | the agent, as a pseudonymous id only the issuer can resolve |
| `act` | string | yes | the action this receipt allows |
| `typ` | string | yes | the action type: `payment`, `data.release`, `tool.call` and the like |
| `amt`, `cur` | integer, string | payments | the authorised amount in minor units, and its ISO 4217 currency |
| `mer` | string | payments | the merchant domain it was authorised for |
| `mdt` | string or null | yes | the rule (mandate) it was allowed under; `null` when none applied, and then `mdh` is absent |
| `hum` | boolean | yes | `true` when a signed-in person approved this action, or a remembered approval a person gave for this agent and tool covered it |
| `iat`, `exp` | integer | yes | issued and expiry times, seconds since the epoch. Receipts are short lived: Immiscible issues them for five minutes |
| `jti` | string | yes | a unique id. A receipt is single use |
| `fld` | array | data releases | the fields allowed to be released |
| `cry` | object | crypto payments | what a wallet must match before it signs: asset, network, amount in the asset's units and recipient, with the rate `amt` was taken at |
| `ver` | integer | version 2 | `2`. Absent means version 1 |
| `aud` | string | version 2, payments | the party it was issued for: a merchant host, compared as a host name (lower-cased, a trailing dot and a leading `www.` ignored) |
| `crt` | string | version 2, when a basket was listed | the basket digest, [below](#cart) |
| `mdh` | string | version 2, when a rule applied | SHA-256, base64url, of the rule's canonical signed form, so the rule cannot be swapped for another with the same id |
| `prv` | object | version 2 | what shaped the request: `declared` sources, `observed` untrusted sources, and `mismatch` when they disagree |
| `tnt` | boolean | version 2 | `true` when untrusted content (a web page, an email, another agent's output) was observed in the agent's session |

A receipt MUST NOT carry personal data: people and agents appear only as pseudonymous ids. Unknown claims MUST be ignored by a verifier, so the format can grow.

## The canonical basket 

`crt` fixes the basket, so that a receipt for 4 packs of paper cannot be honoured for something else at the same price.

1. Each line has a `sku` or a `url` (or both), a whole `quantity` of 1 or more and a whole `unitPrice` of 0 or more, in minor units. Names and any other fields are left out: they are for people.
2. `sku` and `url` are trimmed of leading and trailing white space as JavaScript's `String.prototype.trim` defines it (which includes U+FEFF and excludes U+0085). An issuer MUST refuse a `sku` or `url` holding a control character (U+0000 to U+001F, U+007F).
3. The document is `{ "schema": "assay.cart.v1", "currency": <upper-case code>, "items": [ { "sku"?, "url"?, "quantity", "unitPrice" }, ... ] }`, lines in the order given.
4. It is serialised as canonical JSON: object keys sorted as JavaScript sorts strings (by UTF-16 code unit; the basket's keys are all ASCII), no white space, arrays in order, strings as `JSON.stringify` writes them (non-ASCII characters kept as they are, not escaped).
5. `crt` is the SHA-256 of the UTF-8 bytes, base64url without padding.

The lines MUST add up to `amt`; an issuer MUST refuse to sign a basket that does not.

## Verifying

A verifier, given a token, the issuer it trusts (or a key set it pinned) and optionally what it expects:

1. Check the header as above, then find `kid` in the issuer's key set, fetched from `<issuer>/.well-known/immiscible-keys.json` (also published at `/.well-known/assay-keys.json`) or pinned beforehand.
2. Verify the Ed25519 signature over `<header>.<claims>`.
3. Check `iss` equals the trusted issuer, and `iat` and `exp` against the clock, allowing a small skew (the reference verifiers allow 60 seconds).
4. Compare what it expects, when given: `amount` (the charge MUST NOT exceed `amt`; the reference SDKs require it to equal `amt`, which is stricter), `currency`, `merchant` (the same registrable domain at least; the SDKs compare the host, with a leading `www.` ignored), `type`, `agent`, `mandate`, `human_approved`, and for version 2, `audience` and `cart` (or `cartDigest`). A version 1 receipt MUST fail a cart or audience check, because it names neither.
5. For single use, remember `jti` until `exp`, or ask the issuer once (`POST <issuer>/v1/verify`), which marks it seen. Check what you can locally first: the issuer checks amount, currency, merchant, audience and basket before it marks a receipt seen, but not type, agent, rule or approval, and the reference SDKs refuse an order the claims cannot cover before they ask the issuer.

A mismatch SHOULD be reported with codes, so the caller can tell a wrong basket from a wrong price: `cart_mismatch`, `audience_mismatch`, `merchant_mismatch`, `amount_mismatch`, `currency_mismatch`, `type_mismatch`, `agent_mismatch`, `mandate_mismatch`, `human_required`. A mismatch MUST NOT use up the receipt, so the honest charge can still be made.

## Test vectors

`receipt-v2.json`, in the SDKs repository under `packages/immiscible-js/test/fixtures/` and `packages/immiscible-py/tests/fixtures/`, holds baskets with their canonical bytes and digests (including the white-space and non-ASCII cases), and a signed version 2 receipt with its key set and the expected result of each check. An implementation that reproduces every digest and every result there is compatible.

## What a receipt proves, and what it does not

It proves that the issuer, at `iat`, allowed this agent this action under this rule, for this party and basket, and, when `hum` is `true`, that a person approved it or gave a remembered approval that covered it. It does not prove the action then happened, or happened well: that is the merchant's record. It says nothing about the agent's model or its prompt. How Immiscible's claims line up with AP2's mandates is on [receipts](https://immiscible.fly.dev/docs/concepts/receipts.md#binding); a receipt travels beside such protocols and is not part of any of them.

## Changes

Version 2 (10 October 2026) added `ver`, `aud`, `crt`, `mdh`, `prv` and `tnt`. Version 1 receipts still verify. A future version will add claims, not change these.
