Skip to main content

Notifications

Configure delivery channels for your alerts. When an alert fires, RelayX delivers notifications through the channels you've configured.

Access via app.notification.

Channel Types

TypeDescription
WebhookSends an HTTP POST request to your endpoint with the alert payload. Use this to integrate with Slack, PagerDuty, custom dashboards, or any service that accepts webhooks.
EmailSends an email to one or more recipients with a customizable subject and body. Supports template variables like {{rule.name}} and {{device_id}}.
Email limit

The number of email notifications you can send depends on your plan.

API

create()

Create a new notification channel.

await app.notification.create(params)
ParameterTypeDescription
namestringUnique channel name
typestring"WEBHOOK" or "EMAIL"
configobjectChannel-specific configuration (see below)

Webhook

const channel = await app.notification.create({
name: "ops_webhook",
type: "WEBHOOK",
config: {
endpoint: "https://hooks.example.com/alerts",
headers: { "Authorization": "Bearer <token>" },
retry_back_off: [100, 500, 1000],
},
});
FieldTypeDescription
endpointstringThe URL to POST alert payloads to
headersobjectHTTP headers to include with each request
retry_back_offnumber[](optional) Retry delays in milliseconds on failure

Email

const channel = await app.notification.create({
name: "ops_email",
type: "EMAIL",
config: {
recipients: ["ops@example.com", "alerts@example.com"],
subject: "Alert: {{rule.name}}",
template: "Device {{device_id}} triggered {{rule.name}}",
},
});
FieldTypeDescription
recipientsstring[]Email addresses to send to
subjectstringEmail subject line (supports {{template}} variables)
templatestringEmail body (supports {{template}} variables)

Example response:

{
"id": "69cb22a4ed4d9fe786145d01",
"name": "ops_webhook",
"type": "WEBHOOK"
}

update()

Update an existing notification channel's configuration.

await app.notification.update(params)
const updated = await app.notification.update({
id: channelId,
config: { endpoint: "https://new-url.example.com/alerts" },
});

Example response:

{
"id": "69cb22a4ed4d9fe786145d01",
"name": "ops_webhook",
"config": {
"endpoint": "https://new-url.example.com/alerts",
"headers": { "Authorization": "Bearer <token>" }
},
"created_at": "2026-03-28T10:00:00.000Z",
"updated_at": "2026-03-29T14:30:00.000Z"
}

delete()

Permanently remove a notification channel.

await app.notification.delete(channelId)
await app.notification.delete(channelId);

list()

Retrieve all notification channels.

await app.notification.list()
const channels = await app.notification.list();

Example response:

[
{
"id": "69cb22a4ed4d9fe786145d01",
"name": "ops_webhook",
"config": {
"endpoint": "https://hooks.example.com/alerts",
"headers": { "Authorization": "Bearer <token>" }
},
"created_at": "2026-03-28T10:00:00.000Z",
"updated_at": "2026-03-28T10:00:00.000Z"
},
{
"id": "69cb22b8ed4d9fe786145d02",
"name": "ops_email",
"config": {
"recipients": ["ops@example.com"],
"subject": "Alert: {{rule.name}}",
"template": "Device {{device_id}} triggered {{rule.name}}"
},
"created_at": "2026-03-28T10:05:00.000Z",
"updated_at": "2026-03-28T10:05:00.000Z"
}
]

get()

Retrieve a single notification channel by ID.

await app.notification.get(channelId)
const channel = await app.notification.get(channelId);

Example response:

{
"id": "69cb22a4ed4d9fe786145d01",
"name": "ops_webhook",
"config": {
"endpoint": "https://hooks.example.com/alerts",
"headers": { "Authorization": "Bearer <token>" }
},
"created_at": "2026-03-28T10:00:00.000Z",
"updated_at": "2026-03-28T10:00:00.000Z"
}

Linking to Alerts

Pass notification channel IDs when creating alerts to enable delivery:

await app.alert.create({
name: "high_temp",
type: "THRESHOLD",
metric: "temperature",
config: { /* ... */ },
notification_channel: [channelId],
});