# Stablecoin FX Quick Start

**Requirements to be able to trade stablecoins on Kii, via dashboard or API:**

* Have a user&#x20;
* Have an account level 1 at least (to upgrade from level 0 to level 1, you need to complete our KYC verification inside your user settings)&#x20;
* Have balances on any stablecoin

## Endpoints

**Staging URL :**&#x20;

```yaml
https://apstage.proxy.kiiex.io/ap
```

**Prod URL :**&#x20;

```yaml
https://alphaprod.proxy.kiiex.io/ap
```

## Swap Workflow example

For this example will assume a goal and specify what to do in order, also we'll provide you with all the endpoints related to each step. The goal is:

* **Swap USDT → COPM** using a market order.

### Prerequisites

These are the prerequisites for the step-by-step guide.

1. Create your Kii account:
   1. Go to <https://kiiex.io/> and click on login, and create your user
      1. You can also follow our guide on [Set up your Kii Account](/docs/connect-to-kiiex/set-up-your-kiiex-account.md)
2. Update your account from level 0 to level 1 by following our KYC flow to be able to swap
3. Create your trader API Key on our panel to follow the next steps

### Step-by-step

These are the steps to fully create a swap and withdraw it:

1. Authenticate your user via api
   1. [#authenticate-your-user-via-api](#authenticate-your-user-via-api "mention")
2. Create a USDT deposit. If you have already created a deposit, check your current balance
   1. [#create-deposit](#create-deposit "mention")
   2. [#post-getaccountpositions](#post-getaccountpositions "mention")
3. Get the current COPM/USDT rate
   1. [#get-current-rate](#get-current-rate "mention")
4. Create market order (buy COPM)
   1. [#create-a-swap](#create-a-swap "mention")
5. Verify order was filled
   1. [#get-swap-status](#get-swap-status "mention")
6. Get trade details (swap info)
   1. [#post-gettradeshistory](#post-gettradeshistory "mention")
7. Confirm the new COPM balance using the get account positions endpoint
   1. [#get-account-balances](#get-account-balances "mention")
8. Create a COPM withdrawal, it could be to another wallet or to your bank account
   1. [#create-a-withdrawal](#create-a-withdrawal "mention")
9. Check your COPM withdrawal status
   1. [#check-withdrawal-status](#check-withdrawal-status "mention")

**How do I perform the swap workflow using the API?**

## API endpoints

### Authenticate your User via API

## POST /AuthenticateUser

> Authenticate user session

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/AuthenticateUser":{"post":{"summary":"Authenticate user session","operationId":"authenticateUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"APIKey":{"type":"string"},"Signature":{"type":"string"},"UserId":{"type":"string"},"UserName":{"type":"string"},"Nonce":{"type":"string"}}}]}}}},"responses":{"200":{"description":"Authentication result","content":{"application/json":{"schema":{"type":"object","properties":{"authenticated":{"type":"boolean"},"user":{"type":"object","properties":{"userId":{"type":"integer"},"userName":{"type":"string"},"email":{"type":"string"},"emailVerified":{"type":"boolean"},"accountId":{"type":"integer"},"omsId":{"type":"integer"},"use2FA":{"type":"boolean"}}}}}}}}}}}}}
```

### Create Deposit

## POST /CreateDepositTicket

> Create a new deposit ticket

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/CreateDepositTicket":{"post":{"summary":"Create a new deposit ticket","operationId":"createDepositTicket","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"assetManagerId":{"type":"integer"},"accountId":{"type":"integer"},"assetId":{"type":"integer"},"assetName":{"type":"string","nullable":true},"amount":{"type":"number"},"omsId":{"type":"integer"},"requestCode":{"type":"string","nullable":true},"requestIP":{"type":"string","nullable":true},"requestUser":{"type":"integer"},"requestUserName":{"type":"string","nullable":true},"operatorId":{"type":"integer"},"Status":{"type":"integer"},"feeAmt":{"type":"number"},"updatedByUser":{"type":"integer"},"updatedByUserName":{"type":"string","nullable":true},"ticketNumber":{"type":"integer"},"depositInfo":{"type":"string","nullable":true},"createdTimestamp":{"type":"string","format":"date-time"},"lastUpdateTimestamp":{"type":"string","format":"date-time"},"comments":{"type":"string","nullable":true},"attachments":{"type":"string","nullable":true}}}}}},"responses":{"200":{"description":"Deposit ticket creation result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"requestcode":{"type":"string"}}}}}}}}}}}
```

### Get Account Balances

## POST /GetAccountPositions

