> ## 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.
> Read https://docs.sapiom.ai/skill.md for Sapiom's rules and purchase steps. To install it as a skill, run npx skills add https://docs.sapiom.ai.

# Create a budget link

> Creates a link where the user sets a new budget for the card. Send the user `url`. Sapiom returns it only in this response. The current budget stays in effect until the user confirms the new budget. Requires a [user key](/api-reference/overview#authentication) with `org.payment_budget_links.create`.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/payment-cards/{cardId}/budget-links
openapi: 3.0.0
info:
  title: Sapiom Pay API
  version: '1.0'
  description: >-
    Create users, save their cards and authorize transactions. Send your
    platform key or a user key in the `x-api-key` header.
servers:
  - url: https://api.sapiom.ai
    description: Production
security:
  - api-key: []
tags:
  - name: Users
    description: One Sapiom user for each of your users. Called tenants in the API.
  - name: API keys
    description: >-
      Create, list and revoke your organization's API keys, and see which
      permissions a new key can have.
  - name: Cards
    description: Hosted setup links and the user's saved cards.
  - name: Spending limits
    description: Limits on what each card can spend.
  - name: Merchants
    description: Check whether Sapiom can buy from a merchant.
  - name: Transactions
    description: Create, read, update and cancel a transaction, and drive its UCP checkout.
  - name: Browser Pay relay
    description: The relay Browser Pay uses to send the card, for either purchase type.
paths:
  /v1/payment-cards/{cardId}/budget-links:
    post:
      tags:
        - Cards
      summary: Create a budget link
      description: >-
        Creates a link where the user sets a new budget for the card. Send the
        user `url`. Sapiom returns it only in this response. The current budget
        stays in effect until the user confirms the new budget. Requires a [user
        key](/api-reference/overview#authentication) with
        `org.payment_budget_links.create`.
      operationId: BudgetLinksController_create
      parameters:
        - name: cardId
          required: true
          in: path
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBudgetLinkDto'
        required: true
      responses:
        '201':
          description: The link. `url` holds a one-time code and is only returned here
        '403':
          description: Missing permission to request a replacement budget link
        '404':
          description: No such card for this tenant
      security:
        - api-key: []
components:
  schemas:
    CreateBudgetLinkDto:
      properties:
        budget:
          allOf:
            - $ref: '#/components/schemas/CardSetupLinkBudgetDto'
          description: >-
            The new budget's amount, for 30 days. If you send it, the user can
            only confirm it. If you leave it out, the user enters the amount.
        expiresInMinutes:
          default: 1440
          description: How long the link stays usable
          maximum: 10080
          minimum: 5
          type: integer
        returnUrl:
          description: >-
            Where the page sends the user when they finish, with `budget_link`
            and `budget` (`verified`, `card_number`, `failed` or `skipped`)
            added to the query. Use an `https` URL. For a local test, `http`
            works with `localhost`, `127.0.0.1` or `[::1]`, for example
            `http://localhost:3000/done`. Do not put a user name or password in
            the URL.
          maxLength: 2048
          type: string
      type: object
    CardSetupLinkBudgetDto:
      properties:
        amount:
          allOf:
            - $ref: '#/components/schemas/CardSetupBudgetAmountDto'
          description: >-
            The budget's amount: a positive decimal with at most two decimals,
            in USD
      required:
        - amount
      type: object
    CardSetupBudgetAmountDto:
      properties:
        currency:
          example: USD
          type: string
        value:
          example: '200.00'
          type: string
      required:
        - value
        - currency
      type: object
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your platform key for user management, or a user key for everything
        else.

````

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