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

# Prepare payment intent for a pay link

> Returns everything a payer's wallet or agent needs to build a transaction: intent details, settlement destination, token contract, and settlement_mode. For a DIRECT credential the destination is the merchant's own on-chain holder address instead of the mag3nt treasury; DIRECT also enforces the membership pricing gate and the MAG3NT fee-meter debt floor before returning payment instructions. Agents (JSON Accept header, non-browser user agent) get HTTP 402 with WWW-Authenticate; browsers get HTTP 200.




## OpenAPI

````yaml /openapi.yaml get /api/pay/{code}/prepare
openapi: 3.1.0
info:
  title: mag3nt API
  version: '2026-07-16'
  description: >
    Payment infrastructure for AI agents. Issue virtual cards backed by
    credentials, pay for API access via x402/AP2/MPP protocols, and settle in
    USDC on Base. Also covers Native Token Rails membership and recurring
    billing agreements, ERC-20 project token registration (including B20) and
    prepaid MAG3NT fee metering for DIRECT (non-custodial) settlement, the
    credential marketplace and Credential Token (CT) markets, account-wide token
    holdings, and signed webhooks for payment and subscription lifecycle events.
  contact:
    name: mag3nt
    url: https://mag3nt.com
  license:
    name: Proprietary
    url: https://github.com/mag3nt-com/mag3nt-node/blob/main/LICENSE
servers:
  - url: https://mag3nt.com
    description: Production
  - url: https://staging.mag3nt.com
    description: Staging, Base mainnet
security:
  - ApiKeyAuth: []
tags:
  - name: Payments
    description: Universal outbound protocol payments
  - name: Cards
    description: Virtual payment card lifecycle
  - name: Keys
    description: Developer API key management
  - name: Funding
    description: Treasury deposits and balances
  - name: x402
    description: HTTP 402 payment protocol
  - name: AP2
    description: Agent-to-Agent Payment Protocol
  - name: MPP
    description: Micropayment Protocol with streaming
  - name: Pay Links
    description: Shareable payment URLs
  - name: Withdrawals
    description: Withdraw unspent funds back to wallet
  - name: Settlement
    description: On-chain settlement status
  - name: Webhooks
    description: Signed payment and subscription lifecycle notifications for sellers
  - name: Status
    description: System health and configuration
  - name: Membership
    description: Native Token Rails membership tiers, checkout, and auto-renew
  - name: Billing
    description: Recurring billing agreements funded by AP2 open mandates
  - name: Tokens
    description: >-
      Register an ERC-20 contract (including B20 tokens) for DIRECT credential
      settlement
  - name: Fees
    description: Prepaid MAG3NT fee meter for DIRECT settlement overage
  - name: Marketplace
    description: >-
      List and transfer credential businesses (proof of record) on the mag3nt
      marketplace
  - name: Credential Tokens
    description: Credential Token (CT) launch and Uniswap V4 markets
  - name: Holdings
    description: Account-wide Credential Token balances
externalDocs:
  description: mag3nt documentation
  url: https://docs.mag3nt.com
paths:
  /api/pay/{code}/prepare:
    get:
      tags:
        - Pay Links
      summary: Prepare payment intent for a pay link
      description: >
        Returns everything a payer's wallet or agent needs to build a
        transaction: intent details, settlement destination, token contract, and
        settlement_mode. For a DIRECT credential the destination is the
        merchant's own on-chain holder address instead of the mag3nt treasury;
        DIRECT also enforces the membership pricing gate and the MAG3NT
        fee-meter debt floor before returning payment instructions. Agents (JSON
        Accept header, non-browser user agent) get HTTP 402 with
        WWW-Authenticate; browsers get HTTP 200.
      operationId: payLinksPrepare
      parameters:
        - name: code
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Payment intent (browser)
          content:
            application/json:
              schema:
                type: object
                properties:
                  intent:
                    type: object
                    properties:
                      code:
                        type: string
                      amount:
                        type:
                          - number
                          - 'null'
                      asset:
                        type: string
                      network:
                        type: string
                      memo:
                        type: string
                      status:
                        type: string
                      type:
                        type: string
                      uses:
                        type: integer
                      max_uses:
                        type: integer
                      expires_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                  treasury:
                    type: string
                    description: >-
                      Settlement destination - the merchant's on-chain holder
                      for DIRECT, or the mag3nt treasury for CUSTODIAL.
                  token:
                    type:
                      - object
                      - 'null'
                    properties:
                      contract:
                        type: string
                      decimals:
                        type: integer
                      type:
                        type: string
                  accepted_protocols:
                    type: array
                    items:
                      type: string
                  agent_payable:
                    type: boolean
                    description: >-
                      False for open-amount links - an autonomous agent has no
                      fixed price to pay against.
                  amount_mode:
                    type: string
                    enum:
                      - fixed
                      - open
                  settlement:
                    type: object
                    properties:
                      address:
                        type: string
                      network:
                        type: string
                      asset:
                        type: string
                      token_contract:
                        type:
                          - string
                          - 'null'
                      token_decimals:
                        type:
                          - integer
                          - 'null'
                      mode:
                        type: string
                        enum:
                          - DIRECT
                          - CUSTODIAL
                  settlement_mode:
                    type: string
                    enum:
                      - DIRECT
                      - CUSTODIAL
                  is_owner:
                    type: boolean
        '402':
          description: >-
            Payment required (agent) - same body as 200, with WWW-Authenticate;
            or a DIRECT pricing-gate block
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                    enum:
                      - no_active_plan
                      - quota_exhausted
                      - fee_balance_exhausted
        '410':
          description: Pay link expired, cancelled, or used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: DIRECT holder is not provisioned yet - retry shortly
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                    example: holder_not_ready
                  message:
                    type: string
      security: []
components:
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Card not found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API key prefixed with 'Bearer sx_live_...'

````