> Get account positions (balances)

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/GetAccountPositions":{"post":{"summary":"Get account positions (balances)","operationId":"getAccountPositions","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"AccountId":{"type":"integer"},"OMSId":{"type":"integer"},"IncludePending":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Account balances","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"omsId":{"type":"integer"},"accountId":{"type":"integer"},"productSymbol":{"type":"string"},"productId":{"type":"integer"},"amount":{"type":"number"},"hold":{"type":"number"}}}}}}}}}}}}
```

### Get Current Rate

## POST /GetLevel1SummaryMin

> Get market snapshot

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/GetLevel1SummaryMin":{"post":{"summary":"Get market snapshot","operationId":"getLevel1SummaryMin","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"OMSId":{"type":"integer"},"BaseCurrency":{"type":"string"},"QuoteCurrency":{"type":"string"},"InstrumentIds":{"type":"string"}}}}}},"responses":{"200":{"description":"Market data snapshot","content":{"application/json":{"schema":{"type":"array","items":{"type":"array","items":{"type":"string"}}}}}}}}}}}
```

### Create a SWAP

## POST /SendOrder

> Create a new order

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/SendOrder":{"post":{"summary":"Create a new order","operationId":"sendOrder","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"InstrumentId":{"type":"integer"},"OMSId":{"type":"integer"},"AccountId":{"type":"integer"},"TimeInForce":{"type":"integer"},"ClientOrderId":{"type":"integer"},"OrderIdOCO":{"type":"integer"},"UseDisplayQuantity":{"type":"boolean"},"Side":{"type":"integer"},"quantity":{"type":"number"},"OrderType":{"type":"integer"},"PegPriceType":{"type":"integer"},"LimitPrice":{"type":"number"},"PostOnly":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Order status","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"errormsg":{"type":"string"},"OrderId":{"type":"integer"}}}}}}}}}}}
```

### Get SWAP status

## POST /GetOrderStatus

> Get single order status

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/GetOrderStatus":{"post":{"summary":"Get single order status","operationId":"getOrderStatus","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"omsId":{"type":"integer"},"accountId":{"type":"integer"},"orderId":{"type":"integer"}}}}}},"responses":{"200":{"description":"Order status details","content":{"application/json":{"schema":{"type":"object","properties":{"OrderId":{"type":"integer"},"OrderState":{"type":"string"},"QuantityExecuted":{"type":"number"},"AvgPrice":{"type":"number"}}}}}}}}}}}
```

## POST /GetTradesHistory

> Get trades history

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/GetTradesHistory":{"post":{"summary":"Get trades history","operationId":"getTradesHistory","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"omsId":{"type":"integer"},"accountId":{"type":"integer"},"instrumentId":{"type":"integer"},"tradeId":{"type":"integer"},"orderId":{"type":"integer"},"userId":{"type":"integer"},"startTimestamp":{"type":"integer"},"endTimestamp":{"type":"integer"},"depth":{"type":"integer"},"startIndex":{"type":"integer"},"executionId":{"type":"integer"}}}}}},"responses":{"200":{"description":"List of executed trades","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"tradeId":{"type":"integer"},"orderId":{"type":"integer"},"quantity":{"type":"number"},"price":{"type":"number"}}}}}}}}}}}}
```

### Create a Withdrawal

## POST /CreateWithdrawTicket

> Initiates the withdrawal of funds from an account

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/CreateWithdrawTicket":{"post":{"summary":"Initiates the withdrawal of funds from an account","operationId":"createWithdrawTicket","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"OMSId":{"type":"integer"},"AccountId":{"type":"integer"},"ProductId":{"type":"integer"},"Amount":{"type":"number"},"feeAmount":{"type":"number"},"TemplateForm":{"type":"object"},"TemplateType":{"type":"string"}}}}}},"responses":{"200":{"description":"Withdrawal request result","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"boolean"},"errormsg":{"type":"string"},"errorcode":{"type":"integer"},"detail":{"type":"string"}}}}}}}}}}}
```

### Check Withdrawal status

## POST /GetWithdrawTickets

> Returns an array of withdraw tickets from the specified OMS and Account

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"paths":{"/GetWithdrawTickets":{"post":{"summary":"Returns an array of withdraw tickets from the specified OMS and Account","operationId":"getWithdrawTickets","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"OMSId":{"type":"integer"},"AccountId":{"type":"integer"},"StartIndex":{"type":"integer"},"Limit":{"type":"integer"}}}}}},"responses":{"200":{"description":"List of withdraw tickets","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"assetManagerId":{"type":"integer"},"accountId":{"type":"integer"},"assetId":{"type":"integer"},"assetName":{"type":"string"},"amount":{"type":"number"},"templateForm":{"type":"string"},"templateFormType":{"type":"string"},"omsId":{"type":"integer"},"requestCode":{"type":"string"},"requestIP":{"type":"string"},"requestUserId":{"type":"integer"},"requestUserName":{"type":"string"},"operatorId":{"type":"integer"},"Status":{"type":"integer"},"feeAmt":{"type":"number"},"updatedByUser":{"type":"integer"},"updatedByUserName":{"type":"string"},"ticketNumber":{"type":"integer"},"createdTimestamp":{"type":"string","format":"date-time"},"lastUpdateTimestamp":{"type":"string","format":"date-time"},"Comments":{"type":"string"},"Attachments":{"type":"string"},"AuditLog":{"type":"string"}}}}}}}}}}}}
```


---

# 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.kiiglobal.io/docs/connect-to-kiiex/stablecoin-fx-quick-start.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.
