# Agentic checkout

An agent platform can buy from a customer through the Agentic Commerce Protocol. The customer issues the platform a bearer token, says where its own system prices a basket, and says what agents may do. The platform then opens, changes, completes and cancels checkout sessions at the customer's own endpoint, `/agentic/{customer_id}`.

Status: preview. Sessions can be created, priced, updated, retrieved and cancelled. Completing one charges a delegated payment token, so it works only where delegated payment tokens are switched on: `SKERRY_AGENT_TOKENS_ENABLED=true` for the deployment and a profile at the token issuer for the customer's merchant account. Until then `complete` answers `capability_off`. Card acceptance itself is test mode only (see status.md). The code is `lib/agentic.ts`, `lib/pure/acp.ts` and `lib/agent-token.ts`.

Skerry holds no catalogue and computes no tax. What a buyer is shown comes from the customer's system.

## Protocol revision

The protocol code follows the specification's 2026-04-17 snapshot, its description of agentic checkout and of order webhooks, as it stood on 2026-11-13.

`API-Version` values accepted: `2025-09-29`, `2025-12-12`, `2026-01-16`, `2026-01-30`, `2026-04-17`. The latest, `2026-04-17`, is the one followed.

Checked again on 2026-11-14 against the 2026-04-17 snapshot in the protocol's repository (`github.com/agentic-commerce-protocol/agentic-commerce-protocol`: `changelog/2026-04-17.md`, `rfcs/rfc.agentic_checkout.md` section 6, `spec/2026-04-17/openapi/openapi.agentic_checkout.yaml` and `openapi.agentic_checkout_webhook.yaml`):

| Rule of the snapshot | Here |
|---|---|
| `Idempotency-Key` on every POST, at most 255 characters; without it 400 `idempotency_key_required` | Followed, on create, update, complete, cancel and the refund extension. |
| The key is scoped to the authenticated identity and the endpoint path | Followed: the credential and the path. |
| The same key and the same body (compared as JSON, not as bytes) returns the first answer with its status; `Idempotent-Replayed: true` | Followed. The header is sent only on a replay. `Idempotency-Key` and `Request-Id` are echoed. |
| The same key with another body: 422 `idempotency_conflict` | Followed. |
| The same key while the first request runs: 409 `idempotency_in_flight` with `Retry-After` | Followed (`Retry-After: 1`). |
| All three use `type: invalid_request` | Followed. |
| A 5xx answer is not kept against the key | Followed: the claim is released. |
| Keys are kept at least 24 hours | Followed: they are not removed. |
| Order webhooks carry `Merchant-Signature: t=<unix seconds>,v1=<64 hex>`, HMAC-SHA256 over `<t>.<raw body>` | Followed. |
| A discovery document at `/.well-known/acp.json` | Not served. The document must sit at the origin root and must not name a seller, and its `api_base_url` is the base that resource paths are appended to; a customer's endpoint here is `/agentic/{customer_id}`. Serving it needs a decision on how the address is organised. |
| Carts, product feeds, the MCP transport | Not offered. |

A second complete of the same session with a different key, while the first is running, is also answered 409 `idempotency_in_flight`; the snapshot defines that code for the same key only and names no code for this case.

A request with no `API-Version` is refused with `missing_api_version`, one with an unknown version with `unsupported_api_version`; both carry `supported_versions`.

**Older forms, kept.** Build against the current snapshot (2026-04-17). The earlier snapshots and the first published request forms are still read for platforms that have not moved: `items` with `id` and `quantity`, a single `fulfillment_option_id`, a bare `fulfillment_address`, and, before 2026-01-30, `payment_data: { token, provider }` in place of a handler and an instrument.

## What the customer sets

| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
| `POST /customers/{id}/agentic/credentials` | `agentic:write` | none | no | Issue a bearer token to an agent platform. |
| `GET /customers/{id}/agentic/credentials` | `agentic:read` | none | no | The customer's agent-platform credentials, never with a secret. |
| `DELETE /customers/{id}/agentic/credentials/{credential_id}` | `agentic:write` | none | no | Revoke a credential. |
| `POST /customers/{id}/agentic/pricing-callback` | `agentic:write` | none | no | Register the URL asked for line items, totals, tax and fulfilment each time a session is created or changed. |
| `GET /customers/{id}/agentic/settings` | `agentic:read` | none | no | What the customer allows agents, and the address agent platforms call. |
| `POST /customers/{id}/agentic/settings` | `agentic:write` | none | no | Change what the customer allows agents: verified agents only, the refunds an agent may start, the links a session shows, whether payment links answer automated clients with a challenge, and how long unused credit is refundable. |
| `GET /customers/{id}/agentic/refund-requests` | `agentic:read` | none | no | Refunds agents have asked for, newest first. |
| `POST /customers/{id}/agentic/refund-requests/{request_id}` | `refunds:write` | optional | yes | Approve or deny a refund an agent asked for. |
| `POST /customers/{id}/agentic/orders/{session_id}` | `agentic:write` | optional | no | Say where an order has got to; the agent platform is told with a signed order event. |
| `GET /customers/{id}/agentic/orders/{session_id}` | `agentic:read` | none | no | Where an order stands: the order as the agent platform was last told it, `session_status`, and `webhook`: how the last order event went (`status` pending, delivered or exhausted, with `attempts`, or `reason: no_webhook`). |

