# API Withdrawal

Endpoints to mange withdrawals using the OFFCHAIN mechanism.

## Get Fund Locations

`GET /v2/fund-locations`

Get the list of available locations for withdrawals

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `locations` | string[] |  |


  Example (Fund locations):
  ```json
  {"locations":["FIAT","ETHEREUM","TRON","SOLANA","BITCOIN","BITCOIN_CASH","DOGECOIN","XRPL","LITECOIN"]}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/fund-locations" \
  -H "Authorization: Bearer <token>"
```

---

## Withdrawal Status

`GET /v2/offchain-withdrawals/{instructionId}`

Check the status of a withdrawal

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `instructionId` | path | Yes | string | Instruction Id - This is the client specified id when requesting (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id - This is the client specified id when requesting (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `withdrawalLocation` | string | Withdrawal location specified in your request. (e.g. `ETHEREUM`) |
  | `withdrawalLocationReference` | string | The withdrawal location reference specified in your request. (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `bankReference` | string | The bank reference specified in your request. (e.g. `withdrawal-reference-1`) |
  | `asset` | string | asset (e.g. `usd`) |
  | `amount` | string | amount (e.g. `5.67`) |
  | `status` | string | status |
  | `rejectionReason` | string | rejectionReason |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Insufficient funds):
  ```json
  {"code":"INSUFFICIENT_FUNDS","description":"Insufficient funds"}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```
- **404**: Withdrawal not found

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Unknown withdrawal request):
  ```json
  {"code":"UNKNOWN_WITHDRAWAL_REQUEST","description":"No withdrawal request found for instruction id 5"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/offchain-withdrawals/{instructionId}" \
  -H "Authorization: Bearer <token>"
```

---

## Withdrawal Request

`POST /v2/offchain-withdrawals`

Create a withdrawal request

**Request Body** _(required)_

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | This is your client reference id for the request. This can be any string less than 64 in length and needs to be unique per request (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `withdrawalLocation` | string | Withdrawal location (e.g. `ETHEREUM`) |
  | `withdrawalLocationReference` | string | Withdrawal location reference. If withdrawal location is a blockchain - specify your wallet you want to withdraw to, this must have been already whitelisted. If withdrawal location is FIAT please specify the bank name, this must have been already whitelisted. (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `bankReference` | string | Bank reference. If specified, this is the bank reference associated with the withdrawal. This can be any string up to 35 characters in length. (e.g. `withdrawal-reference-1`) |
  | `asset` | string | Asset to withdraw (e.g. `usd`) |
  | `amount` | string | Amount to withdraw. Maximum of 5 decimal places. (e.g. `5.67`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id - This is the client specified id when requesting (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `withdrawalLocation` | string | Withdrawal location specified in your request. (e.g. `ETHEREUM`) |
  | `withdrawalLocationReference` | string | The withdrawal location reference specified in your request. (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `bankReference` | string | The bank reference specified in your request. (e.g. `withdrawal-reference-1`) |
  | `asset` | string | asset (e.g. `usd`) |
  | `amount` | string | amount (e.g. `5.67`) |
  | `status` | string | status |
  | `rejectionReason` | string | rejectionReason |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid amount):
  ```json
  {"code":"INVALID_AMOUNT","description":"Amount passed in must be present, a numeric value and greater than 0"}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```

**Example**

```bash
curl -X POST "https://api.demo.omniaexchange.com/api/v2/offchain-withdrawals" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"instructionId": "375b23de-febf-4a6e-a517-e7b5dfa9357c", "withdrawalLocation": "ETHEREUM", "withdrawalLocationReference": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "bankReference": "withdrawal-reference-1", "asset": "usd", "amount": "5.67"}'
```

---

