# Bind the exact action

Bind an agent's exact payload, its stated reason and its identity to a person's approval, verify all three before the action runs, and stop the agent's session.

Use execution binding to make sure an agent runs exactly the action a person approved. You authorize the exact payload, the agent's stated reason and the agent's identity, then verify all three right before the action runs. Anything that changed in between fails the check.

**Before you begin:** export the sandbox account key. Agents and receipts belong to an account, so this guide uses the account key, not the full-access key. Each run gets its own agent session ID.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
export AGENT_SESSION_ID=sess_$(date +%s)
```

## 1. Register the agent

Registering an agent gives it an ID that appears on its tokens, its decisions and its deny alerts. It's optional: without one, the agent session ID is the only label. Create it with [`POST /v1/mandate/agents`](https://provenanceauth.com/docs/api/agents.md#post-v1-mandate-agents):

**curl**

```bash
curl -s $PROVENANCE_API/v1/mandate/agents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "invoice-bot" }' | tee agent.json
export AGENT_ID=$(jq -r .id agent.json)
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const agent = await prov.mandate.agents.create({ name: "invoice-bot" });
const agentSessionId = `sess_${Date.now()}`;
```

**Python**

```python
import os, time
import httpx
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
api, headers = os.environ["PROVENANCE_API"], {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
agent = httpx.post(f"{api}/v1/mandate/agents", json={"name": "invoice-bot"}, headers=headers).json()
agent_session_id = f"sess_{int(time.time())}"
```

```json
{
  "id": "agt_01M5Q21JM14QHAWX0ND24THM3M",
  "object": "agent",
  "name": "invoice-bot",
  "description": null,
  "status": "active",
  "created_at": "2026-10-24T13:36:45.185Z",
  "last_seen_at": null
}
```

## 2. Authorize the payload and the reason

Send the request to [`POST /v1/mandate/intents`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-intents) with three things bound into the token:

| Field | Bound as | What it proves |
| --- | --- | --- |
| `action_payload` | `payload_hash` | The exact machine payload the agent will run, such as a payment or an API request body |
| `context_evidence` | `context_hash` | The agent's stated reason, shown to the person who approves |
| `agent_id` | `agent` (`id`, `name`, `integration`, `sdk_version`) | Which registered agent asked, and the integration its client declared |

**curl**

```bash
curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "action_payload": { "type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies" },
    "context_evidence": { "invoice": "INV-2041", "reason": "net-30 terms, due today" },
    "agent_id": "'"$AGENT_ID"'",
    "agent_session_id": "'"$AGENT_SESSION_ID"'",
    "device_id": "dev_00000000000000000000000000000001"
  }' | tee authorization.json
export INTENT_TOKEN=$(jq -r .intent_token authorization.json)
```

**Node**

```ts
const action = {
  actionDescription: "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
  actionPayload: { type: "payment", amount: 1850, currency: "USD", payee: "acct_brindlecote_supplies" },
  contextEvidence: { invoice: "INV-2041", reason: "net-30 terms, due today" },
};
const auth = await prov.mandate.intents.create({
  ...action,
  agentId: agent.id,
  agentSessionId,
  deviceId: "dev_00000000000000000000000000000001",
});
```

**Python**

```python
description = "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies"
payload = {"type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies"}
reason = {"invoice": "INV-2041", "reason": "net-30 terms, due today"}
auth = prov.mandate.intents.create(
    action_description=description,
    action_payload=payload,
    context_evidence=reason,
    agent_id=agent["id"],
    agent_session_id=agent_session_id,
    device_id="dev_00000000000000000000000000000001",
)
```

```json
{
  "object": "intent_authorization",
  "intent_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ijc1MjY5NmZmMGY1ZTRmNTMifQ.eyJpc3MiOiJwcm92ZW5hbmNlLWF1dGhvcml6ZSJ9.dUvSg20-l4xn1dRTrhQTU8F0W9tRDWpE1INz793rICt-daFn5wVgd0SndvqNIquHFUih1aFMJ24rCoZCMq3AOA",
  "expires_at": "2026-10-24T17:36:45.000Z",
  "attestation_id": "7f79a885-5fc7-4946-a27e-6d5c5dc412d0",
  "biometric_bound": false
}
```

The reason is the agent's own claim. Provenance binds it and shows it to the person who approves, labelled as the agent's words; it doesn't check that the reason is true.

## 3. Verify right before you execute

Your executor sends the token with the payload and reason it is about to act on to [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments). Run the action only when `valid` is `true`.

**curl**

```bash
curl $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$INTENT_TOKEN"'",
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "action_payload": { "type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies" },
    "context_evidence": { "invoice": "INV-2041", "reason": "net-30 terms, due today" }
  }'
