# Create inabit Wallet Swap

## Create a Swap in an inabit Wallet

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

{% hint style="warning" %}
Please note that this mutation is applicable **only** for **inabit** **wallets**.
{% endhint %}

```graphql
mutation CreateInabitWalletSwap($data: InabitWalletSwapCreateInput!) {
  createInabitWalletSwap(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  | ID of Swapped From Asset  |
| swapAssetTo<mark style="color:red;">\*</mark>    | String  | ID of Swapped To Asset    |
| walletId<mark style="color:red;">\*</mark>       | String  | inabit Wallet ID          |
| note                                             | String  | Internal Note on the Swap |
| isAccelerated                                    | boolean | Always keep as null       |

Example body:

```graphql
{
  "data": {
    "amount": 0.0051,
    "blockchain": {
      "id": "" // FILL WITH CORRECT ID
    },
    "financialAsset": {
      "id": "clefn78h5012plc6rxbmofnop"
    },
    "note": null,
    "swapToBlockchain": {
      "id": ""  // FILL WITH CORRECT ID
    },
    "swapAssetTo": {
      "id": "clefn78gv011olc6rcwtt0wel"
    },
    "wallet": {
      "id": "clp5bm4f1002icg01d526dgw9"
    },
    "isAccelerated": null,
  }
}
```

### Response

Return values:

| Name   | Type    | Description                                      |
| ------ | ------- | ------------------------------------------------ |
| id     | String  | Swap ID                                          |
| amount | Integer | Swap Amount                                      |
| fee    | Integer | Fee Amount (in Native Asset of the "From Asset") |

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

```javascript
{
	"data": {
		"createSwap": {
			"id": "clph3mik5000t8f01qqr0ol74",
			"amount": 0.0051,
			"fee": 0.0014,
		}
	}
}
```

{% endtab %}

{% tab title="🔴 Assets Pair Not Supported" %}

```json
{
  "errors": [
    {
      "code": "OPERATION_FAILED",
      "message": "No InabitWalletSupportedPair found",
      "path": [
        "createInabitWalletSwap"
      ],
      "extensions": {
        "code": "OPERATION_FAILED",
        "message": "No InabitWalletSupportedPair found"
      }
    }
  ],
  "data": null
}
```

{% 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>" %}
