# Notifications

Notification channels deliver platform and deployment events to external destinations. Channels belong to a tenant or workspace. Send requests to `https://api.laserdata.cloud`.

Reading requires `notifications:read`. Creation, updates, and deletion require `notifications:manage`.

## Notification Types

### List Notification Types

`GET /notifications/types`

List all available event types that can be subscribed to.

```bash
curl https://api.laserdata.cloud/notifications/types \
-H "ld-api-key: YOUR_API_KEY"
```

```json
[
  { "type": "deployment_created", "name": "Deployment created" },
  { "type": "deployment_initialized", "name": "Deployment initialized" },
  { "type": "high_cpu_usage", "name": "High CPU usage" },
  { "type": "node_unreachable", "name": "Node unreachable" }
]
```

- Deployment events: `deployment_created`, `deployment_initialized`, `deployment_upgraded`, `deployment_deleted`, `deployment_inactive`
- Invitation events: `invitation_created`, `invitation_accepted`, `invitation_rejected`
- Tenant events: `tenant_join_requested`, `member_joined`
- Organization events: `workspace_created`, `workspace_updated`, `workspace_deleted`, `environment_created`, `environment_updated`, `environment_deleted`
- Health alerts: `high_cpu_usage`, `high_memory_usage`, `high_disk_usage`, `node_unreachable`, `cpu_usage_resolved`, `memory_usage_resolved`, `disk_usage_resolved`, `node_reachable`, `runtime_degraded`, `runtime_recovered`, `plane_condition`, `plane_condition_resolved`, `replication_condition`, `replication_condition_resolved`
- Other: `certificate_expiring`, `billing_limit_reached`, `invoice_created`, `invoice_paid`, `invoice_payment_failed`, `payment_method_added`, `payment_method_removed`

***

## Channels

A channel selects a destination through `slack`, `webhook`, or `email`. Slack uses an incoming webhook. Generic webhooks receive HTTPS POST requests with JSON. Destinations are encrypted at rest.

### Create a Tenant Channel

`POST /tenants/{tenant_id}/channels`

Create a notification channel scoped to the entire tenant.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/channels \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "channel": "slack",
  "name": "production-alerts",
  "destination": "https://hooks.slack.com/services/T00/B00/xxx",
  "settings": {
    "slack": {
      "channel": "#alerts",
      "username": "LaserData"
    }
  },
  "remarks": "Primary alerting channel"
}'
```

| Field | Required | Description |
| --- | --- | --- |
| `channel` | Yes | Channel kind: `slack`, `webhook`, `email` |
| `name` | Yes | Unique name (1-100 chars) |
| `destination` | Yes | Target URL or email address |
| `settings` | No | Channel-specific settings (Slack channel/username, webhook headers, etc.) |
| `remarks` | No | Notes (max 500 chars) |

A successful request returns `201 Created`.

### Create a Workspace Channel

`POST /tenants/{tenant_id}/workspaces/{workspace_id}/channels`

Create a notification channel scoped to a specific workspace.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/workspaces/{workspace_id}/channels \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "channel": "webhook",
  "name": "ops-webhook",
  "destination": "https://example.com/webhooks/laserdata"
}'
```

### List Channels

`GET /tenants/{tenant_id}/channels`

List all notification channels for the tenant.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/channels?page=1&results=10&channel=slack" \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "total_pages": 1,
  "total_results": 1,
  "page": 1,
  "items": [
    {
      "id": 1,
      "owner_kind": "tenant",
      "owner_id": 100,
      "channel": "slack",
      "name": "production-alerts",
      "enabled": true,
      "created_at": "2025-06-01T10:00:00Z",
      "updated_at": "2025-06-01T10:00:00Z"
    }
  ]
}
```

For a workspace, use `GET /tenants/{tenant_id}/workspaces/{workspace_id}/channels`.

| Query Parameter | Description |
| --- | --- |
| `channel` | Filter by kind: `slack`, `webhook`, `email` |
| `page` | Page number |
| `results` | Items per page (max 100) |

### Get Channel

`GET /tenants/{tenant_id}/channels/{channel_id}`

Retrieve a specific channel by ID. Includes destination and settings (omitted in list).

```bash
curl https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id} \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "id": 1,
  "owner_kind": "tenant",
  "owner_id": 100,
  "channel": "slack",
  "name": "production-alerts",
  "enabled": true,
  "destination": "https://hooks.slack.com/services/T00/B00/xxx",
  "settings": {
    "slack": {
      "channel": "#alerts",
      "username": "LaserData"
    }
  },
  "remarks": "Primary alerting channel",
  "created_at": "2025-06-01T10:00:00Z",
  "updated_at": "2025-06-01T10:00:00Z"
}
```

For a workspace, use `GET /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}`.

### Update Channel

`PUT /tenants/{tenant_id}/channels/{channel_id}`

Update a channel's name, destination, settings, or enabled state. All fields optional.

```bash
curl -X PUT https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id} \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "name": "updated-channel-name",
  "destination": "https://hooks.slack.com/services/T00/B00/new",
  "enabled": false
}'
```

Use `enabled: false` to disable delivery without deleting the channel. A successful request returns `204 No Content`.

For a workspace, use `PUT /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}`.

### Test Channel

`POST /tenants/{tenant_id}/channels/{channel_id}/test`

Send a test notification to verify the channel is reachable and correctly configured. Rate limited to one test per 10 seconds.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/test \
-H "ld-api-key: YOUR_API_KEY"
```

