# A2A delegation v1

The A2A extension that carries a Provenance grant from one agent to another. Its URI is this page's address. The receiver declares its key in its Agent Card, and the sender puts the grant in Message.metadata.

**Extension URI:** `https://www.provenanceauth.com/docs/a2a/delegation/v1`

This page specifies how an agent hands a Provenance grant to another agent over [A2A](https://a2a-protocol.org/latest/specification/) 1.0. The grant is the authority, bound to the receiver's key. The A2A request's own authentication, from the receiver's `securitySchemes`, stays the operator's credential. The URI is the extension's identifier and includes its version; a breaking change gets a new URI (A2A section 4.6.3). `@provenanceauth/rails/a2a` implements every shape below, and a working client and server are in `examples/a2a-delegation/` in the Provenance repository.

## The receiver's Agent Card

A receiver that accepts grants lists the extension in `capabilities.extensions` (A2A section 4.4.3, `AgentExtension` in section 4.4.4):

```json
{
  "capabilities": {
    "extensions": [
      {
        "uri": "https://www.provenanceauth.com/docs/a2a/delegation/v1",
        "description": "Accepts Provenance grants bound to this agent's key, in Message.metadata under this URI.",
        "required": false,
        "params": {
          "holder_key": { "kty": "EC", "crv": "P-256", "x": "…", "y": "…" },
          "online_status_checks": true,
          "provenance_agent_id": "agt_…"
        }
      }
    ]
  }
}
```

| Param | Type | Meaning |
| --- | --- | --- |
| `holder_key` | P-256 public JWK | The key a grant handed to this agent is bound to (`cnf.jkt`). Never a private part |
| `online_status_checks` | boolean | The receiver checks each grant's status online before it acts |
| `provenance_agent_id` | string, optional | The receiver's registered agent. A grantor then sees its registry name and operator, and its account gets incoming-grant records |

Leave `required` false unless every request to the agent needs a grant.

## Turning it on

The sender lists the URI in the `A2A-Extensions` request header (A2A section 3.2.6). A receiver that activates it lists the URI in the response's `A2A-Extensions` header, as the A2A extensions guide recommends.

## The grant in the message

The sender gets the grant from Provenance with a hand-off to the receiver's key (see [hand off to outside agents](https://provenanceauth.com/docs/mandate/guides/hand-a-grant-to-an-outside-agent.md)). It puts the grant in the message's `metadata` under the extension URI, and lists the URI in the message's `extensions` (A2A section 4.1.4):

```json
{
  "messageId": "6f1c…",
  "role": "ROLE_USER",
  "parts": [{ "text": "Hold seat 14C on TP1351." }, { "data": { "flight": "TP1351", "seat": "14C", "fare": 420, "currency": "EUR" } }],
  "metadata": {
    "https://www.provenanceauth.com/docs/a2a/delegation/v1": {
      "grant_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6Im1hbmRhdGUrand0Ii…",
      "handoff_id": "xho_…",
      "approval_id": "appr_…"
    }
  },
  "extensions": ["https://www.provenanceauth.com/docs/a2a/delegation/v1"]
}
```

| Field | Meaning |
| --- | --- |
| `grant_token` | The grant (`mandate+jwt`), bound to the receiver's key |
| `handoff_id` | The Provenance hand-off it was minted from, optional |
| `approval_id` | The grantor's approval, optional |

## Checking the grant

The receiver accepts the grant only when all of these hold:

1. It checks against Provenance's published JWKS: signature, expiry, and the limits for what is asked.
2. Its `cnf.jkt` is the thumbprint of the receiver's own `holder_key`. A bearer grant, or one bound to another key, is refused.
3. When the receiver declared `online_status_checks`, or the grant says `status_check: "online"`, its status at `GET /v1/public/grants/{id}/status` is `active`.

```ts
import { acceptDelegation } from "@provenanceauth/rails/a2a";

const verdict = await acceptDelegation(message, { jwks, holderKey: myPublicKey, need: { amount: 420 }, online: true, apiBase: "https://api.provenanceauth.com" });
```

When the receiver acts at a store under the grant, it signs each request with its key (a DPoP proof), as [bind a grant to its holder](https://provenanceauth.com/docs/mandate/guides/bind-a-grant-to-its-holder.md) describes.

## Asking for more

A receiver whose grant doesn't cover the request moves the task to `TASK_STATE_AUTH_REQUIRED` (A2A section 4.1.3). Its status message names what it needs under the extension URI:

```json
{
  "state": "TASK_STATE_AUTH_REQUIRED",
  "message": {
    "role": "ROLE_AGENT",
    "parts": [{ "text": "I need a grant that covers 840." }],
    "metadata": { "https://www.provenanceauth.com/docs/a2a/delegation/v1": { "need": { "amount": 840, "currency": "EUR", "action_type": "purchase", "reason": "The fare for seat 2A is 840." } } },
    "extensions": ["https://www.provenanceauth.com/docs/a2a/delegation/v1"]
  }
}
```

The sender asks its grantor for a new grant through Provenance, then replies in the same task (`taskId` and `contextId`) with the new `grant_token`. The state itself authorizes nothing; only a signed grant does.

## The receipt

The receiver's result artifact names what it did under the grant in its `metadata` under the extension URI (A2A section 4.1.7):

```json
{ "https://www.provenanceauth.com/docs/a2a/delegation/v1": { "grant_id": "grt_…", "reference": "hold_8c2f…" } }
```

| Field | Meaning |
| --- | --- |
| `grant_id` | The grant used |
| `reference` | The receiver's own reference for what it did, optional |
| `decision_id`, `receipt_id` | A Provenance decision or receipt, when the action went through Provenance, optional |

## Versions

| URI | A2A | Changes |
| --- | --- | --- |
| `https://www.provenanceauth.com/docs/a2a/delegation/v1` | 1.0 | First version |
