Skip to main content
A transaction ties one merchant checkout to one of the buyer’s saved cards. Your agent sends the checkout, Sapiom opens it with the merchant and checks it against your rules, and each result says what to do next. Before you start:

Where each step runs

Your backend stores each buyer’s key and passes it to the agent and the browser worker for that buyer’s session.

Request the transaction

  • checkout is a UCP checkout request. item.id is the merchant’s product ID; the line id is your own label.
  • paymentMethodId is the id of the buyer’s chosen card.
  • idempotencyKey is your own unique ID for this transaction. See below.
The result includes a transactionId. Save it: every later step uses it. All arguments are in the MCP tools reference. Calling Sapiom from your backend instead? See Use REST instead.

Keep the same idempotency key

The key identifies this transaction. If a request times out or you lose the response, send the identical request with the same key to pick it back up. Don’t switch to a new key to get past an uncertain result: that can buy twice.

Follow nextAction

Every result has a nextAction object. Its type says what to do. Act on it, then read the transaction with sapiom_get_transaction to get the next one.

Change or cancel a transaction

  • Change: sapiom_update_transaction replaces the whole checkout. Send transactionId, the latest version, a new stable idempotencyKey for this change, and the full checkout. Changing items or the total can mean the buyer approves again.
  • Cancel: sapiom_cancel_transaction with transactionId and an idempotencyKey. It cannot stop a checkout that is already completing, and it does not refund an order.

Use REST instead

Your backend can run the same transaction with the buyer’s key.
  1. Create a transaction. estimate is your expected total and is optional. Omit paymentCardId to use the buyer’s default card.
  2. Open the checkout with POST /v1/transactions/{id}/ucp/checkout, sending the UCP line_items and buyer. If you sent shipping when you created the transaction, leave out buyer.
  3. Read nextAction.action in each response. While it’s update, replace the checkout with PUT on the same path.
Both checkout calls take an Idempotency-Key header. REST names some actions differently from the MCP tools: wait, revise, blocked and closed have the same names.