# REST profile

A formal REST profile for the SACP calls. It says how an agent and a shop talk over HTTP: how requests are signed, how a retry is safe, how errors look, and how a price change between prepare and confirm is caught. The words MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119 and RFC 8174.

## What this profile is

The profile is new in 1.3.0-draft. It is additive. A shop advertises it with the capability `rest.profile` and the extension `extensions.rest` in its discovery document. A shop that does not advertise it keeps the 1.0.0, 1.1.0 and 1.2.0 behaviour. Nothing in the earlier layers is removed.

The machine-readable form is an OpenAPI 3.1 document: [`/openapi.yaml`](https://agentictradestandard.org/openapi.yaml) and [`/openapi.json`](https://agentictradestandard.org/openapi.json). The request and response bodies are JSON Schemas under [`/schemas/`](https://agentictradestandard.org/schemas/rest.schema.json). This page is the human-readable rules. If the page and the OpenAPI document disagree, report it. The page is normative for behaviour, the schemas for the shape of bodies.

- Scope: the seven calls of 1.0.0 (discovery, catalog search, product, shipping quote, negotiation, item collection, checkout prepare) plus three new checkout calls: `GET /checkout/{checkout_id}`, `POST /checkout/{checkout_id}/confirm` and `POST /checkout/{checkout_id}/cancel`.
- Confirm is optional. It exists only for autonomous checkout ([1.2.0](https://agentictradestandard.org/phases/)), level `rest-enterprise`, and only when the shop advertises `checkout.autonomous`. In `human_handoff` a person confirms with the merchant, and the agent reads the result with GET or a webhook.
- The profile does not change who pays and who is merchant of record. The call carries no card number and no private key.

## Transport and TLS

- Every endpoint MUST be served over HTTPS with TLS 1.2 or later. TLS 1.3 SHOULD be offered. Plain HTTP MUST NOT answer API calls (a redirect is allowed for discovery only).
- The API host MUST send `Strict-Transport-Security` with `max-age` of at least 31536000. The certificate MUST chain to a publicly trusted root.
- Bodies are UTF-8 JSON (`Content-Type: application/json`). A shop answers 415 `unsupported_media_type` for anything else and 413 `payload_too_large` above 1 MiB (the limit may be advertised as `max_body_bytes`).
- HTTP/1.1 MUST be supported. HTTP/2 and HTTP/3 MAY be offered. Agents MUST send a `User-Agent` that names the agent and a contact.
- Checkout endpoints are for servers, not browsers. A shop MUST NOT answer them with `Access-Control-Allow-Origin: *`. Discovery, JWKS, schemas and the OpenAPI document MAY be open to any origin.

## Versioning and deprecation

The major version is the last segment of the base path, for example `/wp-json/agent-commerce/v1`. A breaking change needs a new major version and a new path. Within a major version changes are additive: new optional fields, new endpoints, new error codes, new enum values the client must tolerate. A client MUST ignore unknown members and MUST treat an unknown error code by its HTTP status.

- The request header `SACP-Version` (for example `1.3`) is optional. It names the minor version the agent was written for. If the shop cannot serve it, it answers 400 `version_unsupported` and lists `supported_versions`. Without the header the shop serves its latest minor version of that major version. The shop SHOULD send `SACP-Version` in every answer.
- A deprecated operation MUST carry `Deprecation` (RFC 9745) and, when a removal date is set, `Sunset` (RFC 8594) with a `Link` to the replacement. Once a major version is final, a deprecated operation MUST keep working for at least 12 months after the Sunset date is announced.
- While SACP is a draft (`-draft`), changes can come in any minor version. Every change is listed in the [changelog](https://agentictradestandard.org/changelog/). One change in 1.3.0-draft is deprecated, not removed: a plain number as `max_price` in catalog search. Use a money object.

## Authentication and agent identification

Two things are kept apart. **Identification** says which agent is calling (this section). **Authority** says what that agent may commit (the [mandate](https://agentictradestandard.org/authority/)). A valid signature is never authority.

### HTTP Message Signatures (RFC 9421)

- Every call in the `checkout` phase MUST be signed with RFC 9421, or sent over mutual TLS (RFC 8705 style, certificate bound). This covers prepare, status, confirm and cancel. A shop MAY require signatures on `shopping` calls too (`required_for` in `extensions.rest.signature`). If a shopping call carries a signature, the shop MUST verify it and reject a bad one.
- Allowed algorithms: `ed25519` and `ecdsa-p256-sha256`. Shared-secret MACs (`hmac-sha256`) MUST NOT be accepted for agent requests, because a shop would hold the secret that proves the agent.
- Covered components, at least: `@method`, `@target-uri`, `content-type` and `content-digest` (when there is a body), `sacp-agent-id`, and, when present, `idempotency-key` and `if-match`. The body digest is `Content-Digest: sha-256=:…:` (RFC 9530). The shop MUST compute it over the received body bytes and compare.
- Parameters: `created`, `expires`, `nonce`, `keyid`, `alg` and `tag="sacp-1"`. `expires` minus `created` MUST NOT exceed 300 seconds. The shop allows 60 seconds of clock skew. Outside the window it answers 401 `signature_expired`.
- Replay protection: the shop MUST remember each `nonce` per key until `expires` plus the skew, and MUST answer 401 `replay_detected` for a repeat. Idempotency keys (below) and the checkout state machine are a second line, not a replacement.
- `keyid` is the RFC 7638 thumbprint of the agent key. It MUST equal `agent.key_thumbprint` in the [mandate](https://agentictradestandard.org/authority/) when a mandate is presented, and the key MUST be one the shop has accepted for that `SACP-Agent-Id`. A shop that cannot bind key and agent id answers 401 `signature_invalid`.

### Key discovery

- Agent keys are published as a JSON Web Key Set (RFC 7517). The agent MAY send `Signature-Agent` with the HTTPS URL of its key directory (practice from the IETF web bot authentication work, still a draft). A shop MAY instead pre-register keys out of band. A shop MUST NOT fetch a key directory from a private or link-local address.
- The shop publishes its own public keys at `jwks_uri` (default `/.well-known/jwks.json`). They verify `quote_signature` ([1.1.0](https://agentictradestandard.org/intent-binding/)) and webhook signatures. When a key is replaced, the old key stays in the set for at least `max_validity_seconds` plus the idempotency retention.
- A key that is lost or exposed is removed from the directory, and the issuer revokes the mandate that names its thumbprint. The shop checks the mandate status as in 1.1.0.

A signed example with real values is in [`/files/example-signed-request.json`](https://agentictradestandard.org/files/example-signed-request.json). It contains the signature base, so that an implementer can verify the signature with the public key. The key pair was generated for the example and the private key was discarded.

## Idempotency

A network can fail after the shop acted and before the agent heard. A retry must not buy twice. The profile follows the IETF `Idempotency-Key` header (a draft). The value is a Structured Field String (RFC 9651), in double quotes, 16 to 255 characters. A random UUID is recommended.

- Required (MUST send, MUST be enforced) on `POST /collection/items`, `POST /checkout/prepare`, `POST /checkout/{checkout_id}/confirm` and `POST /checkout/{checkout_id}/cancel`. Optional on search, shipping quote and negotiation. A missing key answers 400 `idempotency_key_missing`.
- Scope: the key is unique per agent identity (the verified key), not per IP address. The shop stores the key with a fingerprint of method, path and body, and the first answer (status and body).
- Same key and same request: the shop MUST return the stored answer with the same status and body, and the header `Idempotent-Replayed: true`. It MUST NOT run the action again.
- Same key, different request: 422 `idempotency_key_reuse`. Same key while the first request still runs: 409 `idempotency_in_progress` with `Retry-After`.
- Retention: at least 24 hours (`retention_seconds` in discovery) and at most 30 days. After that the stored answer MUST be deleted. A 5xx answer SHOULD NOT be stored, so that a retry can succeed.

## Errors

Every error is `application/problem+json` (RFC 9457) with the members `type`, `title`, `status` and `code`. The `code` is a stable string from the registry below, and `type` is `https://agentictradestandard.org/api/#err-{code}`, which resolves to the row for that code. Code-specific members from earlier versions (`diff`, `reasons`, `required`, `retry_after_seconds`) stay as extension members. The schema is [`problem.schema.json`](https://agentictradestandard.org/schemas/problem.schema.json).

- `detail` MUST NOT contain personal data, secrets, a stack trace or an internal host name. `trace_id` SHOULD be present.
- The client decides on `code` and `retryable`, never on `detail`. A `retryable` error may be retried with the same `Idempotency-Key`, after `Retry-After` when it is present, with exponential backoff and jitter.
- Order of checks on confirm: signature (401), idempotency key (400, 409, 422), `If-Match` (428, 412), checkout state (404, 410, 409), live terms against `terms_hash` (409), mandate and approvals (403, 428). A rate limit (429) may come at any step. Nothing is committed unless every check passes.

### Error code registry

The registry is machine-readable at [`/files/sacp-error-registry.json`](https://agentictradestandard.org/files/sacp-error-registry.json). New codes are added in minor versions, with the version in the last column. A vendor extension MUST use a code with the prefix `x_`.

| Code | HTTP | Title | Retry | Meaning | Since |
|---|---|---|---|---|---|
| <code id="err-invalid_request">invalid_request` | 400 | Invalid request | no | The request is malformed: bad JSON, a missing header or a value of the wrong type that is not covered by a more specific code. | 1.3.0 |
| <code id="err-phase_mismatch">phase_mismatch` | 400 | Phase mismatch | no | The declared agent_phase does not fit the call. Example: shopping on POST /checkout/prepare. | 1.2.0 |
| <code id="err-phase_undeclared">phase_undeclared` | 400 | Phase undeclared | no | The shop advertises agent.lane and the request declares no phase. | 1.2.0 |
| <code id="err-phase_conflict">phase_conflict` | 400 | Phase conflict | no | The body and the SACP-Agent-Phase header declare different phases. | 1.2.0 |
| <code id="err-idempotency_key_missing">idempotency_key_missing` | 400 | Idempotency-Key missing | no | The call requires an Idempotency-Key header and none was sent. | 1.3.0 |
| <code id="err-version_unsupported">version_unsupported` | 400 | Version unsupported | no | The SACP-Version header names a version the shop does not serve. The body lists the supported versions. | 1.3.0 |
| <code id="err-signature_required">signature_required` | 401 | Signature required | no | The call requires an HTTP Message Signature (or a client certificate) and none was sent. The response may carry Accept-Signature. | 1.3.0 |
| <code id="err-signature_invalid">signature_invalid` | 401 | Signature invalid | no | The signature does not verify, the key is unknown, the algorithm is not allowed, or a required component is not covered. | 1.3.0 |
| <code id="err-signature_expired">signature_expired` | 401 | Signature expired | yes | The created or expires parameter is outside the allowed window. Check the clock and sign again. | 1.3.0 |
| <code id="err-replay_detected">replay_detected` | 401 | Replay detected | no | The nonce was already used inside its window. Sign a new request with a new nonce. | 1.3.0 |
| <code id="err-authority_denied">authority_denied` | 403 | Authority denied | no | The mandate does not cover the terms. The reasons member lists why. | 1.1.0 |
| <code id="err-autonomous_not_offered">autonomous_not_offered` | 403 | Autonomous checkout not offered | no | checkout_mode is autonomous and the shop does not advertise checkout.autonomous. | 1.2.0 |
| <code id="err-not_found">not_found` | 404 | Not found | no | The product, collection or checkout does not exist, or the caller may not see it. | 1.3.0 |
| <code id="err-terms_changed">terms_changed` | 409 | Terms changed | no | A material change voided the approval. No handoff is issued and nothing is confirmed. The body carries the diff and the current terms. | 1.1.0 |
| <code id="err-idempotency_in_progress">idempotency_in_progress` | 409 | Idempotency in progress | yes | A request with the same Idempotency-Key is still running. Retry after Retry-After. | 1.3.0 |
| <code id="err-checkout_state_conflict">checkout_state_conflict` | 409 | Checkout state conflict | no | The checkout is in a state that does not allow this call. Example: confirm on a human_handoff checkout. | 1.3.0 |
| <code id="err-checkout_expired">checkout_expired` | 410 | Checkout expired | no | The prepared checkout passed expires_at. Prepare a new one. | 1.3.0 |
| <code id="err-precondition_failed">precondition_failed` | 412 | Precondition failed | no | If-Match does not equal the current ETag. The checkout changed after the agent read it. Fetch it again with GET. | 1.3.0 |
| <code id="err-payload_too_large">payload_too_large` | 413 | Payload too large | no | The body is larger than the shop accepts. The limit is 1 MiB unless the shop advertises another limit. | 1.3.0 |
| <code id="err-unsupported_media_type">unsupported_media_type` | 415 | Unsupported media type | no | The Content-Type is not application/json. | 1.3.0 |
| <code id="err-validation_failed">validation_failed` | 422 | Validation failed | no | The body is valid JSON but breaks the schema or a business rule. The errors member lists JSON Pointers. | 1.3.0 |
| <code id="err-idempotency_key_reuse">idempotency_key_reuse` | 422 | Idempotency-Key reused | no | The Idempotency-Key was used before with a different request. Use a new key for a new request. | 1.3.0 |
| <code id="err-approval_required">approval_required` | 428 | Approval required | no | The amount is above an approval threshold. A named approver must sign an approval bound to the terms hash. | 1.1.0 |
| <code id="err-precondition_required">precondition_required` | 428 | Precondition required | no | The call requires an If-Match header and none was sent. | 1.3.0 |
| <code id="err-rate_limited">rate_limited` | 429 | Rate limited | yes | The limit for the agent phase was exceeded. Wait Retry-After seconds. | 1.2.0 |
| <code id="err-internal_error">internal_error` | 500 | Internal error | yes | The shop failed. Retry with the same Idempotency-Key. | 1.3.0 |
| <code id="err-service_unavailable">service_unavailable` | 503 | Service unavailable | yes | The shop is down or in maintenance. Retry after Retry-After. | 1.3.0 |

## Pagination

Lists use cursors, not offsets. The request carries `limit` (1 to 100, default 20; the shop may advertise lower numbers) and `cursor`. The answer carries `items` and `next_cursor`, which is `null` on the last page. The cursor is opaque. A shop MUST keep a cursor valid for at least 10 minutes. An expired cursor answers 422 `validation_failed` with the pointer `/cursor`. Results can change between pages, so an agent MUST NOT assume a stable snapshot. A GET list (none exists yet) uses the query parameters `limit` and `cursor` and the `Link` header with `rel="next"` (RFC 8288).

## Rate limits

- Every answer SHOULD carry `RateLimit-Policy` and `RateLimit` (IETF structured header fields, a draft), for example `RateLimit-Policy: "checkout";q=10;w=60` and `RateLimit: "checkout";r=7;t=42`. The policy name is the agent phase (`shopping` or `checkout`), as in [1.2.0](https://agentictradestandard.org/phases/).
- At the limit the shop MUST answer 429 `rate_limited` with `Retry-After` in whole seconds, and the body member `retry_after_seconds` with the same number. Overload and maintenance answer 503 `service_unavailable` with `Retry-After`.
- The limits are counted per agent identity and phase. An agent that gets 429 MUST wait and MUST NOT rotate keys or identities to get around the limit.

## ETag, If-Match and price changes

Between `prepare` and `confirm` the world can change: a price, a stock level, a shipping cost, the expiry. Two different checks catch this, and they answer different questions.

| Check | Question | Answer on failure |
|---|---|---|
| `If-Match` with the checkout `ETag` | Is the checkout the agent holds still the current one? | 412 `precondition_failed` (428 `precondition_required` if the header is missing). Read the checkout again with GET. |
| `terms_hash` in the confirm body | Do the live terms still equal the terms that were approved? | 409 `terms_changed` with a diff and the current terms. Under the default tolerance of zero any price increase is material. See [approved terms](https://agentictradestandard.org/intent-binding/). |

- Every checkout answer carries a strong `ETag`. It MUST change when `terms_hash`, `status` or `expires_at` changes. `GET` supports `If-None-Match` and answers 304.
- On confirm the shop MUST re-quote and compare the live terms with `terms_hash` before it commits, even if `If-Match` matched. A price rise inside the tolerance of the approved snapshot is allowed. Nothing outside it is. The customer or the mandate never sees a silent change.
- A confirm that already succeeded and is sent again with the same `Idempotency-Key` returns the stored 200. A new key on a confirmed checkout answers 409 `checkout_state_conflict`. The shop MUST NOT create a second order.

## The checkout resource

`POST /checkout/prepare` creates a checkout. Its status moves along these edges and never backwards:

| Status | Meaning | Next |
|---|---|---|
| `awaiting_human` | human_handoff. The handoff URL is issued. A person completes it with the merchant. | `confirmed`, `expired`, `cancelled`, `failed` |
| `ready_to_confirm` | autonomous. The terms are bound. The agent may call confirm. | `confirmed`, `expired`, `cancelled`, `failed` |
| `confirmed` | An order exists (`order.order_id`). Terminal. | — |
| `expired`, `cancelled`, `failed` | Terminal. Nothing was charged by this checkout. | — |

- `checkout_id` MUST be unguessable (at least 128 bits of randomness) and bound to the agent that created it. Another agent asking for it gets 404 `not_found`, not 403.
- `expires_at` is never later than `valid_until` of the terms snapshot. After it the checkout answers 410 `checkout_expired` on confirm and shows `expired` on GET.
- The confirm answer carries `authority_check` with `audit_event_id` when a mandate was checked, so that the [audit trail](https://agentictradestandard.org/authority/) and the order can be joined.

## Formats

| Kind | Format | Example |
|---|---|---|
| Money | Object `{"amount", "currency"}`. `amount` is a decimal string in major units with the exponent of the currency (ISO 4217): two decimals for SEK, none for JPY. `currency` is the ISO 4217 alphabetic code. JSON numbers are not used for money, because binary floating point cannot hold 0.10. | `{"amount":"1290.00","currency":"SEK"}` |
| Timestamp | RFC 3339 date-time in UTC with the suffix `Z`. No local offsets. | `2026-12-04T09:15:00Z` |
| Date | ISO 8601 calendar date, `YYYY-MM-DD`. | `2026-12-09` |
| Country | ISO 3166-1 alpha-2, upper case. A postcode is sent only when the carrier needs it for the quote. A street address is never part of a shopping call. | `SE` |
| Quantity | Positive integer. | `1` |
| Identifiers | Opaque strings, at most 128 characters, case sensitive. The client never parses them. | `co_7f3a91` |
| Hash | `sha256:` and 64 lower-case hex characters over RFC 8785 canonical JSON. | `sha256:8042…f1fb` |

## The agent reference

The agent reference is a critical data element. It answers one audit question: which agent, under which mandate, made this order. Added in `1.3.0-draft` from community feedback.

| Member | Meaning |
|---|---|
| `key_id` | The RFC 7638 thumbprint of the key that signed the prepare call. |
| `mandate_id` | The `mandate_id` of the mandate presented with the call. Absent when none was presented. |
| `checkout_id` | The checkout. |
| `ref` | The compact form `key_id/mandate_id/checkout_id`, with `-` for an absent mandate. At most 256 characters. It fits a payment reference or a metadata field. |

```
"agent_reference": {
  "key_id": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ",
  "mandate_id": "mnd_2026_12_0042",
  "checkout_id": "co_7f3a91",
  "ref": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ/mnd_2026_12_0042/co_7f3a91"
}
```

- Every checkout answer, its `order` and every webhook event **must** carry `agent_reference`. The shop sets it once and never changes it.
- The shop **must** persist it with the order and carry it through to settlement and reconciliation: the order record, the receipt or invoice metadata, the payment reference or metadata field at the PSP, settlement and payout reports, refunds and chargebacks, the audit log and every export. A system that cannot hold a structured value keeps `ref`.
- It holds no secret and no personal data. It is the same on a replayed idempotent answer.

## Webhooks

Webhooks are optional (`webhooks: true` in discovery). The agent gives a `webhook` object in `POST /checkout/prepare`: an HTTPS `url` and the `events` it wants: `checkout.confirmed`, `checkout.expired`, `checkout.cancelled`, `checkout.failed`. The body is the event envelope `WebhookEvent` of [`rest.schema.json`](https://agentictradestandard.org/schemas/rest.schema.json) with the checkout resource.

- The shop MUST sign each delivery with RFC 9421 using a key from its `jwks_uri`: covered `@method`, `@target-uri`, `content-type`, `content-digest`, `sacp-webhook-id`; `tag="sacp-webhook-1"`; the same 300 second window. The receiver MUST verify the signature and the digest before it reads the body.
- Delivery is at least once. `SACP-Webhook-Id` equals the event `id`. The receiver MUST deduplicate on it and MUST answer 2xx within 10 seconds. Order is not guaranteed: compare `created` or read the checkout with GET.
- Retries: after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then stop. A 4xx answer other than 408, 425 and 429 ends the retries.
- SSRF defence: the shop MUST accept only `https` URLs, MUST NOT follow redirects, MUST resolve the host and refuse private, loopback and link-local addresses, and MUST NOT send cookies or credentials. The payload carries no personal data.

## Security considerations

| Threat | Defence in this profile |
|---|---|
| Replay of a signed request | Signature window of 300 seconds, a nonce remembered per key, an idempotency key, and a checkout that commits at most once. |
| Price or terms change after approval | `terms_hash` binding, a re-quote at confirm, `ETag` with `If-Match`, and a tolerance that defaults to zero. |
| An agent acting outside its mandate | The signing key thumbprint must equal `agent.key_thumbprint` in the mandate. The mandate and approvals are checked against the exact terms hash at confirm, and the mandate status is read fresh. |
| A stolen or leaked key | Short signature lifetime, key removal from the directory, mandate revocation, and per-agent rate limits and alerts. |
| Enumeration of checkouts | Unguessable ids bound to the creating agent. 404 for a foreign id. |
| Webhook abuse (SSRF) | HTTPS only, no redirects, address checks, no credentials, signed deliveries. |
| Oversized or malformed input | 1 MiB body limit, strict schemas, 413, 415 and 422 answers, rate limits per agent. |
| Cross-site calls from a browser | No wildcard CORS on checkout endpoints. Signatures are not available to page scripts. |
| A downgrade to a weaker scheme | Shared-secret MACs are not accepted. The shop advertises the algorithms it allows and rejects the rest with 401 `signature_invalid`. |

## Privacy and data minimisation

- A shopping call carries no personal data. Destination is a country and, only when the carrier needs it, a postcode. No name, street, phone number or email address is sent in the agent lane.
- The person gives name, address and payment details to the merchant on the handoff page. They never pass through the agent or this API.
- The handoff URL MUST NOT contain personal data. Webhook payloads and error bodies carry none either. Logs of agent calls SHOULD hold the agent id, the phase, the status and the `trace_id`, and no request bodies from checkout calls.
- Stored idempotency answers are kept for the retention time only (24 hours to 30 days) and then deleted. The audit trail of the [authority layer](https://agentictradestandard.org/authority/) follows its own retention.

## Conformance levels

A shop declares one level in `extensions.rest.level`. A higher level includes every requirement of the lower one. The keywords are those of RFC 2119 and RFC 8174. The numbers in this profile (a 300 second signature window, 60 seconds of skew, 24 hours to 30 days of idempotency retention, a 1 MiB body, 12 months of deprecation notice, the webhook retry schedule, 10 minute cursors) are **draft defaults, open for feedback**: send comments to info@linespotting.com.

| Level | For | In short |
|---|---|---|
| `rest-core` | Shopping: discovery, catalog, shipping, negotiation, collection | TLS, versioning, problem+json, formats, pagination, rate limits, agent identification |
| `rest-checkout` | Checkout with human handoff | Adds signatures, idempotency, ETag and If-Match, the checkout resource, terms re-check at confirm |
| `rest-enterprise` | Organizations with mandates and audit, and optional autonomous checkout | Adds signatures or mutual TLS on every call, signed webhooks, key rotation rules, audit ids, and the optional confirm call |

| Id | Level | Keyword | Requirement |
|---|---|---|---|
| `T-1` | core | MUST | HTTPS with TLS 1.2 or later on every endpoint. TLS 1.3 SHOULD be offered. |
| `T-2` | core | MUST | Send HSTS with max-age of at least 31536000 on the API host. |
| `T-3` | core | MUST | Accept and send UTF-8 application/json. Answer 415 and 413 as specified. |
| `T-4` | core | MUST NOT | Answer checkout endpoints with wildcard CORS. |
| `V-1` | core | MUST | Put the major version in the base path. |
| `V-2` | core | MUST | Answer 400 version_unsupported for an unserved SACP-Version. SHOULD send SACP-Version in answers. |
| `V-3` | core | MUST | Mark deprecated operations with Deprecation and Sunset and keep them 12 months after announcement once the major version is final. |
| `E-1` | core | MUST | Return errors as application/problem+json with type, title, status and a registry code. |
| `E-2` | core | MUST NOT | Put personal data, secrets or stack traces in detail. |
| `E-3` | core | SHOULD | Include trace_id in every error. |
| `F-1` | core | MUST | Money as an object with a decimal string amount and an ISO 4217 currency. No JSON numbers for money. |
| `F-2` | core | MUST | Timestamps in RFC 3339 UTC with Z. Dates as YYYY-MM-DD. Countries as ISO 3166-1 alpha-2. |
| `P-1` | core | MUST | Paginate lists with limit and an opaque cursor. Default 20, maximum 100. next_cursor is null on the last page. Cursors live at least 10 minutes. |
| `R-1` | core | MUST | Answer 429 rate_limited with Retry-After in seconds. SHOULD send RateLimit-Policy and RateLimit. |
| `A-1` | core | MUST | Require the agent lane declaration (agent id and phase) as in 1.2.0, and label requests by phase. |
| `A-2` | core | MUST | Verify a signature that is present on a shopping call, and reject a bad one. |
| `S-1` | checkout | MUST | Require an RFC 9421 signature or mutual TLS on every checkout-phase call. |
| `S-2` | checkout | MUST | Check that the covered components include the minimum set and that Content-Digest matches the body bytes. |
| `S-3` | checkout | MUST | Reject a signature with expires minus created above 300 seconds, or outside 60 seconds of skew. |
| `S-4` | checkout | MUST | Remember nonces per key until expires plus skew and answer 401 replay_detected for a repeat. |
| `S-5` | checkout | MUST NOT | Accept shared-secret MACs for agent requests. Allowed: ed25519, ecdsa-p256-sha256. |
| `S-6` | checkout | MUST | Bind the key to the SACP-Agent-Id, and to agent.key_thumbprint when a mandate is presented. |
| `I-1` | checkout | MUST | Enforce Idempotency-Key on collection/items, prepare, confirm and cancel. |
| `I-2` | checkout | MUST | Replay the stored answer for the same key and request. 422 for a different request. 409 while running. Keep 24 hours to 30 days. |
| `I-3` | checkout | MUST | Scope the key to the agent identity, not to the IP address. |
| `C-1` | checkout | MUST | Send a strong ETag on checkout answers. Require If-Match on confirm: 428 if missing, 412 if stale. |
| `C-2` | checkout | MUST | Re-quote at confirm and compare with terms_hash. 409 terms_changed outside the tolerance. |
| `C-3` | checkout | MUST | Commit at most once per checkout and never after expires_at. Never change price, tax or shipping silently. |
| `C-4` | checkout | MUST | Make checkout_id unguessable and bound to the creating agent. Answer 404 for a foreign id. |
| `C-5` | checkout | MUST | Put agent_reference on every checkout answer, order and webhook event, and keep it unchanged through settlement and reconciliation. |
| `W-1` | checkout | MUST | If webhooks are offered: sign each delivery, https only, no redirects, address checks, retry schedule, event id for deduplication. |
| `X-1` | enterprise | MUST | Require a signature or mutual TLS on every call, shopping included. |
| `X-2` | enterprise | MUST | Offer signed webhooks, and keep a replaced key in the directory for at least max_validity_seconds plus retention. |
| `X-3` | enterprise | MUST | Return audit_event_id on confirm when a mandate was checked, and check mandate status fresh. |
| `X-5` | enterprise | MAY | Offer autonomous checkout and POST /checkout/{checkout_id}/confirm. If offered, advertise checkout.autonomous, require a mandate that covers the exact terms, and otherwise answer 403 autonomous_not_offered. |
| `X-6` | enterprise | MAY | Accept standing mandates (authority.standing). Inside the policy, autonomous checkout needs no per-checkout approval. Outside it, answer 403 authority_denied with outside_standing_policy. |
| `X-4` | enterprise | SHOULD | Offer mutual TLS with a certificate bound to the agent key. |

## Examples

The values are examples. Hosts end in `.example` or `.example.se`. The signatures are real (they verify with the public key in the file) but the keys belong to no one.

### 1. Prepare a checkout (human handoff), signed

```
POST /wp-json/agent-commerce/v1/checkout/prepare HTTP/1.1
Host: shop.example.se
Content-Type: application/json
SACP-Agent-Id: agent:buyer-agent-7
SACP-Agent-Phase: checkout
SACP-Checkout-Mode: human_handoff
Idempotency-Key: "8e03978e-40d5-43e8-bc93-6894a57f9324"
Content-Digest: sha-256=:j3I/t+GrGfzTpIkdEmGSAE3bmjZs/2FZem/zZ2DZdGQ=:
Signature-Input: sacp1=("@method" "@target-uri" "content-type" "content-digest" "sacp-agent-id" "idempotency-key");created=1796374870;expires=1796375170;nonce="n-5f1c0a77d2b94e3a";keyid="dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ";alg="ed25519";tag="sacp-1"
Signature: sacp1=:GkCJ0X9+RJdd1hGrG3jAicurPKg4rnr+RPY38IQuIgHO3VGjmZmKoaW9cuDYNZibPtP44bGiAEr2uHNTDSRyAQ==:

{
  "agent": {
    "id": "agent:buyer-agent-7",
    "name": "Example Buyer Agent",
    "agent_phase": "checkout",
    "checkout_mode": "human_handoff"
  },
  "collection_id": "col_31c8",
  "items": [
    {
      "id": "sku-1042",
      "qty": 1
    }
  ],
  "shipping": {
    "method": "home-delivery",
    "destination": {
      "country": "SE"
    }
  },
  "payment_handoff": "swish",
  "approved_terms": {
    "snapshot": {
      "sacp_terms_version": "1.1",
      "quote_id": "q_8f3a2c71",
      "merchant": {
        "id": "shop.example.se",
        "name": "Example Shop AB",
        "origin": "https://shop.example.se"
      },
      "items": [
        {
          "id": "sku-1042",
          "name": "Trail running shoes, size 43",
          "qty": 1,
          "unit_price": "1290.00",
          "line_total": "1290.00",
          "availability": "in_stock"
        }
      ],
      "currency": "SEK",
      "subtotal": "1290.00",
      "taxes": [
        {
          "type": "vat",
          "rate": "0.25",
          "amount": "269.80",
          "included": true
        }
      ],
      "shipping": {
        "method": "home-delivery",
        "carrier": "Example Carrier",
        "cost": "59.00",
        "eta_date": "2026-12-09",
        "destination": {
          "country": "SE"
        }
      },
      "total": "1349.00",
      "valid_from": "2026-12-04T09:00:00Z",
      "valid_until": "2026-12-04T09:15:00Z",
      "tolerance": {
        "price_increase_max_percent": "0",
        "price_increase_max_amount": "0.00",
        "shipping_cost_increase_max": "0.00",
        "eta_delay_max_days": 0,
        "total_increase_max": "0.00"
      }
    },
    "terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb"
  },
  "webhook": {
    "url": "https://agent.example/hooks/sacp",
    "events": [
      "checkout.confirmed",
      "checkout.expired"
    ]
  }
}

(The Content-Digest is over the compact form of this body. The exact bytes are in /files/example-signed-request.json.)
```

```
HTTP/1.1 200 OK
Content-Type: application/json
ETag: "co_7f3a91-1"
SACP-Version: 1.3
RateLimit-Policy: "checkout";q=10;w=60
RateLimit: "checkout";r=9;t=58

{
  "checkout_id": "co_7f3a91",
  "status": "awaiting_human",
  "created_at": "2026-12-04T09:01:12Z",
  "expires_at": "2026-12-04T09:15:00Z",
  "terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb",
  "handoff": {
    "type": "swish",
    "url": "https://shop.example.se/pay/co_7f3a91",
    "expires_at": "2026-12-04T09:15:00Z"
  },
  "terms_check": {
    "status": "match",
    "terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb"
  },
  "agent_reference": {
    "key_id": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ",
    "checkout_id": "co_7f3a91",
    "ref": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ/-/co_7f3a91"
  }
}
```

### 2. Search with a cursor

```
POST /wp-json/agent-commerce/v1/catalog/search HTTP/1.1
Host: shop.example.se
Content-Type: application/json
SACP-Agent-Id: agent:buyer-agent-7
SACP-Agent-Phase: shopping

{
  "agent": {
    "id": "agent:buyer-agent-7",
    "name": "Example Buyer Agent",
    "agent_phase": "shopping",
    "checkout_mode": "human_handoff"
  },
  "query": "trail running shoes",
  "max_price": {
    "amount": "1500.00",
    "currency": "SEK"
  },
  "limit": 2
}
```

```
HTTP/1.1 200 OK
Content-Type: application/json
SACP-Version: 1.3
RateLimit-Policy: "shopping";q=60;w=60
RateLimit: "shopping";r=58;t=41

{
  "items": [
    {
      "id": "sku-1042",
      "name": "Trail running shoes, size 43",
      "gtin": "7350012345678",
      "price": {
        "amount": "1290.00",
        "currency": "SEK"
      },
      "availability": "in_stock",
      "url": "https://shop.example.se/p/sku-1042"
    },
    {
      "id": "sku-2210",
      "name": "Trail running shoes, size 43, wide",
      "price": {
        "amount": "1390.00",
        "currency": "SEK"
      },
      "availability": "preorder"
    }
  ],
  "next_cursor": "eyJvIjoyfQ"
}
```

### 3. Confirm after the price rose (409)

```
POST /wp-json/agent-commerce/v1/checkout/co_7f3a91/confirm HTTP/1.1
Host: shop.example.se
Content-Type: application/json
If-Match: "co_7f3a91-1"
Idempotency-Key: "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed"
SACP-Agent-Id: agent:buyer-agent-7
SACP-Agent-Phase: checkout
SACP-Checkout-Mode: autonomous
Signature-Input: sacp1=(…);tag="sacp-1"
Signature: sacp1=:…:

{
  "agent": {
    "id": "agent:buyer-agent-7",
    "name": "Example Buyer Agent",
    "agent_phase": "checkout",
    "checkout_mode": "autonomous"
  },
  "terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb",
  "authority": {
    "mandate_ref": "https://authority.example.org/mandates/mnd_2026_12_0042"
  }
}
```

```
HTTP/1.1 409 Conflict
Content-Type: application/problem+json

{
  "type": "https://agentictradestandard.org/api/#err-terms_changed",
  "title": "Terms changed",
  "status": 409,
  "code": "terms_changed",
  "detail": "The unit price rose from 1290.00 to 1390.00 SEK. The approval no longer covers the offer.",
  "retryable": false,
  "approved_terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb",
  "current_terms_hash": "sha256:04a669ab1d22ffccdd4bc5e6e2a4b997a72b38c8a7ab46b45f4ed627a435af7b",
  "within_tolerance": false,
  "reconfirm_required": true,
  "diff": [
    {
      "path": "items[0].unit_price",
      "approved": "1290.00",
      "current": "1390.00",
      "change": "increase",
      "material": true
    },
    {
      "path": "total",
      "approved": "1349.00",
      "current": "1449.00",
      "change": "increase",
      "material": true
    }
  ],
  "current_terms": {
    "sacp_terms_version": "1.1",
    "quote_id": "q_8f3a2c71",
    "merchant": {
      "id": "shop.example.se",
      "name": "Example Shop AB",
      "origin": "https://shop.example.se"
    },
    "items": [
      {
        "id": "sku-1042",
        "name": "Trail running shoes, size 43",
        "qty": 1,
        "unit_price": "1390.00",
        "line_total": "1390.00",
        "availability": "in_stock"
      }
    ],
    "currency": "SEK",
    "subtotal": "1390.00",
    "taxes": [
      {
        "type": "vat",
        "rate": "0.25",
        "amount": "289.80",
        "included": true
      }
    ],
    "shipping": {
      "method": "home-delivery",
      "carrier": "Example Carrier",
      "cost": "59.00",
      "eta_date": "2026-12-09",
      "destination": {
        "country": "SE"
      }
    },
    "total": "1449.00",
    "valid_from": "2026-12-04T09:00:00Z",
    "valid_until": "2026-12-04T09:15:00Z",
    "tolerance": {
      "price_increase_max_percent": "0",
      "price_increase_max_amount": "0.00",
      "shipping_cost_increase_max": "0.00",
      "eta_delay_max_days": 0,
      "total_increase_max": "0.00"
    }
  }
}
```

### 4. Confirm with a stale ETag (412)

```
HTTP/1.1 412 Precondition Failed
Content-Type: application/problem+json

{
  "type": "https://agentictradestandard.org/api/#err-precondition_failed",
  "title": "Precondition failed",
  "status": 412,
  "code": "precondition_failed",
  "detail": "The checkout changed after it was read. Read it again with GET /checkout/co_7f3a91.",
  "instance": "/checkout/co_7f3a91/confirm",
  "retryable": false
}
```

### 5. A retry and a reused key

```
# Same Idempotency-Key, same body, after a lost answer:
HTTP/1.1 200 OK
Idempotent-Replayed: true
Content-Type: application/json

(the stored answer of the first call, byte for byte)

# Same Idempotency-Key, different body:
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json

{
  "type": "https://agentictradestandard.org/api/#err-idempotency_key_reuse",
  "title": "Idempotency-Key reused",
  "status": 422,
  "code": "idempotency_key_reuse",
  "detail": "This key was used with a different request.",
  "retryable": false
}
```

### 6. Rate limited (429)

```
HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json
Retry-After: 30
RateLimit-Policy: "shopping";q=60;w=60
RateLimit: "shopping";r=0;t=30

{
  "type": "https://agentictradestandard.org/api/#err-rate_limited",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "retryable": true,
  "agent_phase": "shopping",
  "retry_after_seconds": 30
}
```

### 7. A webhook delivery

```
POST /hooks/sacp HTTP/1.1
Host: agent.example
Content-Type: application/json
SACP-Webhook-Id: evt_01je5q7m2k
Content-Digest: sha-256=:GIjHKB6MJeyIhBhZzXulQPn+9tUxBVjoePRPaV9RBvE=:
Signature-Input: sacpwh=("@method" "@target-uri" "content-type" "content-digest" "sacp-webhook-id");created=1796375262;expires=1796375562;nonce="w-91d03be4c7a8";keyid="wUnyhuKK3awE7ycENiuc4yzof6zFazcQ4V0pPSa8NLc";alg="ed25519";tag="sacp-webhook-1"
Signature: sacpwh=:KJGBvPCfASnL2ZgnBUNSzkqZnaSEX0QQD5HulDouZg9RboorQ9FNM3BtZxJYPbw5z8omjrhJnZG0PbStK5LsCA==:

{
  "id": "evt_01je5q7m2k",
  "type": "checkout.confirmed",
  "created": "2026-12-04T09:07:42Z",
  "checkout_id": "co_7f3a91",
  "agent_reference": {
    "key_id": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ",
    "mandate_id": "mnd_2026_12_0042",
    "checkout_id": "co_7f3a91",
    "ref": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ/mnd_2026_12_0042/co_7f3a91"
  },
  "data": {
    "checkout": {
      "checkout_id": "co_7f3a91",
      "status": "confirmed",
      "created_at": "2026-12-04T09:01:12Z",
      "expires_at": "2026-12-04T09:15:00Z",
      "terms_hash": "sha256:8042bb8bd734bf15b1437a5630335263b0f6494700f4d92ef461049c1235f1fb",
      "order": {
        "order_id": "ord_5521",
        "confirmed_at": "2026-12-04T09:07:41Z",
        "agent_reference": {
          "key_id": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ",
          "mandate_id": "mnd_2026_12_0042",
          "checkout_id": "co_7f3a91",
          "ref": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ/mnd_2026_12_0042/co_7f3a91"
        }
      },
      "authority_check": {
        "status": "covered",
        "mandate_id": "mnd_2026_12_0042",
        "level": "consumer",
        "approvals_verified": [
          "apr_2026_12_9917"
        ],
        "audit_event_id": "aud_88123"
      },
      "agent_reference": {
        "key_id": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ",
        "mandate_id": "mnd_2026_12_0042",
        "checkout_id": "co_7f3a91",
        "ref": "dRkgvMoKa5Kry4nJd8QjnqBSOxvTzyWiXd9NVAFLYRQ/mnd_2026_12_0042/co_7f3a91"
      }
    }
  }
}

(The Content-Digest is over the compact form. See /files/example-signed-webhook.json.)
```

### 8. Discovery with the REST profile

```
{
  "capabilities": [
    "catalog.search",
    "catalog.product",
    "shipping.quote",
    "negotiation.offer",
    "collection.items",
    "checkout.handoff",
    "checkout.status",
    "terms.binding",
    "authority.mandate",
    "agent.lane",
    "rest.profile"
  ],
  "endpoints": {
    "catalog_search": "/wp-json/agent-commerce/v1/catalog/search",
    "catalog_product": "/wp-json/agent-commerce/v1/catalog/product/{id}",
    "shipping_quote": "/wp-json/agent-commerce/v1/shipping/quote",
    "negotiation_offer": "/wp-json/agent-commerce/v1/negotiation/offer",
    "collection_items": "/wp-json/agent-commerce/v1/collection/items",
    "checkout_prepare": "/wp-json/agent-commerce/v1/checkout/prepare",
    "checkout_status": "/wp-json/agent-commerce/v1/checkout/{checkout_id}",
    "checkout_cancel": "/wp-json/agent-commerce/v1/checkout/{checkout_id}/cancel",
    "jwks": "/.well-known/jwks.json"
  },
  "extensions": {
    "rest": {
      "profile": "1.3",
      "level": "rest-checkout",
      "versions": [
        "1"
      ],
      "openapi": "https://agentictradestandard.org/openapi.json",
      "jwks_uri": "/.well-known/jwks.json",
      "signature": {
        "algorithms": [
          "ed25519",
          "ecdsa-p256-sha256"
        ],
        "required_for": [
          "checkout"
        ],
        "max_clock_skew_seconds": 60,
        "max_validity_seconds": 300,
        "mtls": false
      },
      "idempotency": {
        "retention_seconds": 86400
      },
      "pagination": {
        "default_limit": 20,
        "max_limit": 100
      },
      "max_body_bytes": 1048576,
      "webhooks": true
    }
  }
}
```

## Machine-readable files

- [`/openapi.yaml`](https://agentictradestandard.org/openapi.yaml) and [`/openapi.json`](https://agentictradestandard.org/openapi.json): OpenAPI 3.1. The older name [`/openapi/sacp-v1.yaml`](https://agentictradestandard.org/openapi/sacp-v1.yaml) serves the same document.
- [`rest.schema.json`](https://agentictradestandard.org/schemas/rest.schema.json), [`problem.schema.json`](https://agentictradestandard.org/schemas/problem.schema.json), [`discovery.schema.json`](https://agentictradestandard.org/schemas/discovery.schema.json): JSON Schema 2020-12.
- [`/files/sacp-error-registry.json`](https://agentictradestandard.org/files/sacp-error-registry.json): the error code registry.
- [`/files/example-signed-request.json`](https://agentictradestandard.org/files/example-signed-request.json) and [`/files/example-signed-webhook.json`](https://agentictradestandard.org/files/example-signed-webhook.json): signature test vectors.
- The OpenAPI document passes `redocly lint` with the recommended rules and no warnings, and its examples validate against the schemas.

## Questions

### How does an agent authenticate to a SACP shop?

With HTTP Message Signatures (RFC 9421) or mutual TLS. Every checkout call is signed over the method, the target URI, the body digest, the agent id and the idempotency key, with a window of at most 300 seconds and a one-time nonce. The key thumbprint must match the mandate. A valid signature identifies the agent. It is never authority to commit.

### How does SACP stop a retry from buying twice?

Every state-changing POST carries an Idempotency-Key. The shop stores the first answer and returns it again, with Idempotent-Replayed: true, for the same key and request. A different request with the same key gets 422 idempotency_key_reuse, and a request that is still running gets 409 idempotency_in_progress. A checkout also commits at most once.

### What error format does SACP use?

RFC 9457 problem+json. Every error has type, title, status and a stable code from the SACP error registry, for example terms_changed, approval_required, rate_limited or precondition_failed. The type is a URL on this site that explains the code. The registry is at /api/#error-registry and /files/sacp-error-registry.json.

### What happens if the price changes between prepare and confirm?

Two checks run. If-Match with the checkout ETag catches a checkout that changed after it was read (412 precondition_failed). The terms_hash in the confirm body is compared with a fresh quote and catches a changed price (409 terms_changed with a diff). Under the default tolerance of zero any price increase is material, and nothing is committed.

### Is there an OpenAPI document for SACP?

Yes. SACP 1.3.0-draft publishes an OpenAPI 3.1 document at /openapi.yaml and /openapi.json with request and response schemas, security schemes, error responses, and webhooks. It passes redocly lint with no warnings. The human-readable REST profile is at /api/.

### What are the SACP REST conformance levels?

rest-core is shopping: TLS, versioning, problem+json, formats, pagination and rate limits. rest-checkout adds signatures, idempotency, ETag with If-Match, the checkout resource and the terms re-check at confirm. rest-enterprise adds signatures or mutual TLS on every call, signed webhooks, key rotation rules, audit ids and the optional autonomous confirm call. A shop declares its level in extensions.rest.level.

### What is the SACP agent reference and why must a shop keep it?

The agent reference is key_id, mandate_id and checkout_id, plus a compact ref string. Every checkout answer, order and webhook event must carry it, and the shop must persist it through settlement and reconciliation. It lets a merchant, a PSP or an auditor tie an order to the exact agent key and mandate.
