---
title: "Create Swap Instructions"
method: POST
path: "/swap-instructions"
tags: ["Swap"]
---

# Create Swap Instructions

`POST /swap-instructions`

Returns Solana swap instructions for a given token pair and amount.

## Headers

- `0x-api-key` string, required

## Request body

- SwapInstructionsRequest — Request body for the swap-instructions endpoint.
  - `amount_in` integer, required — Input amount in its base units.
  - `disabled_sources` string[] — DEX sources to exclude from routing. Valid source names are returned by `/enabled-sources`.
  - `recipient` union — A swap destination: either an existing token account (or wallet for native SOL) address, or an owner whose token account should be used, and created if required. If an account is created, its rent is paid by `sponsor` if present, else by `taker`. If the created ATA belongs to the taker, the sponsor keeps close authority and can reclaim the rent once the account is empty. ATAs created for anyone else (custom recipient, fee or surplus recipient) leave the rent as a permanent sponsor cost.
    - string — An existing base-58 encoded token account (or wallet for native SOL) address.
    - AssociatedTokenAccountDestination
      - `associatedTokenAccount` AssociatedTokenAccountOwner, required
        - `owner` string, required — Base-58 encoded owner address that the created token account belongs to.
  - `reserve_transaction_bytes` integer — Minimum bytes to reserve in the transaction for composing with additional instructions.
  - `slippage_bps` integer — Slippage tolerance in basis points.
  - `sponsor` string — Transaction fee payer and rent payer for a fully-sponsored swap. Must differ from the taker and from every native destination in the request. The taker remains the swap authority and must still sign.
  - `swap_fee_ppm` string — Comma-separated volume-based swap fees in parts per million. Must be provided together with `swap_fee_recipient`. Each entry must be between `0` and the per-app maximum (`100_000` unless configured otherwise). A value of `0` disables that fee entry. Multiple fees on the same side are applied sequentially, each on the amount remaining after prior deductions — not the original amount. Fee amounts are rounded up to the nearest base unit.
  - `swap_fee_recipient` union — Fee recipients for the swap fees: either a comma-separated list of existing token accounts, or a structured list mixing addresses with owners whose token accounts should be the fee recipient.
    - string — Comma-separated base-58 encoded token account addresses.
    - Destination[] — Structured list of destinations, one per fee entry.
      - union — A swap destination: either an existing token account (or wallet for native SOL) address, or an owner whose token account should be used, and created if required. If an account is created, its rent is paid by `sponsor` if present, else by `taker`. If the created ATA belongs to the taker, the sponsor keeps close authority and can reclaim the rent once the account is empty. ATAs created for anyone else (custom recipient, fee or surplus recipient) leave the rent as a permanent sponsor cost.
        - string — An existing base-58 encoded token account (or wallet for native SOL) address.
        - AssociatedTokenAccountDestination
          - `associatedTokenAccount` AssociatedTokenAccountOwner, required
            - `owner` string, required — Base-58 encoded owner address that the created token account belongs to.
  - `swap_fee_side` string — Comma-separated fee sides for each fee entry. Supported values are `buy` and `sell`. This field may be omitted only when every fee uses the default `buy` side. When provided, the number of entries must match `swap_fee_ppm`.
  - `taker` string, required — Base-58 encoded taker wallet address.
  - `token_in` string, required — Input token mint, base-58 encoded. Use `So11111111111111111111111111111111111111111` for native SOL.
  - `token_out` string, required — Output token mint, base-58 encoded. Use `So11111111111111111111111111111111111111111` for native SOL.
  - `trade_surplus_cap_ppm` integer — Trade surplus cap in parts per million of the total realized trade size. Must be provided together with `trade_surplus_recipient`, or both fields must be omitted. A value of `0` disables trade surplus collection for the request. When 0x controls trade surplus collection, the request value is ignored and the configured 0x policy is applied instead. The transferred amount is capped relative to trade size.
  - `trade_surplus_recipient` union — A swap destination: either an existing token account (or wallet for native SOL) address, or an owner whose token account should be used, and created if required. If an account is created, its rent is paid by `sponsor` if present, else by `taker`. If the created ATA belongs to the taker, the sponsor keeps close authority and can reclaim the rent once the account is empty. ATAs created for anyone else (custom recipient, fee or surplus recipient) leave the rent as a permanent sponsor cost.
    - string — An existing base-58 encoded token account (or wallet for native SOL) address.
    - AssociatedTokenAccountDestination
      - `associatedTokenAccount` AssociatedTokenAccountOwner, required
        - `owner` string, required — Base-58 encoded owner address that the created token account belongs to.

## Response `200`

Swap instructions

- SwapInstructionsResponse — Swap instructions API response.
  - `address_lookup_tables` string[], required — Address Lookup Table addresses that must be included in the versioned transaction.
  - `amount_out` integer, required — The estimated output amount after fees, in its base units.
  - `instructions` Instruction[], required — The instructions to perform the swap.
    - `accounts` AccountMeta[], required
      - `is_signer` boolean, required
      - `is_writable` boolean, required
      - `pubkey` integer[], required — Account public key as a 32-byte array.
    - `data` integer[], required — Serialized instruction data bytes.
    - `program_id` integer[], required — Program ID as a 32-byte array.
  - `min_amount_out` integer, required — The minimum output amount after slippage and fees, in its base units. Transaction will fail if this amount is not met.
  - `route_plan` SwapInstructionsRoutePlanStep[], required — List of swap legs comprising the swap.
    - `amount_in` string, required — The amount of the input token to swap, in its base units.
    - `amount_out` string, required — The estimated amount of the output token received from the swap, in its base units.
    - `dex_address` string, required — The base-58 encoded address of the DEX.
    - `dex_label` string, required — The label for the DEX. Matches labels returned by the `enabled-sources` endpoint.
    - `dex_program_id` string, required — The base-58 encoded program ID address of the DEX.
    - `ppb` integer, required — Proportion of _remaining_ amount routed through this step in parts per billion.
    - `token_in` string, required — The base-58 encoded address of the input mint.
    - `token_out` string, required — The base-58 encoded address of the output mint.
  - `sponsor` string — Present when the caller requested full sponsorship. The returned transaction must use this address as fee payer; both sponsor and taker sign.
  - `zid` string, required — Unique 12-byte hex identifier for this request.

## Other responses

- `4XX` — Client error
- `5XX` — Server error

## Changes

> 6 revisions in range; 4 could not be searched.

- **2026-07-15** `07e63227e266` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/0xproject/apis/solana-api/changes/swap-instructions/post.md)

---

[API](https://skmtc.dev/0xproject/apis/solana-api.md) · [All operations](https://skmtc.dev/0xproject/apis/solana-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/0xproject/solana-api/revisions/39cc24f39810/schema)
