Skip to main content
Send Agentcard a product from the Channel3 catalog, or the store’s own product page, and the person it is for. Agentcard builds the cart at the store, reads the store’s own total, and opens the person’s approval of that total in their Vault. Once they approve, Agentcard places the order with their own card.
Catalog purchases are in beta. A field can still change before the API is final.

Check what you need

  • Your company’s client_id and client_secret, exchanged for an access token. Agentcard refuses an API key when you create, answer or cancel a purchase. Your company’s API key reads a purchase too.
  • The person connected to your app with a card in their Vault. See Adding a card.
  • Catalog purchases turned on for your company. Ask Agentcard to turn them on.
  • Commerce billing set up in the dashboard, for live purchases.

Create a purchase

Name the catalog, the person, and the product, with an Idempotency-Key you keep when you retry the same purchase. The answer comes back at once, with the purchase building its cart:
Send an Idempotency-Key header with each create. A retry with the same body, the same credentials and the same mode within 24 hours gets the first answer back instead of making another purchase. Agentcard keeps refusals too, so use a new key once you correct the body: Agentcard refuses the same key with a changed body as idempotency_key_reused. Agentcard refuses a retry while the first request still runs as idempotency_key_in_flight; wait, and retry with the same key. After 24 hours the key expires, and reusing it can make another purchase.

Buy several products

Send catalog.items instead of url to name products by their catalog id, each with the store that sells it:
One purchase buys at one store. At a store Agentcard orders from directly, one purchase holds up to 10 products. At a store whose own checkout page Agentcard fills in, one purchase holds one product. A product_id with no store buys the cheapest offer in stock at a store Agentcard can order from.

Follow the purchase

Read where the purchase stands at any time:

Answer the store

A purchase in needs_input carries the store’s question in input. Here the size the person chose sold out, and the store still has two others:
Send the answer, and the purchase builds its cart again:
A delivery address names the street, the city, a two-letter state or province code, and a US ZIP or ZIP+4 or a Canadian postal code. The name, a second address line, a two-letter country code and the phone are optional:
delivery_address on the create takes the same fields. A card question for a sandbox person carries no input.url, because the add-a-card link is a live one. Open a Vault session for them with POST /api/v2/vault_sessions, as Adding a card shows, and send {} once they saved a card. Agentcard refuses an answer that leaves out what the store asked, and the question stays open:
Send the answer again with the option the message names:
A question waits 30 minutes for its answer. After that the purchase ends expired. A purchase in awaiting_approval carries the cart, the store’s total, and the approval link:
Send the person approvalUrl right away. They see the store and the total, and approve with their passkey. approval_expires_at says when the link stops working; after that the purchase ends expired. When the store may authorize more than its total, amount is that larger figure and cart.total_cents is what the person pays.

Hear each step

Subscribe your webhook endpoint to purchase.message or purchase.* in the purchase’s mode. A catch-all * alone does not turn these messages on. Agentcard tells your company about each step as a purchase.message event. The step is in the event’s data: data.facts.authorization_id names the purchase, and data.text is ready to send to the person as it is:
data.note is the same step written for your own agent to read. Drop an event that arrives after its data.facts.valid_until: its link no longer works.

Cancel a purchase

Cancel a purchase the person has not approved yet:
The purchase ends cancelled, and an approval link already sent stops working. Once the person approved, or the purchase ended, Agentcard refuses the cancel and the purchase goes on as it stands:
A purchase at a store Agentcard orders from directly stops being cancellable once its cart is built, while it still reads building_cart, because the store can take the order at once. Agentcard refuses that cancel too, and the purchase goes on to its order:

Test in sandbox

Your sandbox credentials make sandbox purchases. Agentcard builds the cart at the store and the approval opens as it does live, and after the person approves the purchase ends approved with no order placed and nothing charged. Stores Agentcard orders from directly take live purchases only. A sandbox credential never reads, cancels or answers a live purchase.

Fix a refusal

A create that Agentcard refuses makes nothing. Each refusal names what to change:
Add the catalog and send the create again, with a new Idempotency-Key:

Know the limits

  • One purchase buys at one store, with one product at a store whose checkout page Agentcard fills in.
  • A purchase never takes an amount: the amount is always the store’s own total.
  • A cart that takes long to build leaves the person less time to approve. approval_expires_at always says how long.