```

**Node**

```ts
const check = await prov.mandate.assessments.create({ intentToken: auth.intentToken, ...action });
if (check.valid) {
  // run the payment
}
```

**Python**

```python
check = prov.mandate.assessments.create(
    intent_token=auth["intent_token"],
    action_description=description,
    action_payload=payload,
    context_evidence=reason,
)
```

```json
{
  "object": "mandate_assessment",
  "approval_context": null,
  "valid": true,
  "hardware_attested": false,
  "scope_match": true,
  "payload_bound": true,
  "intent_token_age_seconds": 0,
  "policy": null,
  "signature": { "method": "none", "valid": null, "key_id": null, "directory": null, "agent_id": null, "covers": [] },
  "authority": {
    "kind": "provenance_intent_token",
    "verified": true,
    "verified_against": "provenance_jwks",
    "alg": "ES256",
    "key_id": "kH3pQe",
    "issuer": "https://api.provenanceauth.com",
    "mandate_id": null,
    "approval_context_id": null,
    "cart_match": "not_applicable"
  }
}
```

Verify from the code that executes the action, not from the agent. If the agent could skip the check, the binding proves nothing.

A token authorizes one action. The first verify that returns `valid: true` spends it, so a second verify of the same token, or two at once, returns `valid: false` with `token_already_used` for all but one. A verify that returns `valid: false` (a step-up still waiting, a changed payload) spends nothing, so you can verify again once the person approves. To act again, authorize again for a fresh token. A token minted under a [grant](https://provenanceauth.com/docs/mandate/concepts/grants.md) is counted by the grant's own limits instead.

When the agent signs its requests to your tool, pass the request as you received it in `request`: its method, URL and headers, and its body when the signature covers the body's digest. The signature is checked before the token and comes back as `signature` (see [how the agent signed](https://provenanceauth.com/docs/concepts/assessments.md#how-the-agent-signed)). A signature that doesn't verify makes the result `valid: false`.

`authority` names the token that covered the action and, under a grant, the grant and its chain.

## 4. See a changed reason fail

Each bound value is checked on its own. Here the agent's reason changed after the approval, so verification fails even though the payload is the same:

**curl**

```bash
curl $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$INTENT_TOKEN"'",
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "action_payload": { "type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies" },
    "context_evidence": { "invoice": "INV-2041", "reason": "urgent, the CEO asked" }
  }'
```

**Node**

```ts
const changed = await prov.mandate.assessments.create({
  intentToken: auth.intentToken,
  ...action,
  contextEvidence: { invoice: "INV-2041", reason: "urgent, the CEO asked" },
});
```

**Python**

```python
changed = prov.mandate.assessments.create(
    intent_token=auth["intent_token"],
    action_description=description,
    action_payload=payload,
    context_evidence={"invoice": "INV-2041", "reason": "urgent, the CEO asked"},
)
```

```json
{
  "object": "mandate_assessment",
  "valid": false,
  "reason": "context_hash_mismatch"
}
```

Each binding has its own reason code:

| What changed | `reason` |
| --- | --- |
| The description | [`action_hash_mismatch`](https://provenanceauth.com/docs/platform/reason-codes.md#action_hash_mismatch) |
| The payload | [`payload_hash_mismatch`](https://provenanceauth.com/docs/platform/reason-codes.md#payload_hash_mismatch) |
| The stated reason | [`context_hash_mismatch`](https://provenanceauth.com/docs/platform/reason-codes.md#context_hash_mismatch) |

## 5. Pass your own facts in `context`

Facts that only your executor knows, such as the amount or the action type, go in `context` at verify. Your account's [policy](https://provenanceauth.com/docs/concepts/policies.md) reads them. The default policy requires hardware-backed devices above 500, so this payment is refused on the sandbox's simulated device. The token from step 3 is spent, so authorize again first:

**curl**

```bash
curl -s $PROVENANCE_API/v1/mandate/intents -o authorization.json \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "action_payload": { "type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies" },
    "context_evidence": { "invoice": "INV-2041", "reason": "net-30 terms, due today" },
    "agent_id": "'"$AGENT_ID"'",
    "agent_session_id": "'"$AGENT_SESSION_ID"'",
    "device_id": "dev_00000000000000000000000000000001"
  }'
