> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sapiom.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Sapiom Pay is for platforms whose agent shops for many end users. Each end user is a buyer with their own Sapiom key and saved cards.
> Use the buyer's key for every call made on that buyer's behalf. Never use one buyer's key for another user, and never give the agent the platform key.
> Backends call the REST API at https://api.sapiom.ai/v1. Agents can also call the hosted MCP tools at https://api.sapiom.ai/v1/mcp/pay. Both take the key in an x-api-key header.
> Keys that start with sk_test_ reach the sandbox, a separate test environment with its own buyers and cards, at the same addresses. Use test card numbers only there.
> Never ask a buyer for a card number, expiry date or CVV in chat. Buyers enter card details only on Sapiom's hosted pages.
> Check the merchant before buying. Use purchase.type ucp_checkout only when the merchant check returns supported. Otherwise use browser_checkout.
> Follow the nextAction in each transaction result. Action links are secrets for the intended buyer only.
> Use one idempotency key per transaction. Resume an unanswered create with the same request and key. If a UCP update or cancellation is uncertain, stop and hand off to a person. If a browser cancellation is uncertain, read the transaction and resend the same cancellation, with the same key, only if it is not closed. Never start a new transaction to escape an uncertain outcome.
> For a ucp_checkout purchase, report an order as placed only when order.outcome is confirmed; if it is unknown, stop and hand off to a person. A browser_checkout purchase has no order confirmation (order is null): confirm the order on the merchant's page.

# Sapiom Pay MCP tools reference

