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

# Build swap transaction

> Build a complete swap transaction from a quote



## OpenAPI

````yaml /raptor/http/openapi.json post /swap
openapi: 3.0.3
info:
  title: Raptor DEX Aggregator API
  description: >-
    Solana DEX aggregation API for quotes, swap transactions, transaction
    sending, and WebSocket quote streams.
  version: 1.0.0
  contact:
    name: Raptor API Support
servers:
  - url: https://raptor-beta.solanatracker.io
    description: Beta server endpoint
security: []
paths:
  /swap:
    post:
      summary: Build swap transaction
      description: Build a complete swap transaction from a quote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRequest'
      responses:
        '200':
          description: Successful transaction build
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SwapRequest:
      type: object
      required:
        - userPublicKey
        - quoteResponse
      properties:
        userPublicKey:
          type: string
          description: User's wallet public key
        wrapUnwrapSol:
          type: boolean
          description: Automatically wrap/unwrap SOL
          default: true
        txVersion:
          type: string
          enum:
            - legacy
            - v0
          description: Transaction version
          default: v0
        computeUnitPriceMicroLamports:
          type: integer
          description: Priority fee in microlamports
        computeUnitLimit:
          type: integer
          description: Compute unit limit
        priorityFee:
          type: string
          description: Priority fee mode or microlamports
        maxPriorityFee:
          type: integer
          description: Maximum priority fee cap
        tipAccount:
          type: string
          description: Tip account pubkey
        tipLamports:
          type: integer
          description: Tip amount in lamports
        feeAccount:
          type: string
          description: Platform fee recipient
        feeBps:
          type: integer
          description: Platform fee in basis points
        feeFromInput:
          type: boolean
          description: Take fee from input
          default: false
        chargeBps:
          type: integer
          description: Extra charge on positive slippage
        quoteResponse:
          $ref: '#/components/schemas/QuoteResponse'
    SwapResponse:
      type: object
      required:
        - swapTransaction
        - lastValidBlockHeight
        - contextSlot
        - prioritizationFeeLamports
      properties:
        swapTransaction:
          type: string
          description: Base64-encoded transaction
        lastValidBlockHeight:
          type: integer
          description: Block height until transaction is valid
        contextSlot:
          type: integer
          description: Solana slot when built
        prioritizationFeeLamports:
          type: integer
          description: Priority fee included
    ErrorResponse:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
          description: Error message
        code:
          type: integer
          description: HTTP status code
    QuoteResponse:
      type: object
      required:
        - inputMint
        - outputMint
        - amountIn
        - amountOut
        - minAmountOut
        - feeAmount
        - priceImpact
        - slippageBps
        - routePlan
        - contextSlot
        - timeTaken
      properties:
        inputMint:
          type: string
          description: Input token mint address
        outputMint:
          type: string
          description: Output token mint address
        amountIn:
          type: string
          description: Input amount in lamports
        amountOut:
          type: string
          description: Expected output amount in lamports
        minAmountOut:
          type: string
          description: Minimum output amount after slippage
        feeAmount:
          type: string
          description: Total fees paid in lamports
        priceImpact:
          type: number
          description: Price impact percentage
        slippageBps:
          type: integer
          description: Slippage used in basis points
        routePlan:
          type: array
          items:
            $ref: '#/components/schemas/RouteStep'
          description: Array of routing steps
        swapUsdValue:
          type: string
          description: USD value of the input amount
        priorityFee:
          $ref: '#/components/schemas/PriorityFeeInfo'
        platformFee:
          $ref: '#/components/schemas/PlatformFeeConfig'
        contextSlot:
          type: integer
          description: Solana slot when quote was generated
        timeTaken:
          type: number
          description: Time taken to generate quote in seconds
    RouteStep:
      type: object
      required:
        - programId
        - dex
        - pool
        - inputMint
        - outputMint
        - amountIn
        - amountOut
        - feeAmount
        - priceImpact
      properties:
        programId:
          type: string
          description: DEX program ID
        dex:
          type: string
          description: DEX name
        pool:
          type: string
          description: Pool address
        inputMint:
          type: string
          description: Step input mint
        outputMint:
          type: string
          description: Step output mint
        amountIn:
          type: string
          description: Step input amount
        amountOut:
          type: string
          description: Step output amount
        feeAmount:
          type: string
          description: Step fees
        priceImpact:
          type: number
          description: Step price impact
        percent:
          type: integer
          description: Percentage of total input
    PriorityFeeInfo:
      type: object
      required:
        - recommended
        - level
      properties:
        recommended:
          type: integer
          description: Recommended priority fee in microlamports
        level:
          type: string
          description: Priority level used
        levels:
          $ref: '#/components/schemas/PriorityFeeLevels'
    PlatformFeeConfig:
      type: object
      required:
        - feeBps
        - feeAccount
      properties:
        feeBps:
          type: integer
          description: Fee in basis points
        feeAccount:
          type: string
          description: Fee recipient address
    PriorityFeeLevels:
      type: object
      properties:
        min:
          type: integer
          description: Minimum priority fee
        low:
          type: integer
          description: Low priority fee
        medium:
          type: integer
          description: Medium priority fee
        high:
          type: integer
          description: High priority fee
        veryHigh:
          type: integer
          description: Very high priority fee
        unsafeMax:
          type: integer
          description: Maximum priority fee

````