# Runes

## POST /brc20swap/get\_swap\_psbt2

> Get the unsigned PSBT for exchange

```json
{"openapi":"3.0.1","info":{"title":"Backend API","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap official"}],"security":[],"paths":{"/brc20swap/get_swap_psbt2":{"post":{"summary":"Get the unsigned PSBT for exchange","deprecated":false,"description":"","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"send_coin_type":{"type":"string","title":"The type of coin to send"},"send_tick":{"type":"string","title":"The tick of the coin to send"},"send_amount":{"type":"string","title":"The amount to send"},"receive_coin_type":{"type":"string","title":"The type of coin to receive"},"receive_tick":{"type":"string","title":"The tick of the coin to receive"},"receive_amount":{"type":"string","title":"The amount to receive"},"address":{"type":"string","title":"Address"},"slipper":{"type":"integer"},"fee_rate":{"type":"integer"},"user_public_key":{"type":"string"},"chl":{"type":"string"},"method":{"type":"string","description":"Non-cross-pool swap, cross-pool pools_swap, just pass 'pools_swap'"},"token":{"type":"string"},"btc_address":{"type":"string"}},"required":["receive_amount","receive_coin_type","receive_tick","send_amount","send_coin_type","send_tick","slipper","fee_rate","token","user_public_key","address","btc_address","chl"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"order_id":{"type":"string"},"psbt":{"type":"string"},"check_sign_only":{"type":"boolean"}},"required":["order_id","psbt","check_sign_only"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

#### Important Notes:

{% hint style="info" %}

1. After obtaining the unsigned PSBT, the user must sign it within 30 seconds.
2. Use the same address for both `btc_address` and `address`.
3. For `user_public_key`, provide the parameter as `public_key:public_key` for a wallet with one address, or `btc_public_key:ordi_public_key` for a wallet with two addresses.
4. The `token` must be retrieved from the `/swap-info` endpoint and can only be used once.
   {% endhint %}

## POST /brc20swap/send\_swap\_psbt

> Send the signed PSBT for exchange

```json
{"openapi":"3.0.1","info":{"title":"Backend API","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap official"}],"security":[],"paths":{"/brc20swap/send_swap_psbt":{"post":{"summary":"Send the signed PSBT for exchange","deprecated":false,"description":"","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"order_id":{"type":"string","title":"Order ID"},"psbt":{"type":"string","title":"Signed PSBT"}},"required":["order_id","psbt"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"tx_id":{"type":"string","title":"The txid of the rawtx in PSBT"},"order_id":{"type":"string","title":"The corresponding order ID"},"need_show_task":{"type":"boolean"}},"required":["tx_id"]}},"required":["code","msg","data"]}}},"headers":{}}}}}}}
```

After sending the signed PSBT, a successful response indicates that the swap was successful.

### Extending Signing Duration <a href="#extend-sign-duration" id="extend-sign-duration"></a>

If you are using a hardware wallet, the signing process might take longer. To help us identify it being a hardware wallet, you can add the following header to the API requests:

```
Wallet-Type: 'ledger' | 'software'
```

For example:

```javascript
config.headers["Wallet-Type"] = "ledger"; // Setting it to 'ledger' will extend the signing time, please use 'software' by default
```

{% tabs %}
{% tab title="cURL Example" %}

```bash
curl 'https://api.dotswap.app/brc20swap/send_swap_psbt' \
 -H 'Accept: application/json, text/plain, _/_' \
 -H 'Accept-Language: en' \
 -H 'Cache-Control: no-cache' \
 -H 'Connection: keep-alive' \
 -H 'Content-Type: application/json' \
 -H 'Pragma: no-cache' \
 -H 'Sec-Fetch-Dest: empty' \
 -H 'Sec-Fetch-Mode: cors' \
 -H 'Sec-Fetch-Site: cross-site' \
 -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
 -H 'Wallet-Name: unisat' \
 -H 'Wallet-Type: software' \
 -H 'Wallet-Ver: 1.5.4' \
 -H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
 -H 'sec-ch-ua-mobile:?0' \
 -H 'sec-ch-ua-platform: "macOS"' \
 --data-raw '{"order_id":"swap_1071645262503477248","psbt":"70736274ff0100f302000000020a405df30d988160e1c3d3f046e7526e75a2522102e3a6b8dfbdb2fafe38df650600000000ffffffff90295f92edbbabe2ecb25d6f4eba74c91a930ebed4d6d51aac59eaf461328a110000000000ffffffff044a01000000000000225120e3552a2c24a4238a7344f655f04ceb0d14f381fbd9a4b90278d88257125444214a010000000000002251201447eda7459a2ab79ef45fc9173885d84b9604a746f7d2062eef08612536fa3500000000000000000d6a5d0a00c0a23303968ebd0e01e803000000000000225120c01dcf308ab6e8e0791741beda33a700406a94621eb9a1ee22bc95f3ea7bc1e0000000000001012bd20b0000000000002251201447eda7459a2ab79ef45fc9173885d84b9604a746f7d2062eef08612536fa3501084301414da5d08b5d44a76e600e41fb765d9eabe97c11d5bdeb3f2e61141567ac18bcfe1758f833591b24589e818deaa199a597b115cec9d04099c7a9fd2063532676fc010001012b4a01000000000000225120e3552a2c24a4238a7344f655f04ceb0d14f381fbd9a4b90278d8825712544421010304010000000000000000"}'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.on.nexus/dotswap/developers/l1-swap-and-liquidity-apis/swap_v2/runes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