```text
POST /customers/{id}/agentic/credentials
Authorization: Bearer sk_test_…
Idempotency-Key: 3b9e…

{ "name": "Shopping assistant", "platform": "example-platform", "webhook_url": "https://platform.example/acp/orders", "require_signature": true }
```

The answer shows the bearer token, and the signing and webhook secrets when asked for, once. `GET` lists credentials without a secret; `DELETE …/credentials/{credential_id}` revokes one from the next call.

```text
POST /customers/{id}/agentic/pricing-callback

{ "url": "https://shop.example/skerry/price" }
```

Each time a session is created or changed, Skerry POSTs to that address, signed with `Skerry-Signature`:

```text
{ "type": "checkout_session.price", customer_id, checkout_session_id, currency, items, buyer, fulfillment_details, selected_fulfillment_options, discounts, api_version }
```

A Universal Commerce Protocol cart (when the customer has `carts_enabled`, see [ucp.md](ucp.md)) is priced the same way, as an estimate, with `"type": "cart.price"` and `cart_id` in place of `checkout_session_id`; the answer is read the same way.

and expects, within `SKERRY_PRICING_CALLBACK_TIMEOUT_MS` (4 seconds by default):

```text
{ currency?, line_items: [{ id, quantity?, name?, unit_amount, totals? }], fulfillment_options?, totals: [{ type, display_text, amount }], messages?, links?, ready? }
```

The amounts are taken as stated. What is checked is that each is an integer, that a total exists and is positive, and that every item asked for was priced; otherwise the session answers `pricing_unavailable`. The callback address must be HTTPS on a public address: it is called the way every address a customer supplies is (see security.md). Without a callback, the only things that can be sold are the customer's fixed-amount payment links, each item id naming a link, at the link's amount, with no tax and no shipping.

```text
POST /customers/{id}/agentic/settings

{ "require_verified_agent": false, "refunds": { "window_days": 14, "max_amount": 5000, "needs_approval": true } }
```

Agent refunds are off until a window is set.

## What the agent platform calls

| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
| `POST /agentic/{customer_id}/checkout_sessions` | `agent_credential` | none | no | Create a checkout session. |
| `GET /agentic/{customer_id}/checkout_sessions/{checkout_session_id}` | `agent_credential` | none | no | Retrieve a checkout session. |
| `POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}` | `agent_credential` | none | no | Update a checkout session: items, buyer, fulfilment details, the fulfilment option chosen. |
| `POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}/complete` | `agent_credential` | none | yes | Complete with a delegated payment token. |
| `POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}/cancel` | `agent_credential` | none | no | Cancel a session that has not completed. |
| `POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}/refunds` | `agent_credential` | none | yes | A Skerry extension (`xyz.skerry.refunds`), not part of the protocol: ask for a refund of a completed session, within what the business allows agents. |

```text
POST /agentic/{customer_id}/checkout_sessions
Authorization: Bearer <the token the customer issued>
API-Version: 2026-04-17
Idempotency-Key: 9c1d…

{ "line_items": [{ "id": "sku_123", "quantity": 2 }], "currency": "usd" }
```

The answer is 201 with the session in the protocol's shape and status: `not_ready_for_payment`, `ready_for_payment`, `authentication_required`, `complete_in_progress`, `completed`, `canceled` or `expired`.

```text
POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}/complete

{ "payment_data": { "handler_id": "…", "instrument": { "type": "card", "credential": { "type": "shared_payment_token", "token": "spt_…" } } } }
```

A decline leaves the session payable with a message. A bank that wants the buyer to authenticate makes it `authentication_required`; the platform sends `authentication_result` on a further `complete`. A session that has completed answers 405 to `cancel`.

Rules on every call:

- **Idempotency.** Every POST needs `Idempotency-Key`. The same key with the same body returns the first answer with `Idempotent-Replayed: true`; with a different body, 422 `idempotency_conflict`; while the first is still running, 409 `idempotency_in_flight`.
- **Request signatures.** A credential made with `require_signature` also needs `Timestamp` (RFC 3339, within five minutes) and `Signature`: base64url of HMAC-SHA256 with the signing secret over `<Timestamp>.<canonical JSON of the body>` (keys sorted, no whitespace; nothing after the dot when there is no body). Otherwise `invalid_signature`.
- **Errors** are the protocol's `{ type, code, message, param }`, not Skerry's envelope.

## Orders

```text
POST /customers/{id}/agentic/orders/{session_id}

{ "status": "shipped", "estimated_delivery": "2026-11-20" }
```

The platform is told with `order_create` and `order_update` events at the credential's `webhook_url`, signed `Merchant-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of '<t>.<raw body>'>`. Each event is recorded in `agentic_order_delivery` before it is sent and tried once at once; one that fails is tried again on the webhook schedule (a minute, five, twenty-five, two hours, ten) until it is delivered or out of attempts. The body is signed afresh on each attempt. The outcome is kept on the session's order as `webhook`, and `GET /customers/{id}/agentic/orders/{session_id}` reads it with the order.

