> For the complete documentation index, see [llms.txt](https://docs.inabit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inabit.com/api-reference/develop-with-inabit-api/transactions/create-exchange-swap.md).

# Create Exchange Swap

## Create a Swap Through an Exchange Wallet

Initiate a mutation to create an assets swap request for approval,  from one of your organization's exchange wallets

{% hint style="warning" %}
Please note that all is applicable **only** for **exchange** **wallet** swaps.
{% endhint %}

```graphql
mutation CreateSwap($data: SwapCreateInput!) {
  createSwap(data: $data) {
    id
    amount
    fee
    orderType
  }
}
```

### **Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

### Body (<mark style="color:orange;">WithdrawalCreateInput</mark>) object

| Name                                             | Type    | Description     |
| ------------------------------------------------ | ------- | --------------- |
| amount<mark style="color:red;">\*</mark>         | Integer | Swap Amount     |
| financialAsset<mark style="color:red;">\*</mark> | String  | Coin to swap    |
| swapAssetTo<mark style="color:red;">\*</mark>    | String  | Coin to swap to |
| walletId<mark style="color:red;">\*</mark>       | String  | Wallet ID       |

Example body:

```graphql
{
  "data": {
    "amount": 0.0051,
    "financialAsset": {
      "id": "clefn78h5012plc6rxbmofnop"
    },
    "swapAssetTo": {
      "id": "clefn78gv011olc6rcwtt0wel"
    },
    "wallet": {
      "id": "clp5bm4f1002icg01d526dgw9"
    }
  }
}
```

### Response

Return values:

| Name      | Type    | Description                                              |
| --------- | ------- | -------------------------------------------------------- |
| id        | String  | Swap ID                                                  |
| amount    | Integer | Swap Amount                                              |
| fee       | Integer | Fee Amount                                               |
| orderType | String  | Type of the order (Market/Limit) (will always be market) |

{% tabs %}
{% tab title="🟢 Success" %}

```javascript
{
	"data": {
		"createSwap": {
			"id": "clph3mik5000t8f01qqr0ol74",
			"amount": 0.0051,
			"fee": null,
			"orderType": "Market"
		}
	}
}
```

{% endtab %}

{% tab title="🔴 Failure" %}

{% endtab %}
{% endtabs %}

### Try it out!

{% embed url="<https://studio.apollographql.com/sandbox/explorer?endpoint=https://api.inabit.dev/graphql&explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4RxighigSwiQAIBhAJwXwQGUB3XABwAoASMfXdEh5y6igQBJJExwBCAJQlgAHVIkoVGn1ac8PDlxnzFJEgTAKDB3HAgxUJ0wDMECGwYgUwCCgBUAnk0eKAvgr+IAA0IABuuBQEuABGADYIAM4YIHoGcuBcmTzpppnmltYYJAAMAHSlpQCsAIwhTiSZtgRIuEhQMfEAgklJCCg5so0ZIEZDmVCJtkgA7AAcABbVpbUATEzxUABsFAAesRYzEEyZjf4N+k0gSYxMvf0oHhBDeabX4yWT03PzAObhVa1CBbXZQegoFClegIeJnK4XRqZRjxRKDEpvfJjYxfEBTJjVQ4AFlstSqawIUD+qzA1TW2zAf3oAE54e9AgEgqEQItqG4KClMGcQNymBAkihbPECH9FigAPK+Cj4IhIWjKAhMNCYED+IA>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.inabit.com/api-reference/develop-with-inabit-api/transactions/create-exchange-swap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
