> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infraudit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API endpoints for notification channels

> Create, update, and delete InfraAudit notification channels for Slack, email, and webhooks. Configure which alert severity levels each channel receives.

Notification preferences control which channels InfraAudit sends alerts to, filtered by alert type and severity. Supported channels are Slack (incoming webhook), email, and generic outbound webhook. You can also view delivery history to debug missed notifications.

Base path: `/api/v1/notifications`

***

## GET /notifications/preferences — list preferences

Returns the user's notification preferences.

```http theme={null}
GET /api/v1/notifications/preferences
Authorization: Bearer <token>
```

### Response

```json theme={null}
[
  {
    "id": 1,
    "channel": "slack",
    "alert_type": "security",
    "severity": "critical",
    "webhook_url": "https://hooks.slack.com/services/...",
    "enabled": true
  }
]
```

<ResponseField name="channel" type="string">
  The notification channel: `slack`, `email`, or `webhook`.
</ResponseField>

<ResponseField name="alert_type" type="string">
  The type of alerts this preference applies to: `security`, `cost`, `compliance`, `performance`, or `all`.
</ResponseField>

<ResponseField name="severity" type="string">
  Minimum severity to trigger a notification: `critical`, `high`, `medium`, `low`, or `all`.
</ResponseField>

***

## POST /notifications/preferences — create preference

Creates a new notification preference.

```http theme={null}
POST /api/v1/notifications/preferences
Authorization: Bearer <token>
Content-Type: application/json
```

### Request body

<ParamField body="channel" type="string" required>
  Notification channel: `slack`, `email`, or `webhook`.
</ParamField>

<ParamField body="alert_type" type="string" required>
  Alert type to notify on: `security`, `cost`, `compliance`, `performance`, or `all`.
</ParamField>

<ParamField body="severity" type="string" required>
  Minimum severity: `critical`, `high`, `medium`, `low`, or `all`.
</ParamField>

<ParamField body="webhook_url" type="string">
  Required for `slack` and `webhook` channels. The destination URL.
</ParamField>

```json theme={null}
{
  "channel": "slack",
  "alert_type": "security",
  "severity": "critical",
  "webhook_url": "https://hooks.slack.com/services/T00000/B00000/XXXX"
}
```

***

## PUT /notifications/preferences/{id} — update preference

Updates an existing notification preference.

```http theme={null}
PUT /api/v1/notifications/preferences/{id}
Authorization: Bearer <token>
Content-Type: application/json
```

***

## DELETE /notifications/preferences/{id} — delete preference

Removes a notification preference.

```http theme={null}
DELETE /api/v1/notifications/preferences/{id}
Authorization: Bearer <token>
```

Returns `204 No Content`.

***

## POST /notifications/test — send test notification

Sends a test `ping` event to verify a channel endpoint is reachable.

```http theme={null}
POST /api/v1/notifications/test
Authorization: Bearer <token>
Content-Type: application/json
```

### Request body

<ParamField body="channel" type="string" required>
  The channel type: `slack`, `email`, or `webhook`.
</ParamField>

<ParamField body="webhook_url" type="string">
  The URL to send the test to. Required for `slack` and `webhook`.
</ParamField>

```json theme={null}
{
  "channel": "slack",
  "webhook_url": "https://hooks.slack.com/services/T00000/B00000/XXXX"
}
```

***

## GET /notifications/history — list delivery history

Returns recent notification delivery records.

```http theme={null}
GET /api/v1/notifications/history
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="channel" type="string">
  Filter by channel: `slack`, `email`, or `webhook`.
</ParamField>

<ParamField query="days" type="integer" default="7">
  Number of days of history to return.
</ParamField>

<ParamField query="status" type="string">
  Filter by delivery status: `sent`, `failed`, or `pending`.
</ParamField>
