Incidents.OutgoingWebhookIntegration
An outgoing webhook integration sends a request to your url when an
incident (triggerType: "incident_change"), an on-call shift
(on_call_change) or a monitor (monitor_change) changes. For incidents,
the onIncident* toggles pick the events. Without a custom template the
body is the incident, shift or monitor as JSON under data;
customWebhookTemplateAttributes sets the method, headers, body template
($INCIDENT_ID, $NAME, $CAUSE, … see the Better Stack docs) and basic
auth (authPassword is Redacted).
triggerType and teamId replace the integration; everything else
updates in place. The API never returns the template, so changes to
customWebhookTemplateAttributes are detected against the previous
deploy and the saved template is edited in place (its id is sent along);
removing the template from the config keeps the saved one. name
defaults to a generated unique name; paused is read-only here.
Header values and authUsername are plain strings in the SDK (the API
description does not mark them sensitive): keep secrets in authPassword.
Incidents to your own endpoint
Section titled “Incidents to your own endpoint”Started and resolved incidents as a custom JSON body
yield* BetterStack.Incidents.OutgoingWebhookIntegration("ops-hook", { name: "Incidents to ops tooling", url: "https://ops.example.com/hooks/better-stack", triggerType: "incident_change", onIncidentStarted: true, onIncidentResolved: true, onIncidentAcknowledged: false, onIncidentReopened: false, onIncidentComment: false, customWebhookTemplateAttributes: { httpMethod: "post", headersTemplate: [{ name: "Content-Type", value: "application/json" }], bodyTemplate: '{"incident":"$INCIDENT_ID","status":"$STATUS","cause":"$CAUSE"}', authUsername: "better-stack", authPassword: Redacted.make(process.env.OPS_HOOK_PASSWORD ?? ""), },});On-call changes
Section titled “On-call changes”Tell a chat bot who is on call
yield* BetterStack.Incidents.OutgoingWebhookIntegration("on-call", { url: "https://bot.example.com/on-call", triggerType: "on_call_change",});triggerType "incident_change" | "on_call_change" | "monitor_change" | string required
What triggers the webhook. Fixed once the integration is created.
url string required
The URL the webhook is sent to. For an incident_change webhook, it can use the $INCIDENT_ID, $TEAM_ID and $METADATA variables.
customWebhookTemplateAttributes CreateIncidentsOutgoingWebhookIntegrationRequestCustomWebhookTemplateAttributes
Custom request method, headers, body and basic authentication. Without a custom template, an incident_change or monitor_change webhook sends the incident or monitor under data, with what happened in event, such as started or created. Without a custom template, an on_call_change webhook sends the on-call schedule's message, emails, on_holiday_emails, change, calendar_id, calendar_name and primary_calendar under data. Returned as custom_webhook_template.
metadataApiVersion "v2" | "v3" | string
How the $METADATA variables in the URL and body_template render.
name string
The name shown in the dashboard. Defaults to a unique name generated from the stack, stage and logical id.
notifyAlongsidePrimaryResponder boolean
Whether to send the webhook when the on-call person is alerted about an incident without an escalation policy. Only for an incident_change webhook.
onIncidentAcknowledged boolean
Whether to send the webhook when an incident is acknowledged. Only for an incident_change webhook.
onIncidentComment boolean
Whether to send the webhook when a comment is added to an incident. Without a custom template, the body of a comment webhook also has a comment object, whose attributes hold the comment's content, created_at, updated_at, user_id and user_email. Only for an incident_change webhook.
onIncidentReopened boolean
Whether to send the webhook when an incident is reopened. Only for an incident_change webhook.
onIncidentResolved boolean
Whether to send the webhook when an incident is resolved. Only for an incident_change webhook.
onIncidentStarted boolean
Whether to send the webhook when an incident starts. Only for an incident_change webhook.
teamId string
Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.
Attributes
Section titled “Attributes”id string always set
The incidents_outgoing_webhook_integration's id.
customWebhookTemplateId string
Id of the saved custom request template, undefined when the webhook sends the default body.
metadataApiVersion "v2" | "v3"
How the $METADATA variables in the URL and body_template render.
name string | null
The integration's name, shown in the dashboard.
notifyAlongsidePrimaryResponder boolean
Whether to send the webhook when the on-call person is alerted about an incident without an escalation policy. Only for an incident_change webhook.
onIncidentAcknowledged boolean
Whether to send the webhook when an incident is acknowledged. Only for an incident_change webhook.
onIncidentComment boolean
Whether to send the webhook when a comment is added to an incident. Without a custom template, the body of a comment webhook also has a comment object, whose attributes hold the comment's content, created_at, updated_at, user_id and user_email. Only for an incident_change webhook.
onIncidentReopened boolean
Whether to send the webhook when an incident is reopened. Only for an incident_change webhook.
onIncidentResolved boolean
Whether to send the webhook when an incident is resolved. Only for an incident_change webhook.
onIncidentStarted boolean
Whether to send the webhook when an incident starts. Only for an incident_change webhook.
paused boolean
Whether the integration is paused. A paused integration sends no webhooks.
teamId string
Team that owns this integration, such as t123.
teamName string
Name of the team that owns this integration.
triggerType "incident_change" | "on_call_change" | "monitor_change"
What triggers the webhook. Fixed once the integration is created.
url string
The URL the webhook is sent to. For an incident_change webhook, it can use the $INCIDENT_ID, $TEAM_ID and $METADATA variables.
Lookup
Section titled “Lookup”OutgoingWebhookIntegration.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
id string required
The integration's id.
teamId string
Team that owns it, such as t123. Defaults to the credentials' team.