# Agent2Agent

Skerry speaks the Agent2Agent protocol (A2A), version 1.0 (release v1.0.1 of 28 May 2026; the protocol names versions by major and minor only), with its JSON-RPC and HTTP+JSON bindings. An agent that finds Skerry by its agent card can ask it to pay a merchant or to quote a payout or a conversion; an agent that finds a business's card can buy from that business. Each skill is a REST operation Skerry already has, called with the caller's own credential, so nothing about who may do what changes.

The normative source followed is `specification/a2a.proto` in the A2A repository, with the specification's sections on discovery, signing, caching and the JSON-RPC binding, read on 2026-11-16, and on listing, streaming, push notifications (3.1, 3.5, 4.3, 13.2) and the HTTP+JSON binding (11), read on 2026-11-18. The code is `lib/pure/a2a.ts` and `lib/a2a.ts`.

## Operations

| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
| `GET /.well-known/agent-card.json` | `none` | none | no | Skerry's agent card: the skills pay and quote, the JSON-RPC and HTTP+JSON interfaces at /a2a, signed. |
| `POST /a2a` | `agent-payments:write` | none | yes | Skerry's A2A endpoint: SendMessage (`pay` as POST /agent-payments, `quote` as POST /payouts/quote or POST /conversions/quote), SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask and the push notification configuration methods. |
| `GET /agentic/{customer_id}/.well-known/agent-card.json` | `none` | none | no | The agent card of a business that sells through agentic checkout: the skill checkout, signed. |
| `POST /agentic/{customer_id}/a2a` | `agent_credential` | none | yes | A business's A2A endpoint: SendMessage with `{ skill: checkout, input: { action: create \| get \| update \| complete \| cancel, ... } }`, SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask and the push notification configuration methods. |

## The cards

| Card | Address | Skills | Interface | Credential |
|---|---|---|---|---|
| Skerry's own | `/.well-known/agent-card.json` | `pay`, `quote` | `POST /a2a` | A Skerry API key, or an access token issued for this API |
| A business that sells | `/agentic/{customer_id}/.well-known/agent-card.json` | `checkout` | `POST /agentic/{customer_id}/a2a` | The credential the business issued to the agent platform (`POST /customers/{id}/agentic/credentials`) |

A business has a card once it has issued an agentic credential; before that, and for a business whose live environment is not open, its card address answers 404.

**Signed.** Each card carries one signature: a JWS with a detached payload, `alg: EdDSA`, `typ: JOSE`, `kid` the key's id and `jku` `/.well-known/jwks.json`, over the RFC 8785 canonical JSON of the card without `signatures`, as A2A's section on signing asks. The key is the one receipts are signed with (`SKERRY_RECEIPT_SIGNING_KEY`); a deployment without it serves its cards unsigned. A card is served with `Cache-Control: public, max-age=300` and an ETag of its content, and answers 304 to a matching `If-None-Match`.

## Asking for a skill

Every request sends `A2A-Version: 1.0` (the query parameter `A2A-Version` also works). A request with no version means 0.3 to A2A, which is not served: it is answered -32009.

`SendMessage` takes one message from the user (`role: "ROLE_USER"`) with one data part, `{ "skill": "…", "input": { … } }`, where `input` is the body of the operation the skill stands for:

```text
POST /a2a
A2A-Version: 1.0
Authorization: Bearer sk_test_…

{ "jsonrpc": "2.0", "id": 1, "method": "SendMessage",
  "params": { "message": { "messageId": "m-1", "role": "ROLE_USER",
    "parts": [ { "data": { "skill": "pay", "input": { "agent_id": "agt_…", "url": "https://data.example/v1/quote", "max_amount": 50, "currency": "usd" } } } ] } } }
```

