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

# Buy tokens

> Build buy transactions for one or more wallets.

**Amount resolution:**
- `amounts[]` — per-wallet SOL amounts (takes precedence)
- `inputMint` + `inputAmountRaw` — non-SOL input route
- `solAmount` — uniform SOL amount for all wallets (default: 1 SOL)




## OpenAPI

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


    Runs on port 8082.


    **Auth methods**: `Authorization: Bearer sk_...` header, `X-API-Key: sk_...`
    header, or `?apiKey=sk_...` query param.
  version: 2.0.0
servers:
  - url: https://router.raze.bot
    description: >-
      Raze global trading router — GeoDNS routes to the nearest region
      automatically
security: []
paths:
  /swap/sol/buy:
    post:
      summary: Buy tokens
      description: |
        Build buy transactions for one or more wallets.

        **Amount resolution:**
        - `amounts[]` — per-wallet SOL amounts (takes precedence)
        - `inputMint` + `inputAmountRaw` — non-SOL input route
        - `solAmount` — uniform SOL amount for all wallets (default: 1 SOL)
      operationId: buy
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            API key for authenticated access (alternative to Authorization
            header)
        - name: Authorization
          in: header
          required: false
          schema:
            type: string
          description: Bearer sk_... — alternative to X-API-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuyRequest'
            examples:
              solInput:
                summary: SOL input, single wallet
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  solAmount: 0.1
              multiWallet:
                summary: Multiple wallets, per-wallet amounts
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                    - 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  amounts:
                    - 0.05
                    - 0.15
                  slippageBps: 500
                  feeTipLamports: 1000000
              nonSolInput:
                summary: Non-SOL input (USDC → token)
                value:
                  walletAddresses:
                    - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
                  tokenAddress: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
                  inputMint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  inputAmountRaw: 1000000
      responses:
        '200':
          description: Transactions generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BuyResponse'
              example:
                success: true
                transactions:
                  - 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWJ...
                  - 5mYUDkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWJ...
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Token not found / could not get quote
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    BuyRequest:
      type: object
      properties:
        walletAddresses:
          type: array
          items:
            type: string
          minItems: 1
          example:
            - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
        tokenAddress:
          type: string
          example: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
        solAmount:
          type: number
          description: >-
            Uniform SOL amount per wallet. Required if amounts not provided (SOL
            input only).
          example: 0.1
        amounts:
          type: array
          items:
            type: number
          description: >-
            Per-wallet SOL amounts. Required if solAmount not provided (SOL
            input only).
          example:
            - 0.05
            - 0.15
        inputMint:
          type: string
          description: >-
            Input token mint. Omit for native SOL input. Use for non-SOL → token
            swaps.
          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        inputAmountRaw:
          type: integer
          description: >-
            Raw input amount in token base units. Required when inputMint is
            provided.
          example: 1000000
        slippageBps:
          type: integer
          default: 9990
          minimum: 0
          maximum: 10000
          example: 9990
        transactionsFeeLamports:
          type: number
          description: Priority fee per transaction in lamports
          example: 100000
        feeTipLamports:
          type: number
          description: Tip in lamports. Public — min 0.001 SOL (1000000 lamports) enforced.
          example: 1000000
          minimum: 1000000
        tipWallet:
          type: string
          description: Custom tip recipient wallet (auth only)
        tipLamports:
          type: number
          description: Custom tip amount in lamports (auth only)
          example: 1000000
        feeWallet:
          type: string
          description: Custom fee recipient wallet (auth only)
        feeBps:
          type: number
          description: Custom fee in basis points (auth only)
          example: 50
        encoding:
          type: string
          enum:
            - base58
            - base64
          default: base64
      required:
        - walletAddresses
        - tokenAddress
    BuyResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        transactions:
          type: array
          items:
            type: string
          description: Unsigned transactions ready to be signed and submitted
      required:
        - success
        - transactions
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        details:
          type: string
      required:
        - success
        - error

````