# Agent Exchange Protocol v1.0 (Draft r11) · Profile exchange.v1: deals

<!-- part of the AEP specification; see aep-core.md, "Documents" -->

Part of the specification that begins in `aep-core.md`, whose front matter says which document holds which section. Section numbers are those of the whole specification.

## 12. Delivery and idempotency (Core; §12.3 is `exchange.v1`) (continued; the rest of this section is in `aep-core.md`)

### 12.3 Write-ahead (executor MUST; Profile `exchange.v1`)

1. On receiving a command, durably store (`issuer/id`, the `v` and the content digest it accepted, action, `status: pending`) before calling the Provider. The key is `issuer/id` without `@v` (§14.1): a command runs once, whatever its versions.
2. If `issuer/id` is already stored, return the stored result; never call the Provider again for it. The stored `v` with other content is a `conflict` (§12.4) and a higher `v` is ignored (§14.1); neither is executed, and a changed intent is a new command with a new `id`.
3. If the Provider accepts an idempotency key, pass `issuer/id` and the side effect happens at most once. If it does not, a crash between the Provider's success and step 4 leaves the outcome unknown: the executor MUST then report `status: unknown` and reconcile with the Provider before any retry.
4. Store the result and send `attestation{kind: executed, claims: { status: succeeded | failed | pending | unknown, provider_ref, result_digest }}`, or `rejected` with an Error.

The protocol guarantees at-least-once delivery and exact deduplication of Envelopes and Records. Exactly-once side effects exist only where the Provider supports an idempotency key; everywhere else the honest outcome of a failure is `unknown`, and the executor says so.

## 14. exchange.v1 Profile (optional)

An optional Profile for deals on top of Core. Core is complete without it; it is included here so that the examples in Appendix A can be read in one place. Retail commerce is better carried as UCP and AP2 inside `payload`; this Profile exists for deals that have no protocol yet: reservations, used goods, gigs, hiring, procurement, peer-to-peer coordination. Its bodies have fixed fields so that two independent Agents understand each other without a prior agreement; domain detail goes in `ext`.

### 14.0 Card fields this Profile adds

An Actor that speaks `exchange.v1` lists its capabilities by name in the Core `capabilities[]` (§7) and, under `agent_card.ext["exchange.v1"]`, the invocation details per name: `capabilities[]` {name, version, actions\[\], input\_schema\_digest, output\_schema\_digest, required\_scope, side\_effect\_level}, the schemas behind those digests being published in the registry (§21) or as signed artifacts and never fetched from a URL at runtime, and, for a Surface, `represented_principal` and `claim` (§14.3). `side_effect_level` is none, read, reversible, irreversible or financial and drives the approval rules of §14.2; `required_scope` names the delegation scope a command needs (§13). The Profile registers the filter key `region` (ISO 3166-2) for `listing` and `signal` queries (§9.3) and the error codes `approval_required`, `resource_stale` and `execution_failed` (§14.1).

### 14.1 Types and states

