# Webhooks

## Get All Webhooks

`GET /v3/webhooks`

Returns all webhook subscriptions for the authenticated user. Each subscription includes a subscriptionId, the event types it listens for, and the target server configuration.

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `webhooks` | WebhookGetResponse[] | List of active webhook subscriptions for the authenticated user. (e.g. `[{subscriptionId=9d701848-a6c2-4b4a-baac-9704f144bd02, eventTypes=[ACCOUNT_ACTIVITY], target={url=https://api.example.com/webhooks, headers={Authorization=Bearer <token>, Content-Type=application/json}}}]`) |

- **401**: Unauthorized

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


  Example (Invalid nonce):
  ```json
  {"code":"INVALID_NONCE","description":"Invalid nonce"}
  ```

**Example**

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

---

## Create Webhook

`POST /v3/webhooks`

Create a new webhook subscription. You may create at most 5 webhooks per user. The response includes a subscriptionId that you can use to retrieve or delete the webhook. Currently the only supported event type is ACCOUNT_ACTIVITY, which fires on deposits and withdrawals.

**Request Body** _(required)_

  | Field | Type | Description |
  |-------|------|-------------|
  | `eventTypes` | ChannelType[] | Types of events you want webhooks for |
  | `target` | object | The destination server where webhook events will be delivered. (e.g. `{"url":"https://api.example.com/webhooks","headers":{"Authorization":"Bearer <token>","Content-Type":"application/json"}}`) |

**Responses**

- **201**: Accepted

  | Field | Type | Description |
  |-------|------|-------------|
  | `subscriptionId` | string | Unique identifier for this webhook subscription. Use this to retrieve details or delete the webhook. (e.g. `9d701848-a6c2-4b4a-baac-9704f144bd02`) |
  | `eventTypes` | ChannelType[] | The event types this webhook is subscribed to. Currently the only supported type is ACCOUNT_ACTIVITY, which fires on deposits and withdrawals. |
  | `target` | object | The destination server where webhook events will be delivered. (e.g. `{"url":"https://api.example.com/webhooks","headers":{"Authorization":"Bearer <token>","Content-Type":"application/json"}}`) |

- **400**: Bad request

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

- **401**: Unauthorized

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


  Example (Invalid nonce):
  ```json
  {"code":"INVALID_NONCE","description":"Invalid nonce"}
  ```

**Example**

```bash
curl -X POST "https://api.demo.omniaexchange.com/api/v3/webhooks" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"eventTypes": "<eventTypes>", "target": "{"url":"https://api.example.com/webhooks","headers":{"Authorization":"Bearer <token>","Content-Type":"application/json"}}"}'
```

---

## Get Webhook Details

`GET /v3/webhooks/{subscriptionId}`

Retrieve a specific webhook subscription by its subscriptionId. The subscriptionId is returned when you create a webhook via the Create Webhook endpoint.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `subscriptionId` | path | Yes | string | The unique identifier of the webhook subscription, returned when the webhook was created. (e.g. `9d701848-a6c2-4b4a-baac-9704f144bd02`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `subscriptionId` | string | Unique identifier for this webhook subscription. Use this to retrieve details or delete the webhook. (e.g. `9d701848-a6c2-4b4a-baac-9704f144bd02`) |
  | `eventTypes` | ChannelType[] | The event types this webhook is subscribed to. Currently the only supported type is ACCOUNT_ACTIVITY, which fires on deposits and withdrawals. |
  | `target` | object | The destination server where webhook events will be delivered. (e.g. `{"url":"https://api.example.com/webhooks","headers":{"Authorization":"Bearer <token>","Content-Type":"application/json"}}`) |

- **404**: Not found

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


  Example (Not Found):
  ```json
  {"code":"NOT_FOUND","description":"Not Found"}
  ```
- **401**: Unauthorized

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


  Example (Invalid nonce):
  ```json
  {"code":"INVALID_NONCE","description":"Invalid nonce"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v3/webhooks/{subscriptionId}" \
  -H "Authorization: Bearer <token>"
```

---

## Delete Webhook

`DELETE /v3/webhooks/{subscriptionId}`

Delete a webhook subscription by its subscriptionId. Once deleted, events will no longer be delivered to the target URL.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `subscriptionId` | path | Yes | string | The unique identifier of the webhook subscription to delete. (e.g. `9d701848-a6c2-4b4a-baac-9704f144bd02`) |

**Responses**

- **204**: Ok
- **404**: Not found

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


  Example (Not Found):
  ```json
  {"code":"NOT_FOUND","description":"Not Found"}
  ```
- **401**: Unauthorized

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


  Example (Invalid nonce):
  ```json
  {"code":"INVALID_NONCE","description":"Invalid nonce"}
  ```

**Example**

```bash
curl -X DELETE "https://api.demo.omniaexchange.com/api/v3/webhooks/{subscriptionId}" \
  -H "Authorization: Bearer <token>"
```

---

