> ## 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.

# Test your Sapiom Pay integration in the sandbox

> The Sapiom sandbox enables you to test a Sapiom Pay integration using test keys, test cards, and a test store. The API is the same as in production.

## Get access

Sapiom Pay is still in early access (EA), so the sandbox is only enabled per organization. After you sign up at [app.sapiom.ai/signup](https://app.sapiom.ai/signup), reach out to your Sapiom contact, and we'll enable it for your org.

## Enter Sandbox 🤘

From [app.sapiom.ai](https://app.sapiom.ai), turn on the switch beside **Sandbox** in the sidebar. This tab switches to sandbox data, and a **Test mode** banner appears. Other tabs keep their current environment.

Selecting the **Sandbox** label opens the Sandbox page. Use the adjacent switch to change the environment.

To return to live data, click **Switch to live data** in the banner or turn the sidebar switch off.

![Live and sandbox views of the Sandbox page, showing the sidebar switch off and on and the Test mode banner with Switch to live data](https://mintcdn.com/sapiom-1f975ca2/dbqIlzSQBHwrzxwY/images/open-sandbox-menu.png?fit=max\&auto=format\&n=dbqIlzSQBHwrzxwY\&q=85\&s=25b33a21dba6e2005b7bc15b5663f58e)

Sandbox mode is controlled by the switch beside Sandbox in the sidebar

## Get a key

While the **Test mode** banner is visible, open [Settings → API keys](https://app.sapiom.ai/dashboard/settings?tab=api-keys) and click **Create platform key**. Give it a name and click **Create**. Click **Reveal key**, copy it, and save it securely. Then click **Done**. The key is shown only once. A key from **Create key** can't create buyers.

Below, we call it `SAPIOM_SANDBOX_PLATFORM_KEY`. Keep this key in your backend. Your agent uses a buyer key for one buyer at a time.

## Create a sandbox buyer

Create a test buyer with your sandbox platform key. Requests with an `sk_test_` key reach the sandbox at the same API address. Sapiom links returned in responses open sandbox pages.

```bash theme={null}
curl https://api.sapiom.ai/v1/tenants \
  -H "x-api-key: $SAPIOM_SANDBOX_PLATFORM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Test user","externalId":"test-user-1"}'
```

Store the returned buyer `id`. Follow [Manage buyers](https://docs.sapiom.ai/buyers/create-buyers.md#create-and-store-the-buyer-key) to create a key for that buyer. Below, we call it `SAPIOM_SANDBOX_BUYER_KEY`.

## Save a test card

Create a [setup link](https://docs.sapiom.ai/cards/vault-a-card.md) with a sandbox buyer key, open it, and save this test card:

| Field | Value |
| - | - |
| Card number | `4242 4242 4242 4242` |
| Expiry | Any future date |
| Security code | `123` |

The sandbox saves only the test cards on the setup page. To test a different scenario, select one of these cards under **Sandbox test cards**:

| Scenario | Card number |
| - | - |
| Decline | `4000 0000 0000 0002` |
| Insufficient funds | `4000 0000 0000 9995` |
| Lost card | `4000 0000 0000 9987` |
| Stolen card | `4000 0000 0000 9979` |
| Expired card | `4000 0000 0000 0069` |
| Incorrect CVC | `4000 0000 0000 0127` |
| Processing error | `4000 0000 0000 0119` |

On any security code approval page, also use `123` as the security code.

## Connect your agent

Connect your agent to the hosted MCP server with the sandbox buyer key. For example, in Claude Code:

```bash theme={null}
claude mcp add --transport http sapiom https://api.sapiom.ai/v1/mcp/pay \
  --header "x-api-key: $SAPIOM_SANDBOX_BUYER_KEY"
```

See [Connect your agent](https://docs.sapiom.ai/buyers/connect-agent.md) for other MCP clients.

## Configure Browser Pay SDK

If your integration uses [Browser Pay](https://docs.sapiom.ai/transactions/browser-pay), pass the sandbox buyer key as `apiKey`. Keep `baseUrl` as `https://api.sapiom.ai`. Use the ID of the sandbox transaction your integration creates as `transactionId`:

```ts theme={null}
import { httpPaymentRelay } from "@sapiom/browser-pay";

const relay = httpPaymentRelay({
  baseUrl: "https://api.sapiom.ai",
  apiKey: process.env.SAPIOM_SANDBOX_BUYER_KEY!, // sk_test_...
  transactionId,
});
```

## Make a test purchase

Buy from Sapiom's test store, `https://sapiom-test-store.myshopify.com`. It supports UCP checkout, so checking it with a sandbox buyer key returns `supported`:

```bash theme={null}
curl -G https://api.sapiom.ai/v1/transaction-compatibility \
  -H "x-api-key: $SAPIOM_SANDBOX_BUYER_KEY" \
  -d domain=sapiom-test-store.myshopify.com
```

Create a `ucp_checkout` transaction for the store's Sapiom pen, `gid://shopify/ProductVariant/68317504897245`. Omit `paymentCardId` to use the buyer's default card:

```bash theme={null}
curl -X POST https://api.sapiom.ai/v1/transactions \
  -H "x-api-key: $SAPIOM_SANDBOX_BUYER_KEY" \
  -H "Idempotency-Key: sandbox-test-1" \
  -H "Content-Type: application/json" \
  -d '{
    "purchase": {
      "type": "ucp_checkout",
      "merchant": { "origin": "https://sapiom-test-store.myshopify.com" },
      "checkout": {
        "currency": "USD",
        "line_items": [
          { "item": { "id": "gid://shopify/ProductVariant/68317504897245" }, "quantity": 1 }
        ]
      }
    },
    "funding": { "source": "external_card" },
    "shipping": {
      "address": {
        "first_name": "Jane",
        "last_name": "Buyer",
        "street_address": "1 Market St",
        "address_locality": "San Francisco",
        "address_region": "CA",
        "postal_code": "94105",
        "address_country": "US"
      },
      "contact": { "email": "jane@example.com" }
    }
  }'
```

The purchase asks for the buyer's security code. Open the security code link and enter `123`, the test security code. The transaction is then ready to pay, so you can close that tab. See [Authorize a transaction](https://docs.sapiom.ai/transactions/authorize.md#follow-nextaction) for how to read each step.


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