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

# Advanced swap (Solana)

> Execute a low-latency synchronous Solana token swap with an embedded wallet.

<Warning>
  This is a [Privy Labs API](/api-reference/labs/overview). It is subject to change as Privy
  iterates on the design with partners. Privy provides at least three months of notice before
  removing a documented Labs API.
</Warning>

### Overview

The advanced swap endpoint performs a synchronous Solana token swap in a single request: Privy
fetches a quote, signs the transaction via the enclave, and submits it to the network. Wallet data
preparation is parallelized with the swap quote fetching to minimize latency.

Unlike the standard [swap endpoint](/api-reference/wallets/swap/tokens), this endpoint returns the
signed transaction directly rather than creating an asynchronous wallet action.

To learn more about the design of this endpoint, see [our blog post on reducing trading latency](https://privy.io/blog/reducing-trading-latency-on-privy).

### Prerequisites

* The wallet must be a **Solana** embedded wallet
* Your app must be approved for access to this Labs endpoint

***

### Considerations

This endpoint behaves similarly to [`optimistic_broadcast`](/api-reference/wallets/solana/sign-and-send-transaction) on the standard Solana sign-and-send endpoint:

* The response is returned as soon as the transaction is signed and submitted, it does not wait for onchain confirmation.
* The `submission_status` field indicates whether the network acknowledged the transaction, not whether it confirmed onchain. Monitor the returned `transaction_hash` via Solana RPC for final status.
* The `signed_transaction` field contains the fully signed transaction (base64-encoded), which can be rebroadcast to any Solana RPC endpoint for redundancy or improved landing rates.
* Your app is responsible for checking transaction validity and rebroadcasting if needed.


## OpenAPI

````yaml post /v1/wallets/{wallet_id}/experimental/solana/advanced-swap
openapi: 3.1.0
info:
  version: 0.0.1
  title: Privy API
  description: >-
    REST API for Privy's wallet infrastructure — provision and manage wallets
    across EVM, Solana, and Bitcoin, authenticate users, sign transactions, and
    configure programmable policies and authorization intents.
  contact:
    name: Privy
    url: https://www.privy.io/
    email: support@privy.io
servers:
  - url: https://api.privy.io
security: []
tags:
  - name: Accounts
    description: Operations related to asset accounts
  - name: Aggregations
    description: Operations related to aggregations for tracking and measuring metrics
  - name: Apps
    description: Operations related to app settings and allowlist management
  - name: Client Auth
    description: OAuth token exchange and device authorization operations
  - name: Condition Sets
    description: Operations related to condition sets
  - name: Embedded wallets
    description: Operations related to embedded wallet creation and authentication
  - name: Fiat
    description: Operations related to fiat onramping and offramping
  - name: Intents
    description: Operations related to authorization intents for wallet actions
  - name: Key quorums
    description: Operations related to key quorums
  - name: Kraken Embed
    description: >-
      Operations for Kraken Embed integration, including quotes, trades, user
      management, and portfolio operations
  - name: OAuth
    description: >-
      OAuth 2.0 endpoints including Device Authorization Grant (RFC 8628) for
      CLI and limited-input device login flows
  - name: Organizations
    description: Operations related to organization secret management
  - name: Policies
    description: Operations related to policies
  - name: Shared
    description: Common schemas shared across resources
  - name: Swaps
    description: Operations for swapping tokens within wallets
  - name: Transactions
    description: Operations related to transactions
  - name: User signers
    description: Operations related to user signers
  - name: Users
    description: Operations related to users
  - name: Wallet Actions
    description: Operations related to wallet actions
  - name: Wallets
    description: Operations related to wallets
  - name: Webhooks
    description: >-
      Webhook events that Privy sends to your configured endpoint when specific
      actions occur in your app
  - name: Yield
    description: >-
      Operations for depositing and withdrawing funds from ERC-4626 yield vaults
      (Morpho, Aave)
paths:
  /v1/wallets/{wallet_id}/experimental/solana/advanced-swap:
    post:
      tags:
        - Wallet Actions
      summary: Advanced swap
      description: >-
        Execute a synchronous Solana token swap: fetch a quote, sign via the
        enclave, submit to Jito, and return the signed transaction and quote
        details — all in a single request.
      operationId: advancedSwap
      parameters:
        - schema:
            type: string
            description: ID of the wallet.
          required: true
          name: wallet_id
          in: path
        - schema:
            type: string
            description: ID of your Privy app.
          required: true
          name: privy-app-id
          in: header
        - schema:
            type: string
            description: >-
              Request authorization signature. If multiple signatures are
              required, they should be comma separated.
          required: false
          name: privy-authorization-signature
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdvancedSwapRequestBody'
            example:
              input_token: So11111111111111111111111111111111111111112
              output_token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
              caip2: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
              amount: '1000000000'
              slippage_bps: 50
              platform_fee_bps: 100
              fee_recipient: FeeAcct...
      responses:
        '200':
          description: Swap executed successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdvancedSwapResponse'
              example:
                transaction_hash: 5K4f...base58sig
                submission_status: accepted
                signed_transaction: AQAAAA...base64...
                provider: dflow
                input_token: So11111111111111111111111111111111111111112
                output_token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                in_amount: '1000000000'
                out_amount: '173500000'
                min_out_amount: '172632500'
                slippage_bps: 50
                platform_fee:
                  amount: '1735000'
                  bps: 100
                  token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
      security:
        - appSecretAuth: []
components:
  schemas:
    AdvancedSwapRequestBody:
      type: object
      properties:
        input_token:
          type: string
          description: Input token address (base58 mint address).
        output_token:
          type: string
          description: Output token address (base58 mint address).
        caip2:
          type: string
          description: CAIP-2 chain identifier. Defaults to Solana mainnet.
        amount:
          type: string
          description: >-
            Amount in the smallest unit of the input token (e.g. lamports for
            SOL).
        slippage_bps:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 10000
            - type: string
              enum:
                - auto
          default: auto
          description: >-
            Max slippage tolerance in basis points (0-10000), or "auto" for
            provider-determined. Defaults to "auto".
        dry_run:
          type: boolean
          description: >-
            When true, skip transaction submission (quote + sign only). The
            signed transaction is still returned.
        platform_fee_bps:
          type: integer
          minimum: 0
          maximum: 10000
          description: >-
            Platform fee in basis points, taken from the output token. Requires
            fee_recipient when > 0.
        fee_recipient:
          type: string
          description: >-
            Token account (base58) to receive the platform fee. Must exist
            on-chain for the output token.
      required:
        - input_token
        - output_token
        - amount
      additionalProperties: false
      description: >-
        Request body for initiating a synchronous Solana token swap through an
        embedded wallet.
      title: AdvancedSwapRequestBody
      example:
        input_token: So11111111111111111111111111111111111111112
        output_token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        caip2: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
        amount: '1000000000'
        slippage_bps: 50
        platform_fee_bps: 100
        fee_recipient: FeeAcct...
      x-stainless-model: wallets.advanced_swap_request_body
    AdvancedSwapResponse:
      type: object
      properties:
        transaction_hash:
          type: string
          description: Solana transaction signature (base58).
        submission_status:
          $ref: '#/components/schemas/SwapSubmissionStatus'
        signed_transaction:
          type: string
          description: >-
            Fully signed transaction (base64). Callers can re-submit to any
            Solana RPC for redundancy.
        provider:
          type: string
          description: Which aggregator fulfilled the swap (e.g. "dflow").
        input_token:
          type: string
          description: Input token address (base58).
        output_token:
          type: string
          description: Output token address (base58).
        in_amount:
          type: string
          description: Input amount consumed (smallest unit).
        out_amount:
          type: string
          description: Expected output amount before slippage (smallest unit).
        min_out_amount:
          type: string
          description: >-
            Minimum output amount guaranteed by slippage tolerance (smallest
            unit).
        slippage_bps:
          type: integer
          description: >-
            Slippage applied in basis points. Reflects the resolved value if
            "auto" was requested.
        platform_fee:
          allOf:
            - $ref: '#/components/schemas/AdvancedSwapPlatformFee'
            - description: Platform fee details, present when a fee was applied.
      required:
        - transaction_hash
        - submission_status
        - signed_transaction
        - provider
        - input_token
        - output_token
        - in_amount
        - out_amount
        - min_out_amount
        - slippage_bps
      additionalProperties: false
      description: Response from the synchronous Solana swap endpoint.
      title: AdvancedSwapResponse
      example:
        transaction_hash: 5K4f...base58sig
        submission_status: accepted
        signed_transaction: AQAAAA...base64...
        provider: dflow
        input_token: So11111111111111111111111111111111111111112
        output_token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        in_amount: '1000000000'
        out_amount: '173500000'
        min_out_amount: '172632500'
        slippage_bps: 50
        platform_fee:
          amount: '1735000'
          bps: 100
          token: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
      x-stainless-model: wallets.advanced_swap_response
    SwapSubmissionStatus:
      type: string
      enum:
        - accepted
        - rejected
        - skipped
      description: >-
        "accepted" if the network has acknowledged the transaction, "rejected"
        if the network refused it, "skipped" if dry_run was set. Not an onchain
        confirmation.
      title: SwapSubmissionStatus
      x-stainless-model: wallets.swap_submission_status
    AdvancedSwapPlatformFee:
      type: object
      properties:
        amount:
          type: string
          description: Fee amount in the smallest unit of the fee token.
        bps:
          type: integer
          description: Fee in basis points.
        token:
          type: string
          description: Token the fee was taken from (output token in v1).
      required:
        - amount
        - bps
        - token
      additionalProperties: false
      description: Platform fee collected on a swap.
      title: AdvancedSwapPlatformFee
      x-stainless-model: wallets.advanced_swap_platform_fee
  securitySchemes:
    appSecretAuth:
      type: http
      scheme: basic
      description: >-
        Basic Auth header with your app ID as the username and your app secret
        as the password.

````