Unstatus API

SDKs

Use the official Node and Rust SDKs for the Unstatus REST API.

Unstatus ships official SDKs for Node.js and Rust. Both wrap the REST API with typed resource clients for monitors, incidents, status pages, maintenance windows, notifications, and organization metadata.

Node SDK

bun
bun add @unstatus/node-sdk
npm
npm install @unstatus/node-sdk

Create a Client

Basic client
import { createClient } from "@unstatus/node-sdk";

const client = createClient({
  apiKey: "usk_your_api_key",
});

By default, the SDK uses https://unstatus.app/api/v1.

Examples

List monitors
const { items, pagination } = await client.monitors.list({ limit: 10 });

console.log(items);
console.log(pagination.hasMore);
Create a monitor
const monitor = await client.monitors.create({
  name: "API Server",
  type: "http",
  url: "https://api.example.com/health",
  interval: 30,
  regions: ["eu", "us"],
});
Create an incident
const incident = await client.incidents.create({
  monitorIds: [monitor.id],
  title: "API degraded performance",
  message: "We are investigating elevated error rates.",
  severity: "major",
});

Error Handling

The SDK throws UnstatusApiError for API and transport failures.

Handle API errors
import { UnstatusApiError } from "@unstatus/node-sdk";

try {
  await client.maintenance.start("mw_123");
} catch (error) {
  if (error instanceof UnstatusApiError) {
    console.error(error.status, error.code, error.message);
  }
}

Custom Base URL

Override the API base URL when targeting a local or self-hosted deployment.

Custom base URL
const client = createClient({
  apiKey: "usk_your_api_key",
  baseUrl: "http://localhost:3000/api/v1",
});

Rust SDK

Cargo.toml
[dependencies]
unstatus-rust-sdk = "0.1.0"

The crate exposes an async Client built on reqwest.

Basic client
use unstatus_rust_sdk::Client;

let client = Client::new("usk_your_api_key")?;

Examples

List monitors
use unstatus_rust_sdk::{Client, PaginationParams};

let client = Client::new("usk_your_api_key")?;

let monitors = client
    .monitors()
    .list(Some(&PaginationParams {
        limit: Some(10),
        offset: None,
    }))
    .await?;

println!("{}", monitors.items.len());
Create a monitor
use unstatus_rust_sdk::{Client, CreateMonitorInput, MonitorType};

let client = Client::new("usk_your_api_key")?;

let monitor = client
    .monitors()
    .create(&CreateMonitorInput {
        name: "API Server".into(),
        r#type: MonitorType::Http,
        url: Some("https://api.example.com/health".into()),
        ..Default::default()
    })
    .await?;

Error Handling

The Rust SDK returns UnstatusError for API and transport failures.

Handle API errors
use unstatus_rust_sdk::{Client, UnstatusError};

let client = Client::new("usk_your_api_key")?;

match client.organization().get().await {
    Ok(org) => println!("{}", org.slug),
    Err(UnstatusError::Api { status, code, message, .. }) => {
        eprintln!("{} {} {}", status, code, message);
    }
    Err(err) => eprintln!("{}", err),
}

Custom Base URL

Custom base URL
use unstatus_rust_sdk::Client;

let client = Client::builder("usk_your_api_key")
    .base_url("http://localhost:3000/api/v1")
    .build()?;

Resources

Both SDKs expose the same resource groups:

  • client.monitors
  • client.incidents
  • client.statusPages
  • client.maintenance
  • client.notifications
  • client.organization

On this page