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

# Create Swap

> Creates a new cryptocurrency swap on the specified exchange



## OpenAPI

````yaml POST /swap
openapi: 3.1.0
info:
  title: Bestflow API
  description: >-
    Bestflow is a cryptocurrency exchange aggregator that provides cross-chain
    swap capabilities without any additional fees. It aggregates multiple
    exchanges to offer users the best rates and seamless cryptocurrency swaps
    across different networks.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.bestflow.xyz
security:
  - {}
  - bearerAuth: []
paths:
  /swap:
    post:
      description: Creates a new cryptocurrency swap on the specified exchange
      requestBody:
        description: Swap creation details
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRequest'
        required: true
      responses:
        '200':
          description: Swap created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Unexpected server failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: Upstream exchange rejected or failed swap creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          $ref: '#/components/responses/ServiceUnavailableError'
components:
  schemas:
    SwapRequest:
      type: object
      required:
        - exchange
        - from
        - to
        - fromNetwork
        - toNetwork
        - toAddress
        - amount
      properties:
        exchange:
          type: string
          enum:
            - swapter
            - etzswap
            - pegasusswap
          description: Exchange to use for the swap
        from:
          type: string
          description: Source currency ticker
        to:
          type: string
          description: Destination currency ticker
        fromNetwork:
          type: string
          description: Source network identifier
        toNetwork:
          type: string
          description: Destination network identifier
        toAddress:
          type: string
          description: Destination wallet address
        amount:
          type: number
          exclusiveMinimum: 0
          description: Amount to swap
        memo:
          type: string
          description: Optional memo/tag for destination address
    SwapResponse:
      type: object
      required:
        - id
        - from
        - to
        - fromNetwork
        - toNetwork
        - sendAmount
        - sendAddress
        - sendMemo
      properties:
        id:
          type: string
          description: Unique identifier for the swap
        from:
          type: string
          description: Source currency ticker
        to:
          type: string
          description: Destination currency ticker
        fromNetwork:
          type: string
          description: Source network identifier
        toNetwork:
          type: string
          description: Destination network identifier
        sendAmount:
          type: number
          description: Amount to send to complete the swap
        sendAddress:
          type: string
          description: Deposit address to send funds to
        sendMemo:
          type:
            - string
            - 'null'
          description: Memo/tag for the deposit; null when not required or not provided
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code
          enum:
            - VALIDATION_ERROR
            - INVALID_FORMAT
            - UNKNOWN_EXCHANGE
            - SWAP_ERROR
            - SWAP_NOT_FOUND
            - UNAUTHORIZED
            - RATE_LIMITED
            - SERVICE_UNAVAILABLE
        message:
          type: string
          description: Human-readable error message
  responses:
    UnauthorizedError:
      description: Invalid or unknown API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: UNAUTHORIZED
            message: Invalid API key
    ServiceUnavailableError:
      description: Auth dependency unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: SERVICE_UNAVAILABLE
            message: Auth service unavailable
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Optional Bearer authentication using an API key provided as a Bearer
        token. Required for unlimited requests and revenue sharing.

````