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

# Settle a pay link payment

> Universal settlement for both humans and agents. Mode is detected from the body: `tx_hash` (+ optional `protocol`) settles an on-chain wallet or external-protocol payment (verified on-chain before crediting); `protocol` + `payer_card_id` + `payer_card_token` settles an internal platform card-to-card protocol payment. The destination (merchant treasury vs. on-chain holder) and pricing gate follow the same DIRECT/CUSTODIAL rules as prepare; the settled settlement_mode is delivered on the `payment.settled` webhook, not in this response.




## OpenAPI

````yaml /openapi.yaml post /api/pay/{code}/settle
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}/settle:
    post:
      tags:
        - Pay Links
      summary: Settle a pay link payment
      description: >
        Universal settlement for both humans and agents. Mode is detected from
        the body: `tx_hash` (+ optional `protocol`) settles an on-chain wallet
        or external-protocol payment (verified on-chain before crediting);
        `protocol` + `payer_card_id` + `payer_card_token` settles an internal
        platform card-to-card protocol payment. The destination (merchant
        treasury vs. on-chain holder) and pricing gate follow the same
        DIRECT/CUSTODIAL rules as prepare; the settled settlement_mode is
        delivered on the `payment.settled` webhook, not in this response.
      operationId: payLinksSettle
      parameters:
        - name: code
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  description: Internal protocol mode (platform card pays a pay link).
                  required:
                    - protocol
                    - payer_card_id
                    - payer_card_token
                  properties:
                    protocol:
                      type: string
                      enum:
                        - x402
                        - ap2
                        - mpp
                    payer_card_id:
                      type: string
                    payer_card_token:
                      type: string
                    idempotency_key:
                      type: string
                - type: object
                  description: >-
                    Wallet or external-protocol mode (on-chain payment, verified
                    before crediting).
                  required:
                    - tx_hash
                    - from_address
                  properties:
                    tx_hash:
                      type: string
                    from_address:
                      type: string
                    protocol:
                      type: string
                      enum:
                        - x402
                        - ap2
                        - mpp
                      description: >-
                        Defaults to x402 when omitted for a plain wallet
                        transfer.
                    amount:
                      type:
                        - number
                        - string
                      description: >-
                        Required for an open-amount link; ignored for a
                        fixed-amount link.
      responses:
        '200':
          description: Settlement processed (or already settled on idempotent replay)
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - SETTLED
                      - ALREADY_SETTLED
                  settlement_id:
                    type: string
                  amount:
                    type:
                      - number
                      - string
                  fee:
                    type:
                      - number
                      - string
                  net_amount:
                    type:
                      - number
                      - string
                  tx_hash:
                    type: string
                  mode:
                    type: string
                    enum:
                      - external_protocol
                      - protocol
                  protocol:
                    type: string
                    enum:
                      - x402
                      - ap2
                      - mpp
                  receipt_id:
                    type: string
        '400':
          description: >-
            Invalid amount, missing from_address, unaccepted protocol, or
            on-chain verification failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  status:
                    type: string
                    example: REJECTED
        '401':
          description: Invalid payer card token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Card or link not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many settlement attempts from this IP - retry after a minute
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: Failed to verify the on-chain transaction - retry
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  status:
                    type: string
                    example: REJECTED
        '503':
          description: >-
            Settlement is paused for maintenance, DIRECT holder not ready, or
            on-chain verification is unavailable (no RPC configured)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  status:
                    type: string
                  code:
                    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_...'

````