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

# Execute a swap

> Buy or sell a token across one or more of your wallets.

<Note>
  Want to attach take-profit, stop-loss, trailing, time, or dev-sell exits via
  the `auto_orders` field? See the **[Auto-orders guide](/concepts/auto-orders)**
  for the full field reference, the `target_value` table, and examples.
</Note>


## OpenAPI

````yaml openapi.yaml POST /api/v1/swap
openapi: 3.1.0
info:
  title: Bloom API
  version: 1.0.0
  description: |
    Programmatic trading and token-deploy API for Bloom. Drive swaps and token
    launches with a personal API key authenticated as a Bearer token.
servers:
  - url: https://eu.solana.bloombot.app
    description: Solana — EU
  - url: https://us.solana.bloombot.app
    description: Solana — US
  - url: https://evm.bloombot.app
    description: EVM
security:
  - bearerAuth: []
tags:
  - name: Trading
    description: Execute swaps across your wallets.
  - name: Deploy
    description: Launch new tokens.
paths:
  /api/v1/swap:
    post:
      tags:
        - Trading
      summary: Execute a swap
      description: Execute a buy or sell across one or more of your wallets.
      operationId: swap
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRequest'
            examples:
              buy:
                summary: Buy — spend 0.1 SOL on a token from one wallet
                value:
                  address: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  side: Buy
                  wallets:
                    - address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                      amount: '0.1'
                  slippage: 10
                  priority_fee: 0.001
                  processor_tip: 0.0001
                  anti_mev: false
                  auto_tip: false
              buyEvm:
                summary: Buy on EVM — spend 0.05 native (BNB) on BNB Chain
                value:
                  address: '0x9afedf881ca7e07f4f3cc7ecd2b974705834ffce'
                  chain: bsc
                  side: Buy
                  wallets:
                    - address: '0x2e8f0C9199cE40a66100917Ec09BD67A114D2827'
                      amount: '0.05'
                  slippage: 10
                  priority_fee: 3
                  processor_tip: 0.0005
                  anti_mev: false
                  auto_tip: false
              buyEvmStable:
                summary: Buy on EVM — spend 25 USDG on Robinhood chain
                value:
                  address: '0x9afedf881ca7e07f4f3cc7ecd2b974705834ffce'
                  chain: rbh
                  side: Buy
                  quote_asset: USDG
                  wallets:
                    - address: '0x2e8f0C9199cE40a66100917Ec09BD67A114D2827'
                      amount: '25'
                  slippage: 10
                  priority_fee: 3
                  processor_tip: 0.0005
                  anti_mev: false
                  auto_tip: false
              buyWithTakeProfit:
                summary: Buy with a +50% take-profit auto-order
                value:
                  address: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  side: Buy
                  wallets:
                    - address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                      amount: '0.05'
                  slippage: 10
                  priority_fee: 0.001
                  processor_tip: 0.0001
                  anti_mev: false
                  auto_tip: false
                  auto_orders:
                    - target_type: percentage
                      target_value: 50
                      amount: 100
                      slippage: 15
                      priority_fee: 0.001
                      anti_mev: true
              buyWithDevSell:
                summary: >-
                  Buy with a dev-sell auto-order (exit when the token creator
                  sells)
                value:
                  address: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  side: Buy
                  wallets:
                    - address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                      amount: '0.05'
                  slippage: 10
                  priority_fee: 0.001
                  processor_tip: 0.0001
                  anti_mev: false
                  auto_tip: true
                  auto_orders:
                    - target_type: dev_sell
                      target_value: 0
                      amount: 100
                      slippage: 25
                      priority_fee: 0.001
                      anti_mev: false
              sellPercent:
                summary: Sell 100% of holdings (percentage mode, the default)
                value:
                  address: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  side: Sell
                  sell_mode: percent
                  wallets:
                    - address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                      amount: '100'
                  slippage: 25
                  priority_fee: 0.001
                  processor_tip: 0.0001
                  anti_mev: false
                  auto_tip: false
              sellTokens:
                summary: Sell an exact token quantity (tokens mode)
                value:
                  address: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  side: Sell
                  sell_mode: tokens
                  wallets:
                    - address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
                      amount: '330000.5'
                  slippage: 25
                  priority_fee: 0.001
                  processor_tip: 0.0001
                  anti_mev: false
                  auto_tip: false
      responses:
        '200':
          description: Swap accepted.
          headers:
            X-RateLimit-Limit-Minute:
              description: Configured per-minute limit.
              schema:
                type: integer
            X-RateLimit-Limit-Hour:
              description: Configured per-hour limit.
              schema:
                type: integer
            X-RateLimit-Limit-Week:
              description: Configured per-week limit.
              schema:
                type: integer
            X-RateLimit-Remaining-Minute:
              description: Requests remaining in the current minute window.
              schema:
                type: integer
            X-RateLimit-Remaining-Hour:
              description: Requests remaining in the current hour window.
              schema:
                type: integer
            X-RateLimit-Remaining-Week:
              description: Requests remaining in the current week window.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapResponse'
        '400':
          description: >-
            Bad request. Codes: NO_WALLETS (empty wallets array),
            INVALID_REQUEST (missing or invalid field), WALLET_NOT_OWNED (a
            wallet address does not belong to your account),
            LIQUIDITY_OUT_OF_RANGE (pool liquidity outside requested band),
            MARKET_CAP_OUT_OF_RANGE (market cap outside requested band),
            TOKEN_OR_POOL_NOT_FOUND (mint or pool address could not be
            resolved), NO_ROUTE (no swap route found), INSUFFICIENT_BALANCE
            (wallet has insufficient balance).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: >-
            Unauthorized. Codes: UNAUTHORIZED (missing, malformed, unknown, or
            revoked Bearer token).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Too many requests. Code: RATE_LIMITED. The rejected request is not
            counted against your budget.
          headers:
            Retry-After:
              description: Seconds until the blocking window resets.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: >-
            Internal server error (code `INTERNAL_ERROR`). The request could not
            be completed — safe to retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SwapRequest:
      type: object
      required:
        - address
        - side
        - priority_fee
        - processor_tip
        - slippage
        - anti_mev
        - auto_tip
        - wallets
      properties:
        address:
          type: string
          description: Token mint address or pool ID.
        side:
          type: string
          enum:
            - Buy
            - Sell
        chain:
          type: string
          enum:
            - eth
            - bsc
            - base
            - rbh
            - arc
          description: >
            **EVM host only.** The chain to trade on, matched
            case-insensitively. Optional — when omitted, the token address is
            resolved across the supported chains automatically. Pass it
            explicitly to pin the lookup to one chain. An unrecognised value
            fails with `INVALID_REQUEST`. Not used on the Solana host. See
            [Chains and quote assets](/concepts/chains).
        sell_mode:
          type: string
          enum:
            - percent
            - tokens
          default: percent
          description: >
            For a Sell, how each wallet's `amount` is interpreted: `percent`
            (1-100 of holdings, the default) or `tokens` (absolute token
            quantity). An over-amount in `tokens` mode sells the full balance.
            Ignored for a Buy. `tokens` is **Solana-only** — the EVM host
            rejects it with `INVALID_REQUEST`.
        priority_fee:
          type: number
          description: >
            Priority fee. Denominated in SOL on the Solana host and in **gwei**
            on the EVM host — see [Fee
            denomination](/concepts/chains#fee-denomination).
        processor_tip:
          type: number
          description: >
            Processor tip; ignored when `auto_tip` is true. Denominated in SOL
            on the Solana host and in the chain's **native asset** on the EVM
            host.
        slippage:
          type: number
          description: Slippage tolerance as a percentage, e.g. 10 = 10%.
        anti_mev:
          type: boolean
        auto_tip:
          type: boolean
          description: >-
            When true, the server sets the priority fee and processor tip for
            you.
        wallets:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/SwapWallet'
        auto_orders:
          type: array
          maxItems: 20
          description: >
            Attach take-profit / stop-loss / trailing / time / dev-sell exits to
            this swap (up to 20; any beyond 20 are dropped). See the
            [Auto-orders guide](/concepts/auto-orders) for the full field
            reference, the `target_value` table, and examples.
          items:
            $ref: '#/components/schemas/AutoOrder'
        quote_asset:
          type: string
          enum:
            - SOL
            - ETH
            - BNB
            - USDC
            - USDT
            - USD1
            - USDG
          description: >
            Quote asset to trade against — what a Buy spends, and the unit of
            `wallets[].amount`. Omit it to use the chain's native token.


            Each chain's native token is named by its own symbol: `SOL` on the
            Solana host, and on EVM `ETH` (eth, base, rbh), `BNB` (bsc) or
            `USDC` (arc, whose native token is USDC).


            Support is validated **per chain** — eth `USDC`/`USDT`, bsc
            `USD1`/`USDC`/`USDT`, base `USDC`, rbh `USDG`, arc native only,
            Solana `USDC`/`USD1`. An asset the chain does not support is
            rejected with `INVALID_REQUEST`, and the error lists the valid set.
            See [Chains and quote assets](/concepts/chains).
        min_liquidity:
          type: number
          description: Pool liquidity bounds in USD.
        max_liquidity:
          type: number
          description: Pool liquidity bounds in USD.
        min_market_cap:
          type: number
          description: Token market-cap bounds in USD.
        max_market_cap:
          type: number
          description: Token market-cap bounds in USD.
    SwapResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          required:
            - order_id
            - signatures
          properties:
            order_id:
              type: string
            signatures:
              type: array
              description: >-
                Submitted transaction signatures, one per wallet/transaction.
                These confirm what was broadcast on-chain (not final
                confirmation). May be empty if nothing was submitted.
              items:
                type: string
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type:
                - string
                - 'null'
    SwapWallet:
      type: object
      required:
        - address
        - amount
      properties:
        address:
          type: string
          description: One of your wallets.
        amount:
          type: string
          description: >
            Amount to swap from this wallet, as a decimal string (avoids
            floating-point precision loss). For a Buy, this is the amount of the
            chosen `quote_asset` to spend (e.g. `"10"` with `quote_asset: USDC`
            spends 10 USDC; SOL when `quote_asset` is SOL or omitted). For a
            Sell, it is interpreted per the request's `sell_mode`: a percentage
            of holdings `1`-`100` (default), or an absolute token quantity when
            `sell_mode` is `tokens`.
    AutoOrder:
      type: object
      description: >
        An exit order attached to a swap (take-profit, stop-loss, trailing,

        time-based, or dev-sell). The order is evaluated after the parent trade

        lands and sells automatically when it triggers. See the

        [Auto-orders guide](/concepts/auto-orders) for examples and guidance.


        The meaning of `target_value` depends on `target_type`:


        | target_type  | target_value
        means                                                                                                    
        |

        |--------------|------------------------------------------------------------------------------------------------------------------------|

        | `percentage` | Percent to sell at. Positive = take-profit (sell when
        up X%); negative = stop-loss (sell when down X%).                 |

        | `fixed`      | Target market cap in USD — sell when the market cap
        reaches this value.                                                 |

        | `fixed_add`  | Market-cap change threshold in USD — sell when the
        market cap moves (up or down) by this amount.                        |

        | `trailing`   | Trailing distance as a percent — the stop trails this
        far below the peak and moves up as the price rises.               |

        | `time`       | Seconds — sell this many seconds after the order is
        placed.                                                             |

        | `dev_sell`   | Triggers when the token creator sells: `0` = any dev
        sell, `100` = only a full (whole-position) dev sell.               |
      required:
        - target_type
        - target_value
        - amount
        - slippage
        - priority_fee
      properties:
        target_type:
          type: string
          enum:
            - percentage
            - fixed
            - fixed_add
            - trailing
            - time
            - dev_sell
          description: >-
            Order trigger type. The meaning of `target_value` depends on this.
            Use `dev_sell` for an automatic dev-sell.
        target_value:
          type: number
          description: >-
            Trigger threshold; its meaning depends on `target_type` — see [what
            target_value means](/concepts/auto-orders#what-target_value-means).
        amount:
          type: number
          description: >-
            Percentage of your position to sell when the order triggers, 1–100
            (100 = sell the entire position).
        slippage:
          type: number
          description: Slippage tolerance as a percentage (e.g. 10 = 10%).
        priority_fee:
          type: number
          description: >
            Priority fee. Denominated in SOL on the Solana host and in **gwei**
            on the EVM host — see [Fee
            denomination](/concepts/chains#fee-denomination).
        processor_tip:
          type: number
          description: >
            Processor tip. Denominated in SOL on the Solana host and in the
            chain's **native asset** on the EVM host.
        anti_mev:
          type: boolean
          default: false
          description: >-
            Submit the exit through an anti-MEV path. Optional; defaults to
            false.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Bloom API key, e.g. `Authorization: Bearer blm_sol_live_…`. Create
        one in Bloom Manager → Manage API Keys.

````