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

# Get swap instructions

> Get raw swap instructions and address lookup tables for building custom transactions.

**Requires API key.**




## OpenAPI

````yaml openapi-spec/trading.yaml post /swap/sol/instructions
openapi: 3.0.3
info:
  title: Raze Trading API
  description: >
    Trading endpoints for Solana token swaps — quote, buy, sell, atomic

    round-trips and raw instructions. Perpetuals (Jupiter Perps + Phoenix) live

    here too.


    Quotes can also be **streamed**: `/swap/sol/quote/stream` is a WebSocket
    that

    pushes a fresh quote whenever the pools under your route move. It is not

    describable in OpenAPI — see

    [Streaming quotes](/api-reference/router/quote-stream).


    Write utilities (`/utils/sol/*` — launch, transfer, burn, consolidate, fees)

    moved to the History API on `https://api.raze.bot` (see `history.yaml`).


    Runs on port 8082.


    **Auth methods**: `Authorization: Bearer sk_...` header, `X-API-Key: sk_...`
    header, or `?apiKey=sk_...` query param.
  version: 2.1.0
servers:
  - url: https://router.raze.bot
    description: >-
      Raze global trading router — GeoDNS routes to the nearest region
      automatically
security:
  - ApiKeyAuth: []
paths:
  /swap/sol/instructions:
    post:
      summary: Get swap instructions
      description: >
        Get raw swap instructions and address lookup tables for building custom
        transactions.


        **Requires API key.**
      operationId: swapInstructions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapInstructionsRequest'
            examples:
              exactIn:
                summary: Exact input swap (SOL → token)
                value:
                  wallet: 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  inputMint: So11111111111111111111111111111111111111112
                  outputMint: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  amount: 1000000000
                  swapMode: exactIn
                  slippageBps: 500
                  tipLamports: 1000000
              exactOut:
                summary: Exact output swap
                value:
                  wallet: 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  inputMint: So11111111111111111111111111111111111111112
                  outputMint: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  amount: 400000000
                  swapMode: exactOut
                  slippageBps: 500
      responses:
        '200':
          description: Swap instructions generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapInstructionsResponse'
              example:
                success: true
                instructions:
                  - programId: 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
                    data: AQAAAA...
                    accounts:
                      - pubkey: 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                        isSigner: true
                        isWritable: true
                addressLookupTableAddresses:
                  - 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
        '400':
          description: >-
            Invalid parameters (including invalid_route_ticket /
            route_ticket_mismatch when a routeTicket is present)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            route_expired — the routeTicket is past its TTL; re-quote and retry
            with the fresh ticket (or send refetch:true)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    SwapInstructionsRequest:
      type: object
      properties:
        wallet:
          type: string
          description: Payer wallet public key
          example: 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
        inputMint:
          type: string
          description: Input token mint address
          example: So11111111111111111111111111111111111111112
        outputMint:
          type: string
          description: Output token mint address
          example: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
        amount:
          type: integer
          description: Amount in input token base units (lamports for SOL)
          example: 1000000000
        swapMode:
          type: string
          enum:
            - exactIn
            - exactOut
          default: exactIn
          description: Swap mode — exactIn or exactOut
        slippageBps:
          type: integer
          default: 500
          minimum: 0
          maximum: 10000
          example: 500
        tipWallet:
          type: string
          description: Tip recipient wallet. Omitted ⇒ no tip transfer.
        tipLamports:
          type: number
          description: Tip amount in lamports. Omitted ⇒ no tip transfer.
          example: 5000
        feeWallet:
          type: string
          description: >-
            Platform-fee recipient wallet — any wallet you choose. Omitted ⇒ no
            percentage fee.
        feeBps:
          type: number
          description: >-
            Platform fee in bps, capped on-chain at 1000 (10%). Omitted ⇒ no
            percentage fee. Charged only on routes built through the Raze CPI
            router.
          example: 50
        feeOnInput:
          type: boolean
          description: >-
            Take the on-chain CPI fee from the input token (true) or the output
            token (false). Omitted ⇒ router default (the SOL/stable side of the
            trade).
        transactionsFeeLamports:
          type: number
          description: Priority fee per transaction in lamports
          example: 100000
        maxHops:
          type: integer
          minimum: 1
          maximum: 3
          description: Cap the route search depth (1–3 hops).
        includeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
          description: >-
            Only route through these DEXes (array or CSV). Labels match the
            quote response `route[].dex`, case/spacing-insensitive. Use this to
            PIN the route this endpoint re-quotes internally.
        excludeDex:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
          description: Never route through these DEXes. Wins over `includeDex`.
        serialize:
          type: boolean
          description: |
            When true, the response also carries `transaction`: a ready-to-sign
            unsigned **v0 transaction** (base64) with `wallet` as fee payer, a
            fresh blockhash, and the address lookup tables already resolved
            server-side. A browser wallet can deserialize → sign → send with no
            ALT or blockhash refetch of its own.
        routeTicket:
          type: string
          description: >-
            Route ticket from a /quote response — build EXACTLY the quoted plan
            (no re-quote). Expired ⇒ 409 route_expired; malformed/forged ⇒ 400
            invalid_route_ticket; pair/amount/swapMode mismatch ⇒ 400
            route_ticket_mismatch.
        refetch:
          type: boolean
          description: >-
            Force a fresh re-quote even when routeTicket is present (explicit
            fallback after a 409).
      required:
        - wallet
        - inputMint
        - outputMint
        - amount
    SwapInstructionsResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        instructions:
          type: array
          items:
            type: object
            properties:
              programId:
                type: string
              data:
                type: string
                description: Base64-encoded instruction data
              accounts:
                type: array
                items:
                  type: object
                  properties:
                    pubkey:
                      type: string
                    isSigner:
                      type: boolean
                    isWritable:
                      type: boolean
          description: Raw swap instructions to include in your own transaction
        addressLookupTableAddresses:
          type: array
          items:
            type: string
          description: Address Lookup Table addresses needed for the transaction
        transaction:
          type: string
          description: >-
            Base64 unsigned v0 transaction (fee payer = `wallet`, fresh
            blockhash, ALTs resolved). Present only when the request set
            `serialize: true`.
      required:
        - success
        - instructions
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        details:
          type: string
      required:
        - success
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    BearerAuth:
      type: http
      scheme: bearer

````