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

# Build Sell Transaction

> Build an unsigned sell transaction to swap tokens for SOL or USD1 via one of the supported DEXs.

The response contains a base64-encoded unsigned `VersionedTransaction`. Sign it locally with your keypair and submit it to the network.


## SDK Examples

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ExitApiClient, type BuildSellTxRequest } from "@lasersell/lasersell-sdk";

  const client = ExitApiClient.withApiKey("YOUR_API_KEY");

  const request: BuildSellTxRequest = {
    mint: "TOKEN_MINT_ADDRESS",
    user_pubkey: "YOUR_WALLET_PUBKEY",
    amount_tokens: 1_000_000,
    slippage_bps: 2_000,
    output: "SOL",
  };

  const response = await client.buildSellTx(request);
  console.log("Unsigned tx (base64):", response.tx);

  // Or get just the base64 string:
  const txB64 = await client.buildSellTxB64(request);
  ```

  ```python Python theme={null}
  from lasersell_sdk.exit_api import ExitApiClient, BuildSellTxRequest, SellOutput

  client = ExitApiClient.with_api_key("YOUR_API_KEY")

  request = BuildSellTxRequest(
      mint="TOKEN_MINT_ADDRESS",
      user_pubkey="YOUR_WALLET_PUBKEY",
      amount_tokens=1_000_000,
      slippage_bps=2_000,
      output=SellOutput.SOL,
  )

  response = await client.build_sell_tx(request)
  print("Unsigned tx (base64):", response.tx)
  ```

  ```rust Rust theme={null}
  use lasersell_sdk::exit_api::{ExitApiClient, BuildSellTxRequest, SellOutput};

  let client = ExitApiClient::with_api_key("YOUR_API_KEY");

  let request = BuildSellTxRequest {
      mint: "TOKEN_MINT_ADDRESS".into(),
      user_pubkey: "YOUR_WALLET_PUBKEY".into(),
      amount_tokens: 1_000_000,
      output: SellOutput::Sol,
      slippage_bps: 2_000,
      ..Default::default()
  };

  let response = client.build_sell_tx(&request).await?;
  println!("Unsigned tx (base64): {}", response.tx);
  ```

  ```go Go theme={null}
  import lasersell "github.com/lasersell/lasersell-sdk/go"

  client := lasersell.NewExitAPIClientWithAPIKey("YOUR_API_KEY")

  resp, err := client.BuildSellTx(ctx, lasersell.BuildSellTxRequest{
      Mint:         "TOKEN_MINT_ADDRESS",
      UserPubkey:   "YOUR_WALLET_PUBKEY",
      AmountTokens: 1_000_000,
      Output:       lasersell.SellOutputSOL,
      SlippageBps:  2_000,
  })
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println("Unsigned tx (base64):", resp.Tx)
  ```
</CodeGroup>

## Error Responses

See [Error Handling](/api/exit-api/error-handling) for the full error envelope specification and retryable error logic.


## OpenAPI

````yaml POST /v1/sell
openapi: 3.1.0
info:
  title: LaserSell API
  version: 1.0.0
  description: >
    The LaserSell API builds unsigned Solana transactions for buying and selling
    tokens across supported DEXs.

    All transactions are non-custodial: the API returns unsigned
    `VersionedTransaction` payloads that you sign locally with your own keypair.


    Supported markets: Pump.fun, PumpSwap, Raydium (CPMM, Launchpad), Meteora
    (DBC, DAMM v2).
servers:
  - url: https://api.lasersell.io
    description: Production
security:
  - apiKey: []
tags:
  - name: Trading
    description: Build unsigned buy and sell transactions.
  - name: Account
    description: Account details and trade history.
  - name: Wallets
    description: Wallet registration for the Exit Intelligence Stream.
paths:
  /v1/sell:
    post:
      tags:
        - Trading
      summary: Build Sell Transaction
      description: >
        Build an unsigned sell transaction to swap tokens for SOL or USD1 via
        one of the supported DEXs.


        The response contains a base64-encoded unsigned `VersionedTransaction`.
        Sign it locally with your keypair and submit it to the network.
      operationId: buildSellTx
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuildSellTxRequest'
      responses:
        '200':
          description: Unsigned sell transaction built successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BuildTxResponse'
        '400':
          description: >-
            Bad request (invalid parameters, invalid mint, or unsupported token
            program).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - $ref: '#/components/schemas/UnsupportedResponse'
        '401':
          description: Unauthorized. Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Unsupported market or mint not indexed yet.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/UnsupportedResponse'
                  - $ref: '#/components/schemas/NotIndexedResponse'
        '422':
          description: Valid request but no viable route found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limited. Back off and retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    BuildSellTxRequest:
      type: object
      required:
        - mint
        - user_pubkey
        - amount_tokens
        - output
        - slippage_bps
      properties:
        mint:
          type: string
          description: Token mint address (base58).
          example: So11111111111111111111111111111111111111112
        user_pubkey:
          type: string
          description: Your wallet public key (base58).
          example: 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
        amount_tokens:
          type: integer
          description: Amount to sell in the token's atomic units.
          example: 1000000
        output:
          type: string
          enum:
            - SOL
            - USD1
          description: Desired output asset.
          example: SOL
        slippage_bps:
          type: integer
          description: Maximum slippage tolerance in basis points (e.g., `2000` = 20%).
          example: 2000
        mode:
          type: string
          enum:
            - fast
            - secure
          default: fast
          description: Routing mode hint.
        market_context:
          type: object
          description: >-
            Pre-resolved market context. Omit to let the server resolve
            automatically.
        send_mode:
          type: string
          enum:
            - helius_sender
            - astralane
            - rpc
          description: Transaction send mode.
        tip_lamports:
          type: integer
          description: Optional priority fee tip in lamports.
        partner_fee_recipient:
          type: string
          description: Partner fee recipient wallet (base58 pubkey).
        partner_fee_bps:
          type: integer
          description: >-
            Partner fee in basis points (max 50 = 0.5%). Mutually exclusive with
            `partner_fee_lamports`.
          maximum: 50
        partner_fee_lamports:
          type: integer
          description: >-
            Partner fee as flat SOL lamports (max 50,000,000). Mutually
            exclusive with `partner_fee_bps`.
          maximum: 50000000
    BuildTxResponse:
      type: object
      required:
        - tx
      properties:
        tx:
          type: string
          description: >-
            Base64-encoded unsigned Solana `VersionedTransaction`. Sign this
            locally with your keypair before submitting.
          example: AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
        route:
          type: object
          description: Routing metadata.
          properties:
            market_type:
              type: string
              description: DEX used for this route.
              example: pumpswap
            pool_id:
              type: string
              description: Pool address used.
        debug:
          type: object
          description: Debug information (included when available).
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
          example: invalid mint address
    UnsupportedResponse:
      type: object
      required:
        - status
        - reason
        - message
      properties:
        status:
          type: string
          const: unsupported
        reason:
          type: string
          enum:
            - no_route
            - invalid_mint
            - unsupported_token_program
          description: Machine-readable reason code.
        message:
          type: string
          description: Human and AI-readable explanation.
          example: >-
            No supported market found for this mint. Supported DEXs: PumpSwap,
            Raydium (CPMM, Launchpad), Meteora (DBC, DAMM v2), Pump.fun.
    NotIndexedResponse:
      type: object
      required:
        - status
        - mint
        - reason
      properties:
        status:
          type: string
          const: not_indexed
        mint:
          type: string
          description: The mint address that is not yet indexed.
        reason:
          type: string
          example: mint not indexed yet; try again shortly
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your LaserSell API key. Obtain one from the [LaserSell
        dashboard](https://www.lasersell.io).

````