| type | issuer → subject | body | Rule |
| --- | --- | --- | --- |
| `listing` | Surface or Agent | `kind` (product · used\_product · service · slot), `title`, `description`, `price` {amount, currency}, `availability`, `location`, `freshness` {observed\_at, valid\_until, availability\_confidence}, `source` (provider\_api · partner\_feed · scraped · user\_submitted), `claim` (self · claimed · verified), `provenance` {surface, method, fetched\_at}, `schema` (a schema.org type, optional) | A snapshot. Unusable after `valid_until` without re-verification. A listing with `source: scraped` serves discovery and `quote` only; `hold`, `confirm` and `buy` need a listing or quote the Provider signed itself (`provider_api`, `partner_feed`) or a `self` listing whose issuer is the principal |
| `signal` | Agent → listing (optional) | `intent` (seeking · offering · available · request · update · withdraw · cancel), `objective`, `constraints`, `budget`, `time`, `audience` | Presence is a short-lived `available`. A signal published to an Index omits `budget` and personal `constraints` by default, since those weaken the issuer's own position; an issuer that wants them seen, as an employer does with a salary band, publishes them deliberately |
| `proposal` | Agent → listing or signal | `terms` {price, scope, delivery, sla, cancellation, required\_scope, required\_evidence} | Proposals form a DAG through `parent`; several MAY be alive at once in one exchange, concurrent branches are normal, and none is authoritative until an `agreement` pins one as its `subject`. A proposal is live while unexpired and not superseded by its own issuer |
| `agreement` | first signer → proposal | `listing_ref`, `terms` (the final terms in full), `terms_digest` = SHA-256(JCS(`terms`)), `parties[]` {agent, principal, role: buyer · seller · payer · payee · executor · verifier}, `validity`, `acceptance_window`, `payment` {rail, actor, payer, payee, payer\_account?, payee\_account?, amount, currency, due\_at, release: on\_accept · on\_resolved}, `cancellation` | Concluded when every entry of `parties[]` appears in `sigs[].actor`; a new version needs every party's signature again. A concluded agreement, like an `executed` attestation, cannot be revoked by one party: a `revocation` naming it is recorded as a `challenged` claim and the Record remains evidence that it was issued. A key revocation is treated the same way: when a `revocation` voids a party's signature on an agreement the verifier already holds as concluded, the agreement stays concluded for that verifier and the revocation counts as a `challenged` claim with `grounds: unauthorized`, so settlement freezes until a `resolved` names the outcome and no further command runs under the revoked key (§11.5); a signature that was already void when the agreement reached the verifier never concluded it, and the counterparty's evidence that the signature existed before the revocation is the Gateway-signed `delivered` for the Envelope that carried it (§11.6). Every party's Agent is either self-owned (principal equals the Agent) or has put the standing delegation from its `principal` in the counterparties' hands: the first signer carries it in the agreement's `attached[]`; a countersigner, who cannot change the signed content, sends it as a Record of its own in the same exchange (`parent` = the agreement) or in the `attached[]` of its next Record; an approval travels the same way as the delegation it narrows, and a party's signature counts as representation only once the counterparties hold that chain. When the agreement carries a term with `side_effect_level` reversible or higher, that delegation MUST also be a one-shot approval whose scope is `agree:<this agreement's reference@v>`, or a standing delegation whose constraints bound `max_amount` and `target` to it; `agree:*` alone never suffices. When the agreement carries a `payment`, only the approval will do (§14.2): a standing delegation lets the Agent sign and is never the approval of a payment. The two approval scopes divide cleanly: `agree:<agreement@v>` with `max_amount` and `target` is consent to the signed terms and, at the same time, the approval of the one payment that agreement's `payment` term describes, which is why the examples carry a single approval; any further financial or irreversible command under the same agreement (a second release, a refund, a re-run) needs its own `command:<command@v>` approval, and the §14.2 table's "per-command approval" means exactly that. `terms_digest` covers `terms` alone; what an approval binds to is the agreement's `record_digest` (§14.2), which covers the whole Record, `payment` and `parties[]` included |
| `command` | Agent → listing or agreement | `action` (quote · hold · confirm · buy · execute · cancel · release · deliver · accept), `agreement_ref`, `expected_state` (the exchange state the command assumes), `params`, with the standing delegation and the approval carried in full in `attached[]` | Immutable once execution begins: the executor ignores a higher `v` of a command it has started, and a change travels as a new command (cancel, then a new one with `supersedes`). (`issuer`, `id`) is the idempotency key. `quote` and `hold` MAY precede an agreement; `confirm`, `buy`, `execute` and any payment MUST reference an agreement signed by every party. An executor compares `expected_state` (one of the derived states of §14.1) with its own projection and rejects a mismatch with `conflict`; it evaluates `expected_state`, consumes the approval and records the command's acceptance in one atomic step, because two of these running interleaved is how a command is executed twice; no shared version counter is needed, since the projection is the executor's own. This settles the race between `cancel` and `execute`: whichever the executor applies first wins, and a `cancel` arriving after execution began is answered with the `executed` status and, where `payment` allows, a `refunded` later |

Added attestation `kind`s: `executed` (claims `status` succeeded · failed · pending · unknown, `provider_ref`, `result_digest`), `accepted`, `authorized` (funds reserved on the rail and not yet moved: a card authorization, a hold, a wallet allowance), `settled` (funds moved out of the payer's control into the custody of the payment Actor or its contract: captured, or escrow funded; not yet the payee's), `released`, `refunded`, `resolved`, `challenged`.

Each names in `claims` what it is about: `command_ref` when it answers a command, `agreement_ref` when an agreement exists, and at least one of the two; the `executed` that answers a `quote` or a `hold` sent before any agreement carries `command_ref` alone. So an attestation can never be read against the wrong deal, and `delivered` plays no part in exchange state.

Trust in them is by role, checked by the receiving Agent: `executed` only from the Actor that executes (the one a command was sent to, or under an agreement the party that owes the performance); `authorized`, `settled`, `released` and `refunded` only from the payment Actor named in `agreement.payment` or in the Agent's own policy; `accepted` only from the counterparty; `challenged` only from a party; `resolved` only from the escrow or a Verifier both parties named.

Exchange state is computed, by each party for itself, from the Records whose parent chains reach the anchor named in `exchange`: open → negotiating → agreed → authorized → in\_progress → performed → accepted → closed, with cancelled as the other final state. The state is never stored and never sent, and it is normative all the same: an executor compares a command's `expected_state` with the state these rules give it, so two implementations MUST derive the same state from the same Records. A parent chain that reaches the anchor says that a Record belongs to the exchange and says nothing about authority: a Record counts toward the state only when the Actor named in the table below issued it, and one from anyone else is kept as what that Actor said and changes nothing.

| Record | Counts when issued by | State it establishes |
| --- | --- | --- |
| the anchor of the exchange, whatever its type (§6): a valid `signal` or `listing`, or the `proposal` or command with which a party opens one | its issuer | open |
| a live `proposal` | an Agent taking part in the exchange | negotiating |
| an `agreement` with every `parties[]` entry in `sigs[]` | the parties, by signing | agreed |
| `authorized` | the payment Actor of `agreement.payment` | authorized |
| `executed` with status pending or unknown, naming the concluded agreement and not answering a `quote`, `hold` or `cancel` | the executor: the party that owes the performance (`role` executor, seller or payee) | in\_progress, for as long as the executor has said neither succeeded nor failed of that command; an unknown stays so until the executor has reconciled (§12.3) |
| the same with status succeeded | the executor | performed |
| the same with status failed | the executor | none: that command no longer keeps the exchange at in\_progress, and the deal stands where its other Records put it |
| `executed` that answers a `quote` or a `hold`, or a `cancel` sent before any agreement was concluded (a hold given back), whatever its status | the Actor the command was sent to | none: the result of a command, not a step of the deal. A hold is a claim of that attestation (`hold_exp`), and one that lapses changes nothing |
| `executed` with status succeeded that answers a `cancel` command naming the concluded agreement | the executor | cancelled |
| `executed` with any other status that answers such a `cancel` | the executor | none: a cancel that failed, or whose outcome is unknown, cancelled nothing, and one that arrived after execution began is answered with the status of the command it was meant to stop |
| a `signal` with intent withdraw or cancel | the issuer of the signal or proposals it withdraws | while no concluded agreement is held: that issuer's own signals and proposals end, and the exchange is cancelled when the anchor was theirs. Once one is held: none, since a concluded agreement is ended by a `cancel` command under its `cancellation` term and not by one party's signal, whichever of the two was written first |
| `accepted` | the party the performance is owed to (`role` buyer or payer) | accepted |
| `released`, `refunded` | the payment Actor | closed, unless a `challenged` stands against it (next row) |
| `challenged` | a party | none, and settlement is frozen: a `released` or `refunded` whose `iat` is not earlier than the `challenged` closes nothing until a `resolved` names the outcome |
| `resolved` | the escrow, or the Verifier both parties named | none of its own: it answers the `challenged`, and the `released` or `refunded` then closes the exchange |
| the agreement's `validity`, or before an agreement the anchor's `exp`, passes | nobody | closed |

The state is a function of the Records a party holds and of its clock and, with the one exception at the end of this paragraph, not of the order in which the Records arrived, since no order of arrival is promised (§12): it is the furthest state on the ladder that a held Record establishes, under three rules. The executor's last word on a command replaces its earlier ones (succeeded or failed over pending or unknown), so in\_progress holds only while some command has a pending or unknown `executed` and no succeeded or failed one. Cancelled outranks every other state, and closed outranks all but cancelled. And a Record that arrives late is counted like any other: the state is derived again from all of them. The exception is the one the `agreement` row makes: whether the party held the agreement as concluded before a `revocation` that voids one of its signatures reached it. A party notes the moment it first holds every party's valid signature; a revocation that reaches it later is a `challenged` claim, and one it already held means the agreement never concluded for it. Either way nothing further runs under the revoked key.

performed is the executor's own word that the command which carries out the agreement succeeded, in a booking the `confirm`; that the counterparty received what was agreed is said by `accepted`. `settled` marks the moment funds were captured or escrowed; it may fall anywhere after agreed and establishes no state. Several proposals may be alive at once, and the agreement's `subject` picks one; an agreement with payment pending stays agreed until `authorized`; `refunded` after accepted closes the exchange like any `refunded`. The dispute procedure itself is left to a Profile.

An attestation is a signed statement by its issuer and proves that the issuer said so, not that the world is so; the truth of availability, execution or handover rests with the authority of §3 and with outside evidence such as a carrier record, a pickup confirmation or an artifact digest.

A `challenged` carries { `against` (a pinned reference), `grounds` (not\_as\_described · not\_delivered · not\_performed · unauthorized · other), `evidence[]`, `requested_remedy` (refund · redo · release), `resolver`, `deadline` }; it may be raised until the agreement's `acceptance_window` closes, after which the payment Actor applies the agreement's release rule, and a challenge after release is a dispute the resolver handles outside this Profile.

The Profile registers three error codes beside the Core set (§8): `approval_required` (HTTP 403, not retryable: the approval a `side_effect_level` requires is absent, §14.2), `resource_stale` (409, not retryable: `valid_until` passed or `listing.v` mismatch, §14.3) and `execution_failed` (502, retryable as the Provider says: Provider execution failed, with `provider_code`).

### 14.2 Approval

An approval is a one-shot delegation bound to one Record, by its reference and by its content, so that what the person approved is exactly what the executor runs: `scope` contains `command:<reference@v>` or `agree:<reference@v>`, `constraints.record_digest` is that Record's digest (§13: SHA-256 of the JCS of the Record without `sigs` and `attached`), `human: true`, `exp` ≤ 24 h, signed by the Owner device key (§18.2). The reference alone would not do: an Agent whose key is in the wrong hands can sign a second Record under the same `issuer/id@v` with another date, another party or other parameters, and an executor that never saw the first cannot tell them apart. The digest covers every field of the Record except its signatures and `attached[]`, where the approval itself travels, so `subject`, `exp`, `params`, `payment` and `parties[]` are all inside it. The command carries it in full in `attached[]`, together with the standing delegation (which it narrows through `parent`, or stands beside as a second Owner-issued root), so the executor needs no fetch.

| `side_effect_level` | Example | Required before execution |
| --- | --- | --- |
| none, read | search, quote | delegation scope |
| reversible | hold | delegation scope + audience |
| irreversible | confirm, submit application | approval (or a standing delegation with constraints) + key re-check + two-path Card check (§18.2) |
| financial | buy, release | per-command approval + `max_amount` check + key re-check + two-path Card check (§18.2) + payment authorization from the rail; `settled` is the result and is issued afterwards |

The executing Surface MUST verify the signature of the Owner key or an Owner-delegated device key, `scope` match, `constraints`, that `record_digest` equals the digest it computes over the Record it was handed (the command for `command:`, the agreement for `agree:`), and that the approval is unexpired and unrevoked; failure is `approval_required`, and so is a grant of one exact reference that carries no `record_digest`. Where the table asks for an approval, a standing delegation that happens to grant the same action is not one, and neither is a digest that somebody other than the Owner put into a chain: the chain the executor applies is the one whose digest-carrying delegation is the approval, issued by the Owner. The `side_effect_level` a Surface declares in its Card is the Surface's own claim about its command, so on the Agent's side it is a floor, never a ceiling: the Agent (and the product that collects approvals) classifies a command by what it will do (money moves, something is booked, data leaves) from the command's own fields and the agreement, treats a missing or unknown level as `irreversible`, and raises the level above the declared one whenever its own reading says so; a malicious Surface that labels a payment `none` gains nothing but a refused command, while an honest Surface's `financial` is what makes the Agent ask before it sends. The product that collects the approval MUST render what the person is approving (amount, counterparty, target, deadline) from the structured fields of the pinned Record, its `terms`, `price` and `subject`, never from a counterparty-written `summary`, and computes `record_digest` over the Record it rendered; a `summary` MAY appear as a caption and nothing more, because it is untrusted text aimed at a person (§6, §18). An attestation about a command or an agreement names in `evidence[]` the approvals it relied on. `constraints.max_amount` caps one command: the executor compares it with the amount that command commits, never with a running total. A spending budget across commands or across Surfaces is the product's own bookkeeping: nothing in a delegation caps a total. A payment Adapter MAY place a `mandate` Extension in the approval body.

### 14.3 Freshness, claims and booking

| Field | Value | Rule |
| --- | --- | --- |
| `observed_at`, `valid_until` | RFC 3339 | `valid_until` bounds what is newly promised from the listing: no `proposal`, `quote` or `hold` after it, and no `agreement` concluded on it (MUST). Once an agreement is concluded, its own `validity` governs, and a command under it (`confirm`, `execute`, `cancel`, `release`, `accept`) is not refused because the listing has lapsed since |
| `source` | provider\_api, partner\_feed, scraped, user\_submitted | Propagate to derived Records (MUST). scraped can never be confirmed |
| `availability_confidence` | confirmed, likely, unknown | An estimate until the Provider re-checks |
| `claim` | self, claimed, verified | `self` means the listing's issuer acts for its own Owner (a person selling their own goods or time), shown by the published Owner-to-Agent delegation or, at L0, by the Agent being self-owned, with no third-party Provider behind it; `claimed` means a valid `delegation{issuer: owner:<provider>, subject: <surface>, scope: ["represent:<owner id>"]}` exists and that Owner's Card carries the Provider's handle (§4.2); `verified` adds an `attestation{kind: verified}` from a Verifier the reader trusts. The client checks the delegation and the attestation itself; a claim label in an Index is only a hint. Show it in the approval UI (MUST) |
| `provenance` | {surface, method, fetched\_at} | Immutable even after a claim |

Booking uses `listing.kind ∈ {slot, service}` and the order `quote → hold → agreement → approval → confirm → execute → release | cancel`. `quote` is read; `hold` is reversible (auto-release after `hold_exp` in the hold's claims, returns price) and MAY precede the agreement; `confirm` and `execute` are irreversible or financial and MUST reference the signed agreement. Because `hold` returns the price, `quote` is optional; with the agreement and approval in hand, `hold` then `confirm` completes in two round trips. If `listing.v` differs from current, respond `resource_stale` with the current `v`; the buyer re-queries and issues a new command. The Provider is the authority on availability, confirmation and settlement.

### 14.4 Surface tiers (informative)

| Tier | Provides |
| --- | --- |
| Catalog | A Card and signed listings, possibly as a static feed (L0) |
| Inquiry | Answers to proposals and quotes |
| Transaction | hold, confirm, buy, cancel and execute with write-ahead (§12.3) |
| Settlement | Payment, escrow and refund attestations through a payment adapter |

A website starts as a Catalog Surface with a static feed and climbs one tier at a time; a used-goods seller is a Catalog and Inquiry Surface run by a personal agent.

### 14.5 Payment rails (adapter sketch, informative)

The protocol never moves money. `agreement.payment` names the rail, the payment Actor, payer, payee, amount and release rule; the rail moves the money under the person's approval; the payment Actor signs what happened. Two rails cover most agent commerce today.

|  | Stripe | Crypto: x402, a direct token transfer, or an escrow contract |
| --- | --- | --- |
| `payment.rail` | `stripe` | `x402`, or the CAIP-19 id of the asset |
| `payment.actor` | A Stripe adapter Actor run by the merchant or by a marketplace on Stripe Connect; it signs on Stripe webhook events | The escrow contract's operator Actor, or for a direct transfer the payee's own Agent, after the agreed number of confirmations |
| `payer`, `payee` | Owner IDs; the Stripe customer and account stay inside the adapter | Owner IDs plus chain accounts in `payer_account` and `payee_account` (`eip155:<chain>:<address>`) |
| `payment_ref` (a claim of `authorized`/`settled`, never a term of the agreement, which is signed before any payment exists) | The PaymentIntent id | The transaction hash, or the escrow id |
| Hold and release | Manual capture: authorize at `confirm` → `authorized`; capture on `accepted` → `settled`, then `released` to the payee; refund → `refunded`. A card authorization lapses, for an online payment after about a week, so a deal whose `accepted` comes later than that is captured at `confirm` (`settled`) and paid out on `accepted` (`released`), or refunded | A wallet allowance or a signed, unfunded deposit intent, where the rail has one → `authorized`; deposit to escrow at `confirm` → `settled`; `accepted` → the contract releases → `released`; `challenged` freezes; `resolved` releases or refunds |
| Evidence | Only as strong as the adapter; `claims` carry the PaymentIntent, charge and refund ids and the webhook event id as `provider_ref`, which a Verifier can check with the merchant's cooperation | A transaction hash anyone can verify on chain; `claims` carry chain, block, token and amount |
| The person's approval | The Owner's one-shot approval (`agree:<reference@v>` with `max_amount` and the agreement's `record_digest`) is what the buyer's Agent presents in AEP; the payment method is authorized on the rail by the person's device through the product's Stripe integration, and no card data ever enters a Record | The same approval, plus the wallet signature on the person's device or an agent wallet whose spend limit mirrors `constraints.max_amount`; private keys never enter a Record |

UCP and AP2 sit one layer above a rail. UCP is a checkout protocol: product discovery, cart, taxes, shipping and order, with payment handed to its own PSP through an AP2 mandate, so it chooses a rail rather than being one. When a deal runs on UCP, the whole checkout rides in `payload` in place of the `exchange.v1` flow, the AP2 mandate stands in for the one-shot approval, the payment Actor is the PSP adapter UCP uses, and that adapter closes the exchange with the same `settled`, `released` and `refunded` attestations, whether the money moved over Stripe, a card network or a stablecoin. Retail checkout with carts, taxes and shipping is better carried that way than modeled in `exchange.v1`.

