# On-chain Withdrawal

Endpoints to manage withdrawals via the Deposit‑Trade‑Withdraw (DTW) on‑chain mechanism.

## Withdrawal Status

`GET /v2/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`) |
  | `orderSource` | string | orderSource |
  | `tokenAddress` | string | tokenAddress (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `amount` | string | amount (e.g. `5.67`) |
  | `status` | string | status |
  | `rejectionReason` | string | rejectionReason |
  | `transactionId` | string | transaction Id (e.g. `0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6`) |


  Example (Withdrawal response):
  ```json
  {"instructionId":"375b23de-febf-4a6e-a517-e7b5dfa9357c","orderSource":"ETHEREUM","tokenAddress":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","amount":"5.67","status":"COMPLETED","transactionId":"0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6"}
  ```
- **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/withdrawals/{instructionId}" \
  -H "Authorization: Bearer <token>"
```

---

## Withdrawal Request

`POST /v2/withdrawals`

Create a withdrawal request to remove assets from the Deposit, Trade, Withdraw contract.

**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`) |
  | `orderSource` | string | orderSource |
  | `tokenAddress` | string | tokenAddress (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `amount` | string | amount (e.g. `5.67`) |
  | `deadline` | integer | deadline (e.g. `1653480000000`) |
  | `signature` | string | signature (e.g. `0xc2d0018de1528b8dab42e85482263060903ec1fec13768f66977f9b7b37333a3f2a1bbf42`) |

**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`) |
  | `orderSource` | string | orderSource |
  | `tokenAddress` | string | tokenAddress (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `amount` | string | amount (e.g. `5.67`) |
  | `status` | string | status |
  | `rejectionReason` | string | rejectionReason |
  | `transactionId` | string | transaction Id (e.g. `0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6`) |


  Example (Withdrawal response):
  ```json
  {"instructionId":"375b23de-febf-4a6e-a517-e7b5dfa9357c","orderSource":"ETHEREUM","tokenAddress":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","amount":"5.67","status":"COMPLETED","transactionId":"0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6"}
  ```
- **400**: Bad request

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


  Example (Order source not found):
  ```json
  {"code":"ORDER_SOURCE_NOT_FOUND","description":"Order source not found"}
  ```
- **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/withdrawals" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"instructionId": "375b23de-febf-4a6e-a517-e7b5dfa9357c", "orderSource": "<orderSource>", "tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amount": "5.67", "deadline": 1653480000000, "signature": "0xc2d0018de1528b8dab42e85482263060903ec1fec13768f66977f9b7b37333a3f2a1bbf42"}'
```

---

