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

# Swap

> Create a swap from an accepted quote and return the deposit address, amount, status, and tracking identifiers.



## OpenAPI

````yaml api-reference/openapi.json POST /swap
openapi: 3.1.0
info:
  title: LightSwap API
  description: >-
    Backend REST API for approved LightSwap integrations to quote, create, and
    track swaps.
  version: 1.0.0
servers:
  - url: https://lightswap.me/api/partner/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Assets
    description: Supported asset discovery.
  - name: Address
    description: Destination address validation.
  - name: Quotes
    description: Short-lived quotes.
  - name: Swaps
    description: Swap creation and status tracking.
paths:
  /swap:
    post:
      tags:
        - Swaps
      summary: Create swap
      description: Creates a swap from a quote and returns deposit instructions.
      operationId: createSwap
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSwapRequest'
            examples:
              createSwap:
                summary: Create a swap from a quote
                value:
                  quoteId: pq_aaaaaaaaaaaaaaaaaaaaaaaa
                  destination:
                    address: TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r
                    memo: null
                  notificationEmail: optional@example.com
      responses:
        '200':
          description: Created swap.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapResponse'
              examples:
                waitingDeposit:
                  summary: Swap waiting for deposit
                  value:
                    id: AB12CD34EF56
                    externalId: order-123
                    status: waiting_deposit
                    errorMessage: null
                    from:
                      decimals: 8
                      network: bitcoin
                      token: BTC
                      amount: '0.01'
                    to:
                      decimals: 6
                      network: tron
                      token: USDT
                      estimatedAmount: '100'
                    deposit:
                      address: bc1qdeposit
                      memo: null
                      amount: '0.01'
                      network: bitcoin
                      token: BTC
                      deadline: '2026-04-19T10:03:30.000Z'
                    payout:
                      address: TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r
                      memo: null
                      network: tron
                      token: USDT
                      estimatedAmount: '100'
                    quote:
                      id: pq_aaaaaaaaaaaaaaaaaaaaaaaa
                      rate: '10000'
                      estimatedTimeSeconds: 900
                    createdAt: '2026-04-19T10:00:30.000Z'
                    updatedAt: '2026-04-19T10:00:30.000Z'
                    customerId: u_123
        '400':
          $ref: '#/components/responses/BadRequest'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    CreateSwapRequest:
      type: object
      required:
        - quoteId
        - destination
      properties:
        quoteId:
          type: string
          pattern: ^pq_[a-f0-9]{24}$
          example: pq_aaaaaaaaaaaaaaaaaaaaaaaa
        destination:
          $ref: '#/components/schemas/Destination'
        notificationEmail:
          type:
            - string
            - 'null'
          format: email
          example: optional@example.com
      additionalProperties: false
    SwapResponse:
      type: object
      required:
        - id
        - externalId
        - status
        - errorMessage
        - from
        - to
        - deposit
        - payout
        - quote
        - createdAt
        - updatedAt
        - customerId
      properties:
        id:
          type: string
          pattern: ^[A-Z0-9]{12}$
          example: AB12CD34EF56
        externalId:
          type:
            - string
            - 'null'
          example: order-123
        status:
          $ref: '#/components/schemas/SwapStatus'
        errorMessage:
          type:
            - string
            - 'null'
        from:
          $ref: '#/components/schemas/SwapAssetFrom'
        to:
          $ref: '#/components/schemas/SwapAssetTo'
        deposit:
          $ref: '#/components/schemas/DepositDetails'
        payout:
          $ref: '#/components/schemas/PayoutDetails'
        quote:
          $ref: '#/components/schemas/SwapQuoteSummary'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        customerId:
          type:
            - string
            - 'null'
          example: u_123
    Destination:
      type: object
      required:
        - address
      properties:
        address:
          type: string
          example: TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r
        memo:
          type:
            - string
            - 'null'
          description: Destination memo. The MVP accepts `null` or an omitted value.
          example: null
      additionalProperties: false
    SwapStatus:
      type: string
      enum:
        - waiting_deposit
        - deposit_detected
        - underpaid
        - processing
        - completed
        - refunded
        - failed
        - expired
    SwapAssetFrom:
      type: object
      required:
        - decimals
        - network
        - token
        - amount
      properties:
        decimals:
          type: integer
        network:
          type: string
        token:
          type: string
        amount:
          type: string
    SwapAssetTo:
      type: object
      required:
        - decimals
        - network
        - token
        - estimatedAmount
      properties:
        decimals:
          type: integer
        network:
          type: string
        token:
          type: string
        estimatedAmount:
          type: string
    DepositDetails:
      type: object
      required:
        - address
        - memo
        - amount
        - network
        - token
        - deadline
      properties:
        address:
          type: string
        memo:
          type:
            - string
            - 'null'
        amount:
          type: string
        network:
          type: string
        token:
          type: string
        deadline:
          type: string
          format: date-time
    PayoutDetails:
      type: object
      required:
        - address
        - memo
        - network
        - token
        - estimatedAmount
      properties:
        address:
          type: string
        memo:
          type:
            - string
            - 'null'
        network:
          type: string
        token:
          type: string
        estimatedAmount:
          type: string
    SwapQuoteSummary:
      type: object
      required:
        - id
        - rate
        - estimatedTimeSeconds
      properties:
        id:
          type:
            - string
            - 'null'
          example: pq_aaaaaaaaaaaaaaaaaaaaaaaa
        rate:
          type:
            - string
            - 'null'
          example: '10000'
        estimatedTimeSeconds:
          type: integer
          minimum: 0
          example: 900
    ErrorResponse:
      type: object
      required:
        - error
        - requestId
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
        requestId:
          type: string
          example: req_123
    ErrorBody:
      type: object
      required:
        - code
        - message
        - details
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          example: Quote has expired.
        details:
          type: object
          additionalProperties: true
          example: {}
    ErrorCode:
      type: string
      enum:
        - inactive_partner
        - internal_error
        - invalid_api_key
        - provider_unavailable
        - quote_already_used
        - quote_expired
        - quote_not_found
        - rate_limited
        - swap_not_found
        - unsupported_asset
        - unsupported_pair
        - validation_error
  headers:
    RequestId:
      description: >-
        Request ID generated by LightSwap or echoed from the `x-request-id`
        request header.
      schema:
        type: string
        example: req_123
    RetryAfter:
      description: Seconds to wait before retrying a rate-limited request.
      schema:
        type: integer
        example: 30
  responses:
    BadRequest:
      description: The request is invalid.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            validationError:
              value:
                error:
                  code: validation_error
                  message: quoteId is invalid.
                  details: {}
                requestId: req_123
    RateLimited:
      description: The request exceeded the configured API rate limit.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                error:
                  code: rate_limited
                  message: Too many API requests. Please wait a moment and try again.
                  details: {}
                requestId: req_123
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key. Keep this key on your backend.

````