AgentHandel
SACP · 1.3.0-draft

Document 03 · OpenAPI 3.1.0

OpenAPI

Every SACP call with request and response schemas, security schemes, error responses and webhooks. Handoff names are Swish, IBAN, card, and crypto. The rules for people are in the REST profile.

Server template: https://{host}{basePath}. The defaults are shop.example.se and /wp-json/agent-commerce/v1.

Machine-readable copies: /openapi.yaml (application/yaml), /openapi.json (application/json) and the older name /openapi/sacp-v1.yaml (the same document, also at /files/sacp-v1.yaml). The rules for people are in the REST profile.

GET /.well-known/sacp

Discovery document. The capability document. On this documentation host the same JSON is also at /.well-known/sacp.json and /.well-known/agent-commerce. A shop that follows the REST profile advertises extensions.rest.

operationId: getDiscovery. Responses: 200, 400, 429, 500. Signature optional.

GET /.well-known/jwks.json

The public signing keys of the shop (JSON Web Key Set). They verify quote_signature and webhook signatures.

operationId: getJwks. Responses: 200, 429, 500. Signature optional.

POST /catalog/search

Search products. Request: query, max_price (a money object), limit and cursor. Response: items and next_cursor. A plain number as max_price is deprecated.

operationId: searchCatalog. Responses: 200, 400, 401, 422, 429, 500. Signature optional.

GET /catalog/product/{id}

Product details. id is a required path string. Response: the product with a money price and availability. Supports If-None-Match.

operationId: getProduct. Responses: 200, 304, 400, 401, 404, 429, 500. Signature optional.

POST /shipping/quote

Shipping quotes for items and a destination (country, and a postcode only when the carrier needs it). Response: shipping options with a money cost and an ETA date.

operationId: quoteShipping. Responses: 200, 400, 401, 422, 429, 500. Signature optional.

POST /negotiation/offer

Negotiate an offer. Response: accepted, countered or rejected, with a counter price. This call does not create an order.

operationId: negotiateOffer. Responses: 200, 400, 401, 422, 429, 500. Signature optional.

POST /collection/items

Collect items. Needs an Idempotency-Key. Response: a collection with current prices and a subtotal. This call does not create an order.

operationId: collectItems. Responses: 200, 400, 401, 422, 429, 500. Signature optional.

POST /checkout/prepare

Prepare the purchase handoff. Signed (RFC 9421) or over mutual TLS. Needs an Idempotency-Key. Creates a checkout resource. With human_handoff the status is awaiting_human and the answer has a handoff URL for Swish, IBAN, card, crypto, or another name the shop declares. With autonomous the status is ready_to_confirm. No card number. No private key. Optional approved_terms (approved terms: 409 terms_changed), authority (authority: 403, 428), agent and webhook. When the shop advertises agent.lane, agent_phase must be checkout (shopping and checkout).

operationId: prepareCheckout. Responses: 200, 400, 401, 403, 409, 422, 428, 429, 500. Signature or mutual TLS required.

GET /checkout/{checkout_id}

Read a checkout. The status, the current terms hash and, when it exists, the order. Returns a strong ETag, the value for If-Match on confirm. Supports If-None-Match. Signed.

operationId: getCheckout. Responses: 200, 304, 400, 401, 404, 410, 429, 500. Signature or mutual TLS required.

POST /checkout/{checkout_id}/confirm

Confirm an autonomous checkout and create an order. Only when the shop advertises checkout.autonomous. Needs If-Match and an Idempotency-Key. The body carries the terms_hash the agent commits to. The shop re-quotes: 412 for a stale checkout, 409 terms_changed for changed terms, 403 or 428 for the mandate. Nothing is confirmed unless every check passes. Signed.

operationId: confirmCheckout. Responses: 200, 400, 401, 403, 404, 409, 410, 412, 422, 428, 429, 500. Signature or mutual TLS required.

POST /checkout/{checkout_id}/cancel

Cancel a checkout that is not confirmed. Idempotent. Needs an Idempotency-Key. Signed.

operationId: cancelCheckout. Responses: 200, 400, 401, 404, 409, 410, 429, 500. Signature or mutual TLS required.

POST webhook (shop to agent)

The shop calls the webhook URL the agent gave in POST /checkout/prepare. Signed by the shop (RFC 9421, sacp-webhook-1). Events: checkout.confirmed, checkout.expired, checkout.cancelled, checkout.failed. See webhooks.

The merchant stays merchant of record. Payment authorization stays a human-in-the-loop handoff, except where a shop offers autonomous checkout under a mandate. Rendered from openapi/sacp-v1.yaml.