Skip to content

Open-source status page, incident response and uptime monitoring

3.7 KB
Raw Blame
---
category: SDK
title: Status Report Service
description: "Manage incident reports and status updates with the openstatus Node.js SDK"
---

Manage incident reports with update timelines. The Status Report Service provides 8 RPC methods.

## Create Status Report

```typescript
import {
  createOpenStatusClient,
  StatusReportStatus,
} from "@openstatus/sdk-node";

const client = createOpenStatusClient({
  apiKey: process.env.OPENSTATUS_API_KEY,
});

const { statusReport } = await client.statusReport.v1.StatusReportService
  .createStatusReport({
    title: "API Degradation",
    status: StatusReportStatus.INVESTIGATING,
    message: "We are investigating reports of increased latency.",
    date: "2024-01-15T10:30:00Z",
    pageId: "1",
    pageComponentIds: ["12"],
    notify: true,
  });

console.log(`Status report created: ${statusReport?.id}`);
```

## Add Status Report Update

Add a new entry to a status report's timeline.

```typescript
import { StatusReportStatus } from "@openstatus/sdk-node";

const { statusReport } = await client.statusReport.v1.StatusReportService
  .addStatusReportUpdate({
    statusReportId: "123",
    status: StatusReportStatus.IDENTIFIED,
    message: "The issue has been identified as a database connection problem.",
    date: "2024-01-15T11:00:00Z",
    notify: true,
  });
```

## Edit / Delete Status Report Updates

Entries in the timeline can be corrected or removed. Editing never notifies subscribers; editing the latest entry's status re-derives the report's status.

### Update Status Report Update

```typescript
import { StatusReportStatus } from "@openstatus/sdk-node";

const { statusReportUpdate } = await client.statusReport.v1.StatusReportService
  .updateStatusReportUpdate({
    id: "456",
    status: StatusReportStatus.MONITORING,
    message: "A fix has been deployed and we are monitoring.",
  });
```

To replace the entry's component impacts, pass `componentImpacts` together with `updateComponentImpacts: true` (an empty list clears them). Without the flag the impacts stay untouched.

### Delete Status Report Update

A report always keeps at least one update. Deleting the last one fails with `invalid_argument`; delete the report instead.

```typescript
const { success } = await client.statusReport.v1.StatusReportService
  .deleteStatusReportUpdate({ id: "456" });
```

## List Status Reports

List status reports with optional status filtering and pagination.

```typescript
import { StatusReportStatus } from "@openstatus/sdk-node";

const { statusReports, totalSize } = await client.statusReport.v1
  .StatusReportService.listStatusReports({
    limit: 10,
    offset: 0,
    statuses: [StatusReportStatus.INVESTIGATING, StatusReportStatus.IDENTIFIED],
  });

console.log(`Found ${totalSize} status reports`);
```

## Get / Update / Delete Status Reports

### Get Status Report

Returns the full report including the updates timeline.

```typescript
import { StatusReportStatus } from "@openstatus/sdk-node";

const { statusReport } = await client.statusReport.v1.StatusReportService
  .getStatusReport({ id: "123" });

console.log(`Title: ${statusReport?.title}`);
console.log(`Status: ${StatusReportStatus[statusReport?.status ?? 0]}`);

for (const update of statusReport?.updates ?? []) {
  console.log(`  ${update.date}: [${StatusReportStatus[update.status]}] ${update.message}`);
}
```

### Update Status Report

```typescript
const { statusReport } = await client.statusReport.v1.StatusReportService
  .updateStatusReport({
    id: "123",
    title: "Updated Title",
    pageComponentIds: ["12", "13"],
  });
```

### Delete Status Report

```typescript
const { success } = await client.statusReport.v1.StatusReportService
  .deleteStatusReport({ id: "123" });
```