## Refunds an agent asks for

The specification defines no refund call. `POST /agentic/{customer_id}/checkout_sessions/{checkout_session_id}/refunds` with `{ amount?, reason? }` is a Skerry extension, named `xyz.skerry.refunds` wherever it appears. It is refused with `refunds_not_enabled`, `not_paid`, `outside_window`, `over_limit` or `nothing_to_refund` where those apply. When the customer asked for a person to approve, it answers 202 and waits in `GET /customers/{id}/agentic/refund-requests`; a person decides it with `POST /customers/{id}/agentic/refund-requests/{request_id}` `{ decision: approve | deny }`, and approving runs it as a refund under the deciding key's own policies. Otherwise it answers 201 with the refund.

## Who the agent is

The routes agents call read two signature conventions (`lib/pure/web-bot-auth.ts`):

| Convention | Revision | Result |
|---|---|---|
| Web Bot Auth: an HTTP Message Signature with `tag="web-bot-auth"` and a `Signature-Agent` header whose member, keyed to the signature, is the HTTPS address of the signer's JWK Set (`sig1="https://agent.example/jwks.json"`) | [draft-ietf-webbotauth-httpsig-protocol-01](https://datatracker.ietf.org/doc/draft-ietf-webbotauth-httpsig-protocol/01/), 29 October 2026 (read 14 November 2026) | Verified against that key set, fetched as sent from a public address only. Only a 200 answer counts and a redirect is not followed. Verified for `ed25519`, `rsa-pss-sha512` (the two the draft's test vectors use) and `ecdsa-p256-sha256` (P-256 keys, whose thumbprint the draft also defines); the key in the set decides the algorithm, and an `alg` that key cannot make is refused (`unsupported_algorithm`). Shared HMAC, which the draft forbids, is not read. |
| Visa's Trusted Agent Protocol: `tag="agent-browser-auth"` or `tag="agent-payer-auth"` | its merchant specifications (developer.visa.com, read 17 Nov 2026; no version given) and the reference code at github.com/visa/trusted-agent-protocol, commit `16d59bdf3f8a` (28 Oct 2025; no releases) | Checked for the tag, `@authority` and `@path`, `keyid`, `nonce`, and `created` to `expires` of at most eight minutes. With `SKERRY_VISA_TAP=on` and `SKERRY_VISA_TAP_KEYS` set, verified against the key `keyid` names (Ed25519, or RSA-PSS with SHA-256), and a nonce that already verified in the last eight minutes is refused as `replayed`. Without them it is recorded as unverified with `keys_not_published`: Visa has not said where its keys are published. The objects Visa puts in the body (the consumer recognition object and payment container) are not read. |

Since 18 November 2026 a `Signature-Agent` member that carries parameters is ignored, as the draft requires: the `;type=directory` and `;type=jwks_uri` members of draft-meunier-webbotauth-httpsig-protocol-02 are no longer read. An origin alone (`sig1="https://agent.example"`) is fetched as sent like any other address; the well-known directory at that origin is no longer tried in its place. A signature is attributed only to the member keyed to its own label, and only when it covers that member. At a host's well-known directory, a key whose `kid` is not its thumbprint is not used.

One older form is still read, because the draft lets a verifier accept it (section 5.2.1): the bare string, `"https://agent.example"`, as a single member belonging to the signature that covers it. A request that used it is recorded with `older_form: "signature_agent_string"`.

The agent's identifier is the address its keys were read from, with any query dropped. A fetched key set is kept for ten minutes; a fetch that fails is not tried again for five minutes and does not discard the keys already held, for up to a day.

The result is stored on the session and the payment as `agent_identity: { verified, method, key_id, operator, signature_agent, older_form? }`. `signature_agent` is the identifier; `operator` is the host, and is set only when the keys were read from that host's well-known key directory, because another path names an address and not the host's operator. A request is never refused for lacking a signature unless the customer has set `require_verified_agent` (`agent_not_verified`); that refusal carries `Accept-Signature` with what a signature should cover (`@authority`, `@method`, `@path` and the signature's own `Signature-Agent` member, with `created` and `expires`), as the draft's section 5.3 asks.

## Where the sessions show

A session an agent opened is an ordinary checkout session with `source: "agentic"`: it appears in `GET /checkout-sessions`, its payment in `GET /payments` with `agent: { initiated, token_id, platform, token_limits, indicators }`, and it emits the usual events (see [payments.md](payments.md)). The same delegated payment token can be charged directly with `POST /payments` and `payment_token: { type: "shared_payment_token", id }`. The token's limits are enforced by its issuer and read first where they can be, so a charge that plainly exceeds them is refused without being sent.

## What is not built

- In agentic checkout Skerry is the seller's side only. It does not act as an agent platform. A registered agent paying another merchant is a separate preview, in x402 and the Machine Payments Protocol and not in this protocol: see [agent-payments.md](agent-payments.md).