A successful request returns `204 No Content`.

For a workspace, use `POST /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/test`.

### Delete Channel

`DELETE /tenants/{tenant_id}/channels/{channel_id}`

Delete a channel and all its subscriptions.

```bash
curl -X DELETE https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id} \
-H "ld-api-key: YOUR_API_KEY"
```

A successful request returns `204 No Content`.

For a workspace, use `DELETE /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}`.

***

## Subscriptions

Subscriptions select event types and optional resource scopes. Without subscriptions, a channel receives every event.

### Create Subscription

`POST /tenants/{tenant_id}/channels/{channel_id}/subscriptions`

Subscribe a channel to one or more event types. Optionally filter by tenant, workspace, environment, or deployment IDs.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/subscriptions \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "message_types": ["deployment_created", "deployment_deleted", "node_unreachable"],
  "scope_workspace_ids": [1],
  "scope_environment_ids": [10, 20]
}'
```

| Field | Required | Description |
| --- | --- | --- |
| `message_types` | Yes | Non-empty array of event type strings |
| `scope_tenant_ids` | No | Limit to specific tenants |
| `scope_workspace_ids` | No | Limit to specific workspaces |
| `scope_environment_ids` | No | Limit to specific environments |
| `scope_deployment_ids` | No | Limit to specific deployments |

An event must match every supplied scope level. Empty or omitted levels match all resources. A successful request returns `201 Created`.

For a workspace, use `POST /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/subscriptions`.

### Set Subscriptions (Replace All)

`PUT /tenants/{tenant_id}/channels/{channel_id}/subscriptions`

Atomically replace all subscriptions for a channel in a single transaction.

```bash
curl -X PUT https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/subscriptions \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "subscriptions": [
    {
      "message_types": ["deployment_created", "deployment_deleted"],
      "scope_workspace_ids": [1]
    },
    {
      "message_types": ["high_cpu_usage", "high_memory_usage", "high_disk_usage"],
      "scope_deployment_ids": [611298765432109056, 611298765432109057]
    }
  ]
}'
```

The supplied list replaces every existing subscription. A successful request returns `204 No Content`.

For a workspace, use `PUT /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/subscriptions`.

### List Subscriptions

`GET /tenants/{tenant_id}/channels/{channel_id}/subscriptions`

List all subscriptions for a channel.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/subscriptions?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "total_pages": 1,
  "total_results": 1,
  "page": 1,
  "items": [
    {
      "id": 1,
      "channel_id": 100,
      "message_types": ["deployment_created", "deployment_deleted"],
      "scope_tenants": [{ "id": 1, "name": "Acme Corp" }],
      "scope_workspaces": [{ "id": 10, "name": "Platform Eng" }],
      "created_at": "2025-06-01T10:00:00Z",
      "updated_at": "2025-06-01T10:00:00Z"
    }
  ]
}
```

Responses omit empty scope arrays. Each scope entry contains `id` and `name`.

For a workspace, use `GET /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/subscriptions`.

### Get Subscription

`GET /tenants/{tenant_id}/channels/{channel_id}/subscriptions/{subscription_id}`

Retrieve a specific subscription with full scope details.

```bash
curl https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/subscriptions/{subscription_id} \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "id": 1,
  "channel_id": 100,
  "message_types": ["deployment_created", "deployment_deleted"],
  "scope_tenants": [{ "id": 1, "name": "Acme Corp" }],
  "scope_workspaces": [{ "id": 10, "name": "Platform Eng" }],
  "scope_environments": [{ "id": 100, "name": "Production" }],
  "scope_deployments": [{ "id": 611298765432109056, "name": "prod-cluster" }],
  "created_at": "2025-06-01T10:00:00Z",
  "updated_at": "2025-06-01T10:00:00Z"
}
```

For a workspace, use `GET /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/subscriptions/{subscription_id}`.

### Delete Subscription

`DELETE /tenants/{tenant_id}/channels/{channel_id}/subscriptions/{subscription_id}`

Remove a single subscription from a channel.

```bash
curl -X DELETE https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/subscriptions/{subscription_id} \
-H "ld-api-key: YOUR_API_KEY"
```

A successful request returns `204 No Content`.

For a workspace, use `DELETE /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/subscriptions/{subscription_id}`.

***

## Notification History

### Browse Notifications

`GET /tenants/{tenant_id}/channels/{channel_id}/notifications`

Browse delivery history for a channel: event content, type, and timestamp.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/channels/{channel_id}/notifications?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "total_pages": 1,
  "total_results": 5,
  "page": 1,
  "items": [
    {
      "id": 1,
      "tenant_id": 100,
      "workspace_id": 10,
      "environment_id": 1,
      "deployment_id": 611298765432109056,
      "message_type": "deployment_initialized",
      "content": "Deployment prod-cluster has been initialized",
      "created_at": "2025-06-01T10:30:00Z"
    }
  ]
}
```

For a workspace, use `GET /tenants/{tenant_id}/workspaces/{workspace_id}/channels/{channel_id}/notifications`.

- [Notifications Guide](/observability/notifications): Channel types and event reference
- [Roles & Permissions](/organization/roles-permissions): notifications:read and notifications:manage

Source: https://docs.laserdata.com/api/notifications
