---
title: "Get an unsigned PSBT for swapping runes"
method: POST
path: "/v2/ord/btc/runes/psbt/swap"
tags: ["Runes Swap"]
---

# Get an unsigned PSBT for swapping runes

`POST /v2/ord/btc/runes/psbt/swap`

## Request

- Base URL: `https://api-mainnet.magiceden.dev/v2`
- URL: `https://api-mainnet.magiceden.dev/v2/v2/ord/btc/runes/psbt/swap`
- Auth: none declared
- TypeScript: <https://skmtc.dev/magiceden/apis/magic-eden-api/docs/v2/ord/btc/runes/psbt/swap/post.ts> (a function with typed inputs; its response is checked against the schema)

Get an unsigned PSBT for swapping runes

## Request body

- GetRuneSwapPsbtRequestSchema
  - `amount` string, bigint, required: The amount for the swap, represented as a string to accommodate large integers.
  - `priceToleranceBp` integer, nullable: The price tolerance in percentate x 10000.
  - `runeTicker` string, required: The ticker symbol for the rune.
  - `side` 'buy' | 'sell', required: The side of the trade, either "buy" or "sell".
  - `takerPaymentAddress` string, required: The payment address of the taker.
  - `takerPublicKey` string, nullable: The public key of the taker, required for buying.
  - `takerRunesAddress` string, required: The runes address of the taker.
  - `takerRunesPublicKey` string, nullable: The runes public key of the taker, required for selling.
  - `feeRateTier` 'custom' | 'minimumFee' | 'halfHourFee' | 'hourFee' | 'fastestFee': The fee rate tier.
  - `feeRateNum` number, nullable: The numerical fee rate.
  - `legacyListingOnly` boolean, nullable: Flag indicating if only legacy listings should be considered.
  - `rbfPreventionListingOnly` boolean, nullable: Flag indicating if only RBF prevention listings should be considered.

## Response `200`

Successful response

- GetRuneSwapPsbtResponseSchema
  - `btcChangeOutputIndex` integer, nullable: The index of the BTC change output, optional for sweeping post split.
  - `errors` RuneSwapErrorSchema[], nullable: An array of errors encountered during the swap process.
    - `type` 'legacy-buy' | 'rbf-buy' | 'market-sell', required: The type of the Rune swap transaction error.
    - `message` string, required: The error message.
  - `psbts` RuneSwapPsbtSchema[], required: An array of PSBTs (Partially Signed Bitcoin Transactions).
    - `type` 'legacy-buy' | 'rbf-buy' | 'market-sell', required: The type of the Rune swap transaction.
    - `paymentUtxoIndexes` integer[], required: Array of payment UTXO indexes.
    - `psbtBase64` string, required: The PSBT (Partially Signed Bitcoin Transaction) in base64 format.
    - `settlement` SettlementSchema, required
      - `amount` string, bigint, required: A large integer value, represented the total amount of runes.
      - `price` number, float, required: The price value as a floating-point number, represented the total amount of BTC payment.
    - `runeUtxoIndexes` integer[], required: Array of rune UTXO indexes.
  - `quote` GetQuoteResponseSchema, required
    - `amount` string, bigint, required: The total amount for the quote, represented as a string to accommodate large integers.
    - `averageUnitPrice` number, required: The average unit price.
    - `bestUnitPrice` number, required: The best unit price available.
    - `maxUnitPrice` number, required: The maximum unit price.
    - `minUnitPrice` number, required: The minimum unit price.
    - `price` number, required: The total price.
    - `orders` object[], required
      - `amount` string, bigint: The amount for the order, represented as a string to accommodate large integers.
      - `id` string: The unique identifier for the order.
  - `settlement` SettlementSchema, required
    - `amount` string, bigint, required: A large integer value, represented the total amount of runes.
    - `price` number, float, required: The price value as a floating-point number, represented the total amount of BTC payment.
  - `requestId` string, required: The unique request identifier.

---

[API](https://skmtc.dev/magiceden/apis/magic-eden-api.md) - [All operations](https://skmtc.dev/magiceden/apis/magic-eden-api/llms.txt) - [OpenAPI document](https://skmtc.dev/magiceden/apis/magic-eden-api/revisions/66028b292693?raw)