Your agent calls these tools through the hosted MCP server at `https://api.sapiom.ai/v1/mcp/pay`, connected with the [buyer's key](https://docs.sapiom.ai/buyers/connect-agent.md). The server lists only the eight tools below. Call each by its full name. Argument names are case-sensitive.

| Tool | Purpose | Permission |
| - | - | - |
| `sapiom_check_transaction_compatibility` | Check a merchant | `org.transactions.read` |
| `sapiom_list_payment_methods` | List cards | `org.transactions.read` |
| `sapiom_add_payment_method` | Create a card setup link | `org.transactions.write` |
| `sapiom_delete_payment_method` | Remove a card | `org.transactions.write` |
| `sapiom_request_transaction` | Start or resume a transaction | `org.transactions.write` |
| `sapiom_get_transaction` | Read a transaction | `org.transactions.read` |
| `sapiom_update_transaction` | Replace a UCP transaction's checkout | `org.transactions.write` |
| `sapiom_cancel_transaction` | Cancel a transaction | `org.transactions.write` |

## sapiom\_check\_transaction\_compatibility

`{ "domain": "shop.example" }`. Takes a bare domain or HTTPS origin.

Returns `merchant`, `status`, `reason`, `protocol`, `capabilities: [{ name, supported }]`, `checkedAt`, `expiresAt` and `retryAfterSeconds`.

| `status` | `reason` |
| - | - |
| `supported` | `compatible_ucp_profile`. Use only capabilities marked `supported: true`. |
| `unsupported` | `no_manifest`, `no_compatible_version` or `no_checkout` |
| `unknown` | `timeout`, `fetch_failed`, `upstream_error` or `invalid_profile`. Honor `retryAfterSeconds`. |

## sapiom\_list\_payment\_methods

`{}`. Returns `{ data: [...] }`, newest first, with pending and active cards. Each card includes `id`, `status`, `brand`, `last4`, `expMonth`, `expYear`, `isDefault` and `readiness`. A card can pay when `status` is `active` and `readiness` is not `not_ready`. Card numbers are never returned.

## sapiom\_add\_payment\_method

`{ "returnUrl": "https://your-app.example/cards/done" }`. `returnUrl` is optional: HTTPS, or HTTP for localhost, up to 2,048 characters.

Returns `url` and `setupLink: { id, status, expiresAt }`, plus instructions in `nextStep`. `url` is returned only once. See [Vault a card](https://docs.sapiom.ai/cards/vault-a-card.md).

## sapiom\_delete\_payment\_method

`{ "cardId": "<uuid>" }`. Returns `{ cardId, status, message }`. Calling again with the same ID safely retries cleanup. Removal does not cancel or refund orders.

## sapiom\_request\_transaction

| Argument | Notes |
| - | - |
| `idempotencyKey` | Required, up to 200 characters. One per transaction. |
| `purchase` | What you buy, by `type`. `ucp_checkout`: `{ merchant: { origin }, checkout }`, the merchant's checkout create request with no payment data. `browser_checkout`: `{ merchant: { origin, name? }, total: { amount, currency: "USD" }, description?, claimedLineItems?, pageUrl? }`, for a page your agent completes. Same as `purchase` on [Create a transaction](https://docs.sapiom.ai/api-reference/transactions/create-a-transaction.md). |
| `merchantOrigin`, `checkout` | Older form of a UCP purchase, still accepted. Use `purchase`. |
| `paymentMethodId` | The card's `id`. Send this or `setupLinkId`. |
| `setupLinkId` | Open setup link ID. Returns `status: setup_required`, with `nextAction.type` `complete_payment_method_setup`, until setup completes. |
| `shipping` | Optional, `ucp_checkout` only. Where the order ships and how the merchant reaches the buyer. See [shipping](#shipping). |

Returns the transaction view. See [Authorize a transaction](https://docs.sapiom.ai/transactions/authorize.md).

### shipping

Send an `address`, a `contact`, or both. The fields match `shipping` on [Create a transaction](https://docs.sapiom.ai/api-reference/transactions/create-a-transaction.md).

```json theme={null}
{
  "address": {
    "first_name": "Jane",
    "last_name": "Buyer",
    "street_address": "1 Market St",
    "extended_address": "Suite 400",
    "address_locality": "San Francisco",
    "address_region": "CA",
    "postal_code": "94105",
    "address_country": "US"
  },
  "contact": {
    "email": "jane@example.com",
    "phone_number": "+14155550100"
  }
}
```

* `address` needs `street_address`, `address_locality` and `address_country` (two capital letters, such as `US`). The rest is optional.
* Leave out fields you don't have. `null` and unknown fields are refused.
* With no `address` and no contact `email` or `phone_number`, the call returns `invalid_input`.

Sapiom fills `shipping` into the checkout on create and on every update. Anything you set in `checkout` wins.

| From `shipping` | Into the checkout |
| - | - |
| `contact.email`, `contact.phone_number`, `address.first_name`, `address.last_name` | `buyer` |
| `address` | `fulfillment`: a shipping method to that address, for every line item |

## sapiom\_get\_transaction

`{ "transactionId": "<uuid>", "since": "<version>", "waitSeconds": 20 }`. `since` and `waitSeconds` (0 to 22, default 0) are optional. It reads stored state and never pays. The one exception: while a UCP order is completing (`wait` with reason `complete_in_progress`), it also asks the merchant whether the order completed.

## sapiom\_update\_transaction

`{ "transactionId", "version", "idempotencyKey", "checkout" }`. `checkout` replaces the whole checkout, so any field you leave out is dropped.

Build it from two sources: the line items, quantities and delivery choices in the latest `sapiom_get_transaction` result, and the buyer and merchant-specific fields from your last request, which that result leaves out. Apply your change and send the latest `version`. If the result shows someone else's change that conflicts with yours, ask the buyer first. After `stale_version`, read again, rebuild from both sources and use a new key.

Changing items, the amount or the delivery address can require the buyer to approve again and re-enter their CVV, even at the same total. If the update times out or reports `change_unconfirmed`, stop. Your team recovers it with the merchant, using the original request and key.

UCP only. A browser purchase returns `not_revisable`: cancel it, and once the cancellation is confirmed, request the revised purchase with a new key.

## sapiom\_cancel\_transaction

`{ "transactionId", "idempotencyKey" }`. Cancels an unfinished checkout. It cannot stop a completion in progress or refund a placed order. For a browser purchase, this cancels the card payment and contacts no merchant. After your agent pays, it returns `card_relayed`. Never pay or buy again for it.

If a UCP cancellation is uncertain, stop. Your team recovers it with the merchant, using the original request and key. If a browser cancellation times out or may not have been saved, read the transaction; if it is not closed, send the same cancellation with the same key.

## What transaction tools return

All four transaction tools return the same object. This one is ready for your browser worker to pay:

```json theme={null}
{
  "transactionId": "00000000-0000-4000-8000-000000000003",
  "version": "7:4:authorized",
  "checkout": {
    "merchantOrigin": "https://shop.example",
    "status": "ready_for_complete",
    "currency": "USD",
    "totals": [{ "type": "total", "amount": 2999 }],
    "lineItems": [
      { "id": "line-1", "itemId": "merchant-product-id", "title": "Notebook", "quantity": 1, "unitPriceMinor": 2999 }
    ],
    "fulfillmentMethods": [],
    "expiresAt": "2026-10-23T18:00:00.000Z",
    "revision": 2,
    "governed": true,
    "decision": "authorized",
    "reasons": []
  },
  "localSession": { "state": "open" },
  "payment": {
    "status": "authorized",
    "amount": "29.99",
    "paymentMethodId": "00000000-0000-4000-8000-000000000001",
    "denial": null
  },
  "order": { "outcome": "not_confirmed", "evidence": null, "observationSeq": 4 },
  "nextAction": {
    "type": "payment_ready",
    "actor": "agent",
    "continueUrl": "https://shop-example.myshopify.com/checkouts/abc123",
    "buyerMessages": []
  }
}
```

The merchant supplies `continueUrl`. Its host can be different from `checkout.merchantOrigin`, as in this example. Do not compare the two. See [Pay in the browser](https://docs.sapiom.ai/transactions/browser-pay#attach-browser-pay-then-fill-the-form).

A browser purchase has no `checkout`. `purchase` holds your agent's statement, and `order` is `null`.

`totals` and `unitPriceMinor` are in minor units (cents), while `payment.amount` is a decimal string. A `confirmed` order also carries `id`, `label`, `permalinkUrl` and `links` ([Show the order confirmation](https://docs.sapiom.ai/transactions/confirm-and-recover.md#show-the-order-confirmation)). Pass `version` as `since` on your next read. Other `nextAction` types are listed in [Authorize a transaction](https://docs.sapiom.ai/transactions/authorize.md#follow-nextaction).

## Spending-limit tools

These tools are on `https://api.sapiom.ai/v1/mcp`, not `/v1/mcp/pay`.
Your backend can also use the [spending-limit REST API](https://docs.sapiom.ai/controls/spending-limits.md).

> [!NOTE]
>
> These tools need a key that can manage limits, such as your [platform key](https://docs.sapiom.ai/api-reference/overview.md#authentication). Buyer keys can't call them, so an agent connected with a [buyer's key](https://docs.sapiom.ai/buyers/connect-agent.md) can't read or raise its own limits.

### sapiom\_get\_card\_spending\_limits

`{ "cardId": "<uuid>" }`. Returns the card's three limits, the saved `version`, and `usage`, which shows what the period and date-range limits have `used` and have `remaining`. Same as [Get spending limits](https://docs.sapiom.ai/api-reference/spending-limits/get-spending-limits.md).

### sapiom\_set\_card\_spending\_limits

`{ "cardId", "version", "purchaseLimit", "recurringLimit", "customLimit" }`. Replaces all three limits, so send `null` for any you don't want, with the `version` you read (`0` the first time). Same as [Set spending limits](https://docs.sapiom.ai/api-reference/spending-limits/set-spending-limits.md). See [Spending limits](https://docs.sapiom.ai/controls/spending-limits.md) for each limit's shape.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.