Skip to main content
By the end of this page you’ll have run the whole Purchase API loop against a real merchant: a real conversation, a real cart with an exact total and a hash, and the hash-bound confirm. The one thing sandbox refuses to do is the money: the final confirm comes back declined by design, because sandbox test cards can never pay a real merchant. That refusal is the last lesson of this page, and it’s the only difference from production, where the same confirm places the order.

Prerequisites

  • A sandbox API key (sk_test_) from the dashboard Credentials page
  • curl, Node 18+, or Python 3.8+ with requests, whichever you prefer
1

Create a cardholder

A cardholder is the end user your agent buys for. In sandbox you can invent one:
The API returns the new cardholder. Save the id; the next step needs it.
Output
2

Mint a buy token

The buy token is the bearer your agent uses. It lasts 30 days and only works as this one user:
The token comes back with its expiry:
Output
If you’re following along in a shell, export it so the next calls can use it:
3

Ask for something

Send the request in plain language. The agent searches the merchant, may ask you to choose between options, and stops each turn at needs_input until it has enough to build a cart:
The first turn usually asks a question. Yours will differ; sandbox conversations are live, not scripted:
Output
Answer by sending your reply back with the conversation_id:
Keep going until the response carries a cart with a totalCents and a hash. That’s the agent showing you the exact price before anything happens:
Output
4

Confirm, and watch sandbox stop the money

Send the cart’s hash back as confirm. Echoing the hash, not the word “yes”, is what authorizes exactly this cart at exactly this price:
The hash verifies, the confirm gate passes, and then sandbox refuses the one thing it exists to refuse. Before any money is reserved or any card is created, the checkout denies with the sandbox wall:
Output
That declined is the finish line, not a failure. You exercised the entire conversational contract: an ask, a follow-up, a cart with an exact total, and a hash-bound confirm that verified before anything moved. On a production connection, this exact same call is the one that places the order and returns the receipt.

What you just exercised

Everything up to the money: a conversation that built a real cart at a real merchant, a total shown before any charge, and a hash-bound confirmation that authorized exactly that cart. Sandbox stops at the payment on purpose, because its test cards can never charge a real merchant, so no sandbox call can ever place an order. In production the same confirm reserves against the user’s budget, issues a one-time card, pays the merchant, and returns the receipt.

Where to go next

  • Purchase API: the full envelope, multi-merchant confirms, and the payment layer.
  • POST /buy reference: the exact request and response contract.
  • Test in sandbox: every sandbox knob, from test cards and simulated KYC to test_charge and webhook rehearsal.