> ## 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 API overview

> Base URLs, keys, permissions and idempotency for the Sapiom Pay REST API, MCP tools and Browser Pay SDK.

Sapiom Pay has three surfaces. They share the same keys and data.

| Surface | Used by | Endpoint | Reference |
| - | - | - | - |
| REST API | Your backend | `https://api.sapiom.ai/v1` | [REST endpoints](#rest-endpoints) |
| MCP tools | Your agent | `https://api.sapiom.ai/v1/mcp/pay` | [MCP tools](https://docs.sapiom.ai/api-reference/mcp-tools.md) |
| Browser Pay SDK | Your browser worker | `npm install @sapiom/browser-pay` | [Browser Pay SDK](https://docs.sapiom.ai/api-reference/browser-pay-sdk.md) |

## Authentication

Send a key in the `x-api-key` header on every REST request and MCP connection:

```bash theme={null}
curl https://api.sapiom.ai/v1/payment-cards -H "x-api-key: $SAPIOM_BUYER_KEY"
```

| Key | Where it comes from | Use it for |
| - | - | - |
| Platform key | [Developers → API keys](https://docs.sapiom.ai/buyers/platform-keys.md) in the dashboard | Creating buyers and buyer keys. Keep it in your backend. |
| Buyer key | `POST /v1/tenants/{tenantId}/api-keys` | Everything you do for one user: cards, transactions and Browser Pay |

Every request made with a buyer key is limited to that buyer's cards and transactions. Keys are shown once, as `plainKey` in the creation response.

Production keys start with `sk_live_`. [Sandbox](https://docs.sapiom.ai/sandbox.md) keys start with `sk_test_` and use the same addresses.

Branding endpoints are the exception. They need a signed-in dashboard user. See [Brand hosted pages](https://docs.sapiom.ai/cards/brand-hosted-pages.md).

## Permissions

| Permission | Allows | Held by |
| - | - | - |
| `org.tenants.read` | List and read buyers | Platform key |
| `org.tenants.write` | Create buyers and buyer keys | Platform key |
| `org.transactions.write` | Save and remove cards, request, update and cancel transactions | Buyer key, platform key |
| `org.transactions.read` | Read cards, setup links, merchants and transactions | Buyer key |

## Retries and idempotency

Creating, changing and canceling a transaction each take a key. [Keep the same idempotency key](https://docs.sapiom.ai/transactions/authorize.md#keep-the-same-idempotency-key) explains when to resend with it. Setup links take no key; each call creates a new link.

## REST endpoints

Each group has a page per endpoint, with its fields and examples.

| Group | Endpoints | Key |
| - | - | - |
| [Buyers](https://docs.sapiom.ai/api-reference/buyers/create-a-buyer.md) | Create, list and delete buyers, and create buyer keys | Platform key |
| [Cards](https://docs.sapiom.ai/api-reference/cards/create-a-setup-link.md) | Setup links, and list, read, set default and remove cards | Buyer key |
| [Spending limits](https://docs.sapiom.ai/api-reference/spending-limits/get-spending-limits.md) | Read and set a card's spending limits | Platform key |
| [Merchants](https://docs.sapiom.ai/api-reference/merchants/check-a-merchant.md) | Check whether Sapiom can buy from a merchant | Buyer key |
| [Transactions](https://docs.sapiom.ai/api-reference/transactions/create-a-transaction.md) | Create, read and cancel a UCP or browser checkout transaction, and drive a UCP checkout | Buyer key |
| [Browser Pay relay](https://docs.sapiom.ai/api-reference/browser-pay-relay/relay-a-card-request.md) | The relay Browser Pay uses to send the card | Buyer key |


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