Skip to content
betterstack-alchemyUnofficial

Incidents.CreateStatusReport

Kind BindingType id BetterStack.Incidents.CreateStatusReportSource src/Incidents/CreateStatusReport.ts

Publish an incident or scheduled-maintenance report on a StatusPage from running code (create_status_report): a title, the first update’s message, the affectedResources and their status, and for maintenance a startsAt/endsAt window. The page is fixed when you bind; each call passes the rest.

Notifies. The report is public on the status page at once. Only with notifySubscribers: true is every subscriber of the page e-mailed (and sent their other channels) about the first update: the binding sends false when a call leaves it out, though the API’s own default is to notify.

Credential. These operations need an API token: Better Stack has no narrower credential for them (no per-incident or per-page token, no scopes). The host receives the ApiToken you pass — explicitly, never the deployer’s own — under the name you give it (Redacted, a secret on every host), plus <name>_TEAM_ID when you give a team. The token can do everything it can do in the Uptime API, so use a team-scoped Uptime API token (Settings → API tokens) rather than a global one, and bind it only into hosts that need it.

Provide CreateStatusReportHttp on the host’s implementation.

Bind it with an explicit token

export default class Api extends BetterStack.Cloud.Service<Api>()(
"Api",
{ server: Box, main: import.meta.url, port: 3000 },
Effect.gen(function* () {
const report = yield* BetterStack.Incidents.CreateStatusReport(PublicStatus, IncidentsToken);
return {
fetch: Effect.gen(function* () {
const created = yield* report({
title: "Degraded checkout",
message: "We are looking into slow payments.",
reportType: "manual",
affectedResources: [{ statusPageResourceId: "456", status: "degraded" }],
notifySubscribers: false,
});
return yield* HttpServerResponse.json({ id: created.id });
}).pipe(Effect.orDie),
};
}).pipe(Effect.provide(BetterStack.Incidents.CreateStatusReportHttp)),
) {}

The token and ids are bound through RuntimeContext, so the same yield* BetterStack.Incidents.CreateStatusReport(…) works in a Cloudflare Worker or a Lambda Function, where the token becomes the host’s secret.