> For the complete documentation index, see [llms.txt](https://docs.metamynd.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metamynd.ai/core-concepts/payload-binding.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# Payload Binding

Bind an approval to the exact payload the tool will run, so the payee, amount or other details cannot change after the gate says yes.

A MAGP request signs eight fields: the agent, the action, the amount, the currency, the merchant, the resource, a nonce and a timestamp. That is enough for the gate to decide whether the action is allowed. It is **not** enough to say what the action will actually do. A wire transfer also has a payee account; a flight booking has passengers and a route; an API call has a whole request body. None of that is in the signature.

Without more, an executor has two options for every field the signature never mentioned: refuse it (and the tool can't be used), or allow it unbound (and whatever sits between the agent and the executor can change it). **Payload binding** closes that gap: the agent signs a digest of the **complete** payload, and the service that executes it is held to exactly that payload.

#### How it works

```
agent ── authorize(payload P) ─────────────────────────▶ gate
         signs H = sha256(canonical(P))                   stores H with the hold, echoes it back

agent ── request for P ─────────────────────────────────▶ executor (gateway / MCP guard / A2A skill)

executor ── claim(hold, H' = digest of what it will run) ─▶ gate
                                                           refuses the claim unless H' == stored H
```

1. **The agent signs the digest.** The digest is `sha256:` over the payload's RFC 8785 canonical JSON form, so key order and whitespace don't matter but values do. The agent signs it under its own message domain (`MAGP-PAYLOAD-v1`), naming the same agent, action, nonce and timestamp as the authorize request — so a digest can't be lifted onto another authorization.
2. **The gate verifies and stores it.** A binding that is present but invalid — a digest without a signature, a malformed digest, a signature that doesn't verify — is refused (`PAYLOAD_BINDING_INVALID`). A valid one is stored with the hold (and with the escalation, if the action is held for review).
3. **The gate echoes it back.** The verdict states the digest the authorization is bound to. An agent that sent a digest and gets back a permit that doesn't echo it — because a proxy stripped the fields, or the gate predates binding — must treat the authorization as unbound, refuse it (`PAYLOAD_BINDING_NOT_CONFIRMED`) and release the hold. The SDKs do this for you.
4. **The gate compares at the claim.** The executor claims the hold with the digest of exactly what it is about to run. The gate compares it with the digest **it stored** — not with a header the agent handed the executor, because an agent can sign whatever it likes and hand over a different signed request for the same authorization. Only the issuer knows which digest the authorization was actually granted for.

| At the claim                                   | Result                                                                                  |
| ---------------------------------------------- | --------------------------------------------------------------------------------------- |
| Digests match                                  | Claim granted; the grant reports the bound digest.                                      |
| Digests differ                                 | Refused — `PAYLOAD_DIGEST_MISMATCH`. The hold stays claimable by an honest executor.    |
| Hold is bound, executor states no digest       | Refused — `PAYLOAD_DIGEST_REQUIRED`. An executor cannot ignore the binding by omission. |
| Hold is unbound, executor states a digest      | Refused — `PAYLOAD_NOT_BOUND_AT_AUTHORIZE`.                                             |
| Hold is unbound and the owner requires binding | Refused — `PAYLOAD_BINDING_REQUIRED`, until the agent binds one.                        |

If the executor's digest differs from the agent's, that is the mechanism working: the two sides digested different values. Find what differs; don't loosen the check.

#### What gets bound

The executor decides what it digests — the value it will actually act on, exactly as it receives it as JSON:

| Executor                 | Digests by default                                                                                                                                                                                    |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `agentsafe-http-gateway` | the JSON request body (a route can choose more, e.g. body plus path parameters)                                                                                                                       |
| `agentsafe-mcp-guard`    | the tool arguments, when `bindPayload: true`                                                                                                                                                          |
| `agentsafe-a2a-guard`    | the message `parts`, when `bindPayload: true`; with `bindScope: 'message'` (0.7.0+) also the message metadata, `referenceTaskIds` and extensions — this becomes the default at the next major version |

Bind every field that moves value or identifies who receives it — payee, account, address, reference, currency, items — and not fields that legitimately change between signing and execution, such as a timestamp or trace id the service sets itself.

Because a digest only means something if every reader agrees on the bytes, the protocol refuses anything ambiguous rather than guessing: values JSON can't carry (`NaN`, `Infinity`, functions, unpaired surrogates) are refused before anything is sent; payloads nested deeper than 32 levels or larger than 256 KiB are refused; and an executor refuses a body with a repeated object key, a number a double can't carry exactly, invalid UTF-8 or a byte-order mark. Send large identifiers and amounts as strings.

#### Who requires it

Binding is opt-in per request, and two independent parties can make it mandatory:

* **The executor.** `requirePayloadBinding: true` on an MCP guard tool, an A2A skill, or an HTTP gateway route (or the whole gateway) makes the executor refuse an authorization the agent didn't bind. The gateway scaffolded by `create-metamynd-agent` turns this on for its financial gateway.
* **The owner, per mandate.** A mandate permission can carry `requirePayloadBinding: true`. The **gate** then refuses any request for that action that carries no signed digest, and refuses to let an unbound hold be claimed — whatever the agent, the executor, or a hop in between does. It is part of the signed mandate, and a delegated mandate cannot drop it. A new agent can get it from the switch in the Launchpad. For an existing agent, the owner switches it on or off from the agent's **Payload binding** panel in the dashboard; that reissues the agent's mandates (carrying their spend) and is refused while the agent has an outstanding hold.

The two checks protect against different failures — an agent that skips binding, and an executor that skips requiring it — and don't depend on each other. The requirement is revealed only to a caller that proved the agent's key: a forged request gets `SIGNATURE_INVALID`, never `PAYLOAD_BINDING_REQUIRED`.

#### Late binding after a reviewer's MODIFY

When a human reviewer **modifies** an escalated action (a lower amount, a different merchant), the action the agent originally signed is no longer the one that will run — so the hold minted for the modified action carries **no** digest.

* The escalation status the agent polls reports `payloadBound: false` alongside the `authorizationId` (a boolean — the digest itself is never in the public status).
* The agent then binds the payload of the action that will actually run: `guard.bindPayload(...)` in Node, `client.bind_payload(...)` in Python (`POST /policy/mandate/authorize/{authorizationId}/payload-binding`). This message names the authorization id under its own domain (`MAGP-PAYLOAD-REBIND-v1`), so it can't be lifted onto another hold or replayed as an authorize-time binding.
* Binding is accepted only while the hold is live, unclaimed and unbound, and a digest is **never overwritten**; the same digest again is an idempotent success. A contained agent (suspended, quarantined, decommissioned) cannot bind.
* An executor that requires binding won't claim the hold until it is bound; with the owner requirement, it *can't*.

#### Binding in the evidence

A verified payload digest becomes part of the permanent record:

* It is folded into the anchored decision commitment, so the Merkle-anchored evidence proves which payload the decision was bound to. A digest that was merely claimed and never verified is never included.
* A granted claim records `payload:<digest>` on the hash-chained effect ledger — the tamper-evident record of which payload the executor was held to.
* The reviewer's screen shows the digest the agent signed for the request being approved, or "not bound".

#### Where to go next

* [Require Payload Binding](https://docs.metamynd.ai/guides/require-payload-binding) — turning it on for an agent, an executor, or both.
* [Request Signing & Message Format](https://docs.metamynd.ai/agent-protocol/request-signing-and-message-format) — the exact messages, and the published test vectors every implementation should reproduce.
* The protocol text: [MAGP §8.3.9–8.3.11 and §8.7.11](https://metamynd.ai/developers/spec).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.metamynd.ai/core-concepts/payload-binding.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