| Skill | Stands for | Answer |
|---|---|---|
| `pay` | `POST /agent-payments` | A task `pay_<agent payment id>`; or, when the payment is held for a person, `approval_<approval id>`; or a message when the merchant asked for no payment |
| `quote` | `POST /payouts/quote` (`input.kind: "payout"`) or `POST /conversions/quote` (`"conversion"`) | A message with the quote: a quote moves nothing |
| `checkout` | `input.action`: `create` (`POST /agentic/{customer_id}/checkout_sessions`), `get`, `update`, `complete`, `cancel` (the session's own operations) | A task `checkout_<checkout session id>` |

A write is made under an idempotency key derived from the credential and the message's `messageId`: the same message sent again is answered as the first time and pays once. A message that continues a checkout can name it by its task (`message.taskId`) instead of `input.checkout_session_id`. Only the data part is read; a message with text or files only is answered -32005.

## Tasks

Tasks keep no state of their own. A task's id names the record it follows, and `GetTask` reads that record, so a task is never out of date and never outlives what it describes. Each task has the record as its one artifact (`artifactId` `<task id>_record`, a data part).

| Record | Task states |
|---|---|
| Agent payment | `paid` → `TASK_STATE_COMPLETED`; `refused` → `TASK_STATE_REJECTED`; `failed` → `TASK_STATE_FAILED`; otherwise `TASK_STATE_WORKING` |
| Approval (a held payment) | executed → `TASK_STATE_COMPLETED`; denied → `TASK_STATE_REJECTED`; expired → `TASK_STATE_CANCELED`; failed → `TASK_STATE_FAILED`; pending or approved → `TASK_STATE_WORKING` |
| Checkout session | `completed` → `TASK_STATE_COMPLETED`; `canceled` → `TASK_STATE_CANCELED`; `in_progress` → `TASK_STATE_WORKING`; otherwise `TASK_STATE_INPUT_REQUIRED` |

`CancelTask` cancels an open checkout. A payment attempt cannot be canceled, and a held one ends when a person decides or it expires: both answer -32002.

## Listing tasks

`ListTasks` lists the records tasks follow, newest status first: on Skerry's endpoint every agent payment of the caller's (the one held for a person as its `approval_` task), with the `agent-payments:read` scope; on a business's endpoint the business's checkout sessions that came by the Agentic Commerce Protocol. It takes `contextId`, `status` (a task state), `statusTimestampAfter`, `pageSize` (1 to 100, 50 by default), `pageToken` and `includeArtifacts`. The answer has `tasks`, `nextPageToken` (empty on the last page), `pageSize` and `totalSize`. Without `includeArtifacts` the tasks carry no `artifacts`; with it, a held payment's approval is shown only to a caller with `approvals:read`. Tasks keep no history, so `historyLength` changes nothing.

## Streaming

`SendStreamingMessage` and `SubscribeToTask` answer `text/event-stream`. Each event is one `data:` line: in the JSON-RPC binding a JSON-RPC response whose `result` is a `StreamResponse`, in the HTTP+JSON binding the `StreamResponse` itself. The first event is the task (or the one message that answers a quote, after which the stream ends). The task is then read again every three seconds, and a change sends an `artifactUpdate` (the record, whole, `lastChunk: true`) and then a `statusUpdate`. A sent message's stream ends when the task ends or waits on the client (`TASK_STATE_INPUT_REQUIRED`); a subscription ends only when the task ends. A stream lasts five minutes at most; subscribe again for more. `SubscribeToTask` on a task that has ended is -32004. `SKERRY_A2A_STREAMING=off` switches streaming off, and the cards say so.

## Push notifications

Offered when the deployment sets `SKERRY_A2A_PUSH=on`, and then `capabilities.pushNotifications` is true on the cards; otherwise every configuration method is -32003. A configuration is created with `CreateTaskPushNotificationConfig` (`taskId`, `url`, optional `token` and `authentication: { scheme, credentials }`), or with `configuration.taskPushNotificationConfig` on `SendMessage`, which is checked before the skill runs. The address must be HTTPS on a public address, checked again at every send. A task takes five configurations at most.

When the task's state changes, Skerry POSTs a `StreamResponse` holding a `statusUpdate` to the address, as `application/a2a+json`, with `Authorization: <scheme> <credentials>` and the token in `X-A2A-Notification-Token` (the header the A2A SDKs use; the specification names the field, not the header). Read the task with `GetTask` for its record. The state is looked at every fifteen seconds. A send that is not answered 2xx is tried again after a minute, five, twenty-five, two hours and ten, then given up. A configuration ends after its task ends and is told, when it is deleted, when the key or credential that set it up is revoked, or after thirty days.

Configurations on Skerry's endpoint are set up with an API key, because they are delivered later as that key; on a business's endpoint with the platform's credential. Each is seen and deleted only by whoever set it up. The credentials are kept sealed and never shown again: `GetTaskPushNotificationConfig` returns the scheme without them.

## The HTTP+JSON binding

Both endpoints also answer the specification's paths under their base: `POST {base}/message:send`, `POST {base}/message:stream`, `GET {base}/tasks`, `GET {base}/tasks/{id}`, `POST {base}/tasks/{id}:cancel`, `GET` or `POST {base}/tasks/{id}:subscribe` (the proto says GET, section 11.3.2 says POST; both are read), `POST` and `GET {base}/tasks/{id}/pushNotificationConfigs`, `GET` and `DELETE {base}/tasks/{id}/pushNotificationConfigs/{config_id}`. Bodies are `application/a2a+json` (plain `application/json` is read too), list parameters go in the query by their JSON names, and `A2A-Version` and the bearer credential are sent as headers, as for JSON-RPC.

## Errors

Errors are JSON-RPC errors whose `data` is a list holding one `google.rpc.ErrorInfo` (`@type`, `reason`, `domain: "skerry.xyz"`, `metadata`). A refusal by the operation keeps its own code as `reason` (for example `POLICY_DENIED`) and is -32602; a record that is not there is -32001 `Task not found`. A missing or refused credential keeps the operation's HTTP status (401, or 403 for a missing scope) and its `WWW-Authenticate` challenge.

In the HTTP+JSON binding an error is a `google.rpc.Status` (`{ "error": { code, status, message, details } }`) with the HTTP status of section 5.4 (404 for a task that is not there, 400 for the other A2A errors), and the same ErrorInfo in `details`; the ErrorInfo of an A2A error type has `domain: "a2a-protocol.org"`.

## Not offered

The extended agent card and the gRPC binding. Push notifications tell a change of state, not of the record alone. An access token bound with DPoP cannot be used through A2A, because the proof is bound to the address it was made for. The AP2 extension for A2A is not declared: the AP2 v0.2 pages give no extension URI to declare (see [ucp.md](ucp.md) for AP2).
