> ## 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 is for platforms whose agent shops for many users. Each user has their own Sapiom user key and saved cards.
> Use the user's key for every call made on that user's behalf. Never use one user'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 environment with its own users and cards, at the same addresses. Use test card numbers only there.
> Never ask a user for a card number, expiry date or CVV in chat. Users 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. Send each one only to the person `nextAction.actor` names.
> 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.

# Add a card

Your user enters their card details and sets their budget. We vault the card. Within a user's budget, your agent uses Sapiom to buy without the user in the loop.

## Send a setup link to your user

Create a card setup link with the user key.&#x20;

> [tab] API
>
> ```bash theme={null}
> curl https://api.sapiom.ai/v1/payment-cards/setup-links \
>   -H "x-api-key: $SAPIOM_USER_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{"returnUrl":"https://your-app.example/cards/done","cardholderEmail":"jane@example.com","budget":{"amount":{"value":"50.00","currency":"USD"}}}'
>
> # Send the user the one-time "url". Keep the link's "id" to check progress.
> # expiresInMinutes: 5-1440, default 30. returnUrl: HTTPS, or HTTP to localhost.
> ```

> [tab] Agent (MCP)
>
> Or have your agent call the MCP tool:
>
> ```json theme={null}
> {
>   "name": "sapiom_add_payment_method",
>   "arguments": { "returnUrl": "https://your-app.example/cards/done" }
> }
> ```

![Add a card page branded for a platform called Wayfare, with email, name, card and billing fields, the consent line and a Save card button](https://mintcdn.com/sapiom-1f975ca2/aGERYeS4JlKIoVA1/images/card-setup-page-v2.png?fit=max\&auto=format\&n=aGERYeS4JlKIoVA1\&q=85\&s=b098393a761cfc6f7c112e9087813a1e)

Add a card

![Set a budget page for Wayfare: up to \$50.00 for 30 days, any merchant, Visa ending in 4242, with Confirm with Visa and Skip for now](https://mintcdn.com/sapiom-1f975ca2/9get71X2H3eNyHfD/images/wayfare/set-a-budget-network.jpg?fit=max\&auto=format\&n=9get71X2H3eNyHfD\&q=85\&s=c2d33fb14ab852da4b8580fca4630f75)

Set a budget, card the network verifies

![Set a budget page for Wayfare: up to \$50.00 for 30 days, any merchant, Visa ending in 0119, paid with the card number, with Set budget and Skip for now](https://mintcdn.com/sapiom-1f975ca2/9get71X2H3eNyHfD/images/wayfare/set-a-budget-card-number.jpg?fit=max\&auto=format\&n=9get71X2H3eNyHfD\&q=85\&s=6db01986fb4f64eade3371cc3a08cb20)

Set a budget, card number only

## Confirm the card is ready

Read the setup link. When its `status` is `completed`, `cardId` is the new card:

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

# When "status" is "completed", "cardId" is the new card. Store it with your user.
```

Check the card's budget: remaining amount (`available`), expiry (`expiresAt`) and `status`.

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

# The card can pay when "status" is "active" and "readiness" is not "not_ready".
# "budget" holds "amount", "available", "expiresAt" and "status".
```

## Renew a budget

When a budget is spent or ends, create a budget link and send it to the user. The new budget takes effect once the user confirms it.

```bash theme={null}
curl "https://api.sapiom.ai/v1/payment-cards/$CARD_ID/budget-links" \
  -H "x-api-key: $SAPIOM_USER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"budget":{"amount":{"value":"50.00","currency":"USD"}}}'

# Send the user the "url" from the response. Leave out "budget" to let the user enter the amount.
```

## Without a budget

If the user never sets a budget, each of their purchases asks for their security code.

## Manage cards

| | API | MCP tool |
| - | - | - |
| List | [`GET /v1/payment-cards`](https://docs.sapiom.ai/api-reference/cards/list-cards) | `sapiom_list_payment_methods` |
| Read | [`GET /v1/payment-cards/{cardId}`](https://docs.sapiom.ai/api-reference/cards/get-a-card) | |
| Set default | [`PUT /v1/payment-cards/{cardId}/default`](https://docs.sapiom.ai/api-reference/cards/set-the-default-card) | |
| Remove | [`DELETE /v1/payment-cards/{cardId}`](https://docs.sapiom.ai/api-reference/cards/remove-a-card) | `sapiom_delete_payment_method` |


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