Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
},
{
"group": "Client surfaces",
"pages": ["components", "customization"]
"pages": [
"http-server",
"server-setup",
"components",
"customization",
"alert-rules"
]
}
]
},
Expand Down
87 changes: 86 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
openapi: 3.1.0
info:
title: Pulseforge Events API
version: 1.0.0
version: 1.1.0
description: Publish public service status and manage incident timelines.
servers:
- url: https://status.example.com
tags:
- name: Status
- name: Incidents
- name: Alert rules
paths:
/v1/status:
get:
Expand Down Expand Up @@ -54,7 +55,91 @@ paths:
responses:
'200':
description: Incident resolved
/v1/alert-rules:
get:
operationId: listAlertRules
tags: [Alert rules]
summary: List alert rules
security: [{ bearerAuth: [] }]
responses:
'200':
description: Every alert rule visible to the token
post:
operationId: createAlertRule
tags: [Alert rules]
summary: Create an alert rule
description: Route selected incident events to an email or HTTPS webhook destination.
security: [{ bearerAuth: [] }]
responses:
'201':
description: Alert rule created and enabled
'400':
description: Invalid destination or cooldown
/v1/alert-rules/{ruleId}:
get:
operationId: getAlertRule
tags: [Alert rules]
summary: Get an alert rule
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/RuleId'
responses:
'200':
description: Alert rule details
'404':
description: Alert rule not found
patch:
operationId: updateAlertRule
tags: [Alert rules]
summary: Update an alert rule
description: Change routing, pause delivery, or adjust the cooldown.
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/RuleId'
responses:
'200':
description: Alert rule updated
delete:
operationId: deleteAlertRule
tags: [Alert rules]
summary: Delete an alert rule
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/RuleId'
responses:
'204':
description: Alert rule deleted
/v1/alert-rules/{ruleId}/test:
post:
operationId: testAlertRule
tags: [Alert rules]
summary: Record a test alert
description: Record a synthetic delivery attempt in the reference store.
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/RuleId'
responses:
'202':
description: Test delivery accepted
/v1/alert-rules/{ruleId}/deliveries:
get:
operationId: listAlertDeliveries
tags: [Alert rules]
summary: List alert delivery history
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/RuleId'
responses:
'200':
description: Delivery attempts for the alert rule
components:
parameters:
RuleId:
in: path
name: ruleId
required: true
schema:
type: string
securitySchemes:
bearerAuth:
type: http
Expand Down
153 changes: 153 additions & 0 deletions src/content/alert-rules.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
title: Alert rules
description: Route incident events to email or webhook destinations with reusable alert rules.
---

Alert rules route incident events to email or webhook destinations, decoupling your incident creation logic from notification infrastructure.

## What are alert rules?

A rule selects which incident events trigger notifications (for example,
`incident.opened` or `incident.resolved`), specifies where to send them (email
or webhook), and can include a delivery cooldown to reduce alert fatigue.

Each rule is independent, reusable, and available through the REST API and typed SDK methods.

## Create a rule

Use the SDK to set up a rule that sends new incidents to a webhook:

```ts
import { createPulseforgeClient } from "@pulseforge/events/sdk";

const pulseforge = createPulseforgeClient({
baseUrl: "https://status.example.com",
token: process.env.PULSEFORGE_TOKEN,
});

const rule = await pulseforge.createAlertRule({
name: "Critical incident webhook",
eventTypes: ["incident.opened"],
destination: {
kind: "webhook",
target: "https://alerts.internal.example.com/incidents",
},
cooldownSeconds: 300,
});
```

## Destination types

### Email

Send alerts to a single email address:

```ts
destination: {
kind: "email",
target: "team@example.com",
}
```

### Webhook

Webhook destinations must use HTTPS:

```ts
destination: {
kind: "webhook",
target: "https://alerts.internal.example.com/incidents",
}
```

## Manage rules

### List all rules

```ts
const rules = await pulseforge.listAlertRules();
```

### Get a specific rule

```ts
const rule = await pulseforge.getAlertRule(ruleId);
```

### Update a rule

Change the destination, cooldown, or pause delivery without recreating it:

```ts
await pulseforge.updateAlertRule(ruleId, {
destination: {
kind: "email",
target: "new-team@example.com",
},
isEnabled: true,
});
```

### Delete a rule

```ts
await pulseforge.deleteAlertRule(ruleId);
```

## Test a rule

The reference store records a synthetic successful delivery so you can verify
rule configuration and delivery-history handling. A production adapter should
replace this simulation with a real destination check:

```ts
const result = await pulseforge.testAlertRule(ruleId);
console.log(result.delivery.status); // "delivered" in the reference store
```

## View delivery history

Inspect the most recent delivery attempts for a rule:

```ts
const deliveries = await pulseforge.listAlertDeliveries(ruleId);
deliveries.forEach((d) => {
console.log(`${d.eventType}: ${d.status} at ${d.attemptedAt}`);
});
```

## Embed the alert center

Display alert rules in your operator dashboard using the `<pulseforge-alert-center>` web component. Register it once in your app:

```html
<script type="module">
import { registerPulseforgeAlertCenterWidget } from "@pulseforge/events";
registerPulseforgeAlertCenterWidget();
</script>
```

Then add the component to your page and assign an authenticated client:

```html
<pulseforge-alert-center id="alerts"></pulseforge-alert-center>

<script type="module">
import { createPulseforgeClient } from "@pulseforge/events/sdk";

const client = createPulseforgeClient({
baseUrl: "https://status.example.com",
token: operatorSession.accessToken,
});

document.getElementById("alerts").client = client;
</script>
```

The component displays the count of configured rules and exposes a `refresh()` method to reload them after mutations.

<Note type="warning" title="Use only in an authenticated operator surface">
Do not persist an incident-management token in browser storage or expose it
through markup. Supply a short-lived operator credential from your existing
authenticated application session.
</Note>
6 changes: 6 additions & 0 deletions src/content/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ title: Changelog
description: Pulseforge Events product and documentation updates.
---

## 1.1.0 — 2026-08-16

- Added alert-rule creation, updates, deletion, test delivery, and history.
- Added seven alert-rule operations to the REST API and browser SDK.
- Added the authenticated `pulseforge-alert-center` operator widget.

## 1.0.0 — 2026-08-16

- Added public status reads and authenticated incident management.
Expand Down
15 changes: 14 additions & 1 deletion src/content/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ const pulseforge = createPulseforgeClient({

Omit `token` for calls that only read public status.

## Incident methods
## Status and incidents

- `getStatus()` reads public service status.
- `createIncident(input)` opens an incident.
- `addIncidentUpdate(id, input)` extends its timeline.
- `resolveIncident(id)` marks it resolved.

## Alert rules

Alert rules route incident events to email or webhook destinations. See
[Alert rules](/alert-rules) for full details and examples.

- `listAlertRules()` returns all configured rules.
- `getAlertRule(id)` fetches a single rule.
- `createAlertRule(input)` creates a new rule.
- `updateAlertRule(id, input)` modifies a rule.
- `deleteAlertRule(id)` removes a rule.
- `testAlertRule(id)` records a synthetic delivery in the reference store.
- `listAlertDeliveries(id)` shows recent delivery attempts.
Loading
Loading