export INTENT_TOKEN=$(jq -r .intent_token authorization.json)
curl $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$INTENT_TOKEN"'",
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "action_payload": { "type": "payment", "amount": 1850, "currency": "USD", "payee": "acct_brindlecote_supplies" },
    "context_evidence": { "invoice": "INV-2041", "reason": "net-30 terms, due today" },
    "context": { "transaction_amount": 1850, "action_type": "payment" }
  }'
```

**Node**

```ts
const again = await prov.mandate.intents.create({
  ...action,
  agentId: agent.id,
  agentSessionId,
  deviceId: "dev_00000000000000000000000000000001",
});
const withFacts = await prov.mandate.assessments.create({
  intentToken: again.intentToken,
  ...action,
  context: { transactionAmount: 1850, actionType: "payment" },
});
```

**Python**

```python
again = prov.mandate.intents.create(
    action_description=description,
    action_payload=payload,
    context_evidence=reason,
    agent_id=agent["id"],
    agent_session_id=agent_session_id,
    device_id="dev_00000000000000000000000000000001",
)
with_facts = prov.mandate.assessments.create(
    intent_token=again["intent_token"],
    action_description=description,
    action_payload=payload,
    context_evidence=reason,
    context={"transaction_amount": 1850, "action_type": "payment"},
)
```

```json
{
  "object": "mandate_assessment",
  "valid": false,
  "reason": "hardware_required_above_500"
}
```

`context` is not bound into the token: it's your executor's input to policy, read at verify time.

## 6. Stop the agent's session

To stop an agent, revoke its session with [`POST /v1/mandate/revocations`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-revocations). Every token the session minted fails its next verify with `token_revoked`. You can instead revoke one token (`intent_token`) or everything from a device (`device_id`).

**curl**

```bash
curl $PROVENANCE_API/v1/mandate/revocations \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "agent_session_id": "'"$AGENT_SESSION_ID"'", "reason": "agent stopped by operator" }'
```

**Node**

```ts
await prov.mandate.revocations.create({ agentSessionId, reason: "agent stopped by operator" });
```

**Python**

```python
prov.mandate.revocations.create(agent_session_id=agent_session_id, reason="agent stopped by operator")
```

```json
{
  "object": "revocation",
  "scope": "session",
  "revoked": true,
  "reason": "agent stopped by operator"
}
```

A verifier that checks tokens [offline](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md) can't see a revocation; it calls [`GET /v1/mandate/intents/{id}`](https://provenanceauth.com/docs/api/intent-tokens.md#get-v1-mandate-intents-id) before a high-value action. To stop a registered agent across all its sessions, suspend it with [`POST /v1/mandate/agents/{id}/suspend`](https://provenanceauth.com/docs/api/agents.md#post-v1-mandate-agents-id-suspend); its tokens then fail with `agent_suspended`.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `valid: false`, `payload_hash_mismatch` | The executor's payload differs from the authorized one, even by key order or a number's type | Send the payload exactly as authorized; keys are canonicalized, values are not. |
| `valid: false`, `token_expired` | Tokens last four hours | Authorize again. |
| `valid: false`, `token_revoked` | The token, its session or its device was revoked | Authorize again in a new session. |
| `valid: false`, `token_already_used` | An earlier verify of this token was valid; a token authorizes one action | Verify once, right before you execute. Authorize again to act again. |
| `valid: false`, `agent_signature_invalid` | The `request` you passed carries a signature that doesn't verify: changed after signing, expired, replayed, or not covering the method and path | Pass the request exactly as the agent sent it, headers and body unchanged. |
| `valid: false`, `agent_signature_unverified` | The signature's `Signature-Agent` directory didn't resolve or doesn't list its key | Check the agent's directory publishes the key. |
| `404` [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing) at authorize | The `agent_id` belongs to another account | Use an agent registered with this key's account. |

## See also

- [Step-up approval](https://provenanceauth.com/docs/mandate/guides/step-up-approval.md)
- [Verify tokens offline](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md)
- [Decision ledger](https://provenanceauth.com/docs/mandate/concepts/decision-ledger.md)
- [Framework integrations](https://provenanceauth.com/docs/mandate/guides/framework-integrations.md)
