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

# Buy a listed credential

> Escrows the buyer's USDC card funds, atomically re-keys credential ownership (and its pay links), pays out the seller net of the marketplace take rate, and captures the fee. Any failure after escrow fully unwinds - no half-completed sale, no lost funds.




## OpenAPI

````yaml /openapi.yaml post /api/listings/{id}/buy
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/listings/{id}/buy:
    post:
      tags:
        - Marketplace
      summary: Buy a listed credential
      description: >
        Escrows the buyer's USDC card funds, atomically re-keys credential
        ownership (and its pay links), pays out the seller net of the
        marketplace take rate, and captures the fee. Any failure after escrow
        fully unwinds - no half-completed sale, no lost funds.
      operationId: marketplaceBuyListing
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - buyer_card_id
              properties:
                buyer_card_id:
                  type: string
                  description: An ACTIVE USDC card you own to pay from.
      responses:
        '200':
          description: Purchase settled
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  listing:
                    $ref: '#/components/schemas/Listing'
                  feeQuote:
                    type: object
                  payoutTx:
                    type: string
        '400':
          description: >-
            Pay card is not USDC, wrong network, or self-custody sale not yet
            supported
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Pay card or listing not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Listing is not available (already sold/cancelled/encumbered)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                    example: NOT_LISTED
components:
  schemas:
    Listing:
      type: object
      properties:
        id:
          type: string
          example: lst_mag3nt_abc123_1719500000000_42
        card_id:
          type: string
        seller:
          type: string
        price:
          type: number
        currency:
          type: string
          enum:
            - USDC
            - magUSD
          description: Only USDC settlement is live today.
        status:
          type: string
          enum:
            - LISTED
            - CANCELLED
            - SOLD
        created_at:
          type: string
          format: date-time
        buyer:
          type:
            - string
            - 'null'
        settled_tx:
          type:
            - string
            - 'null'
        settled_at:
          type:
            - string
            - 'null'
          format: date-time
        sellable:
          type: boolean
          description: >-
            Mirrors the exact buy-time gate (LISTED, not frozen/seized/closed,
            not encumbered). Present on GET /api/listings/{id}.
        stats:
          $ref: '#/components/schemas/CredentialStats'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Card not found
    CredentialStats:
      type:
        - object
        - 'null'
      description: >-
        Verifiable, ledger-derived performance for a credential. Never
        fabricated.
      properties:
        rxCount:
          type: integer
        rxLifetime:
          type: number
        rx30d:
          type: number
        rx30dCount:
          type: integer
        lastActive:
          type:
            - string
            - 'null'
          format: date-time
        firstActive:
          type:
            - string
            - 'null'
          format: date-time
        protocols:
          type: integer
        balance:
          type: number
        ageDays:
          type:
            - integer
            - 'null'
        hasCrt:
          type: boolean
        crtStatus:
          type:
            - string
            - 'null'
        crtAddress:
          type:
            - string
            - 'null'
        crtSymbol:
          type:
            - string
            - 'null'
        holderAddress:
          type:
            - string
            - 'null'
        chainStatus:
          type:
            - string
            - 'null'
        identityToken:
          type:
            - string
            - 'null'
        identityStatus:
          type:
            - string
            - 'null'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API key prefixed with 'Bearer sx_live_...'

````