Cloud.Webhook
A Better Stack Cloud webhook: an HTTPS endpoint that receives a signed
JSON event (object, event, occurred_at, data) whenever a resource
of the listed webhookTypes is created, updated or destroyed in this
availability zone. Webhooks are free.
Every prop but teamId and availabilityZone changes in place. Verify
deliveries with the secret attribute (Redacted); the API has no way
to rotate it, so replace the webhook to get a new one. Respond with a 2xx
within 10 seconds; after a delivery fails 10 attempts (about a day) the
API pauses the webhook by itself (status: "paused"); with status: "active" in the config, the next deploy that changes the webhook resumes
it.
Ownership. The API keeps no metadata for it, so the generated name (it ends
in the resource instance’s random suffix) is what identifies an object this stack
created: a create interrupted before its state was saved is found by that name on
the next deploy. An explicitly named object can’t be told apart from someone
else’s (it is taken over only with --adopt), and list returns every object.
Creating a webhook
Section titled “Creating a webhook”Notify about servers and volumes
const hook = yield* BetterStack.Cloud.Webhook("events", { url: "https://example.com/hooks/betterstack", webhookTypes: ["server", "volume"],});Created paused, enabled later
yield* BetterStack.Cloud.Webhook("audit", { name: "audit", url: "https://example.com/hooks/audit", webhookTypes: ["firewall", "ssh_key", "reserved_ip"], status: "paused",});Verifying deliveries
Section titled “Verifying deliveries”Pass the signing secret to the receiver
const signingSecret = hook.secret; // Redacted<string>Looking up an existing webhook
Section titled “Looking up an existing webhook”Reference a webhook by name
const existing = BetterStack.Cloud.Webhook.lookup({ name: "audit" });url string required
The URL we send notifications to. Use an HTTPS URL to protect what the notifications contain. To check that the URL receives notifications, send a test notification.
webhookTypes string[] required
The kinds of resources we notify about. Accepts server, snapshot, reserved_ip, network, firewall, ssh_key, placement_group, scheduled_snapshot, load_balancer, certificate, volume, volume_snapshot, scheduled_volume_snapshot, valkey, mysql, postgres, clickhouse, kafka and object_proxy. A notification names its kind in its object field.
availabilityZone string
Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.
name string
The webhook's name. Defaults to a unique name generated from the stack, stage and logical id. Changes in place.
status "active" | "paused" | string
Whether we send notifications to the webhook. - active: We send notifications. - paused: We send no notifications until you set it back to active.
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”availabilityZone string always set
Availability zone the resource lives in, such as us-west-2a.
id string always set
The webhook's ID, a UUID.
createdAt string
When the webhook was created.
failedDeliveries number
The number of notifications in a row that we couldn't deliver. A delivered notification resets it to 0.
name string
The webhook's name.
secret Redacted<string>
The secret deliveries are signed with: each one has an X-Signature header of sha256= followed by the hex HMAC-SHA256 of the raw body, keyed with this secret. Set when the webhook is created; to rotate it, replace the webhook.
status "active" | "paused"
Whether we send notifications to the webhook. - active: We send notifications. - paused: We send no notifications until you set it back to active.
teamId string
The ID of the team that owns the webhook. betterstack team list shows it.
updatedAt string
When the webhook was last updated.
url string
The URL we send notifications to. Use an HTTPS URL to protect what the notifications contain. To check that the URL receives notifications, send a test notification.
webhookTypes string[]
The kinds of resources we notify about. Accepts server, snapshot, reserved_ip, network, firewall, ssh_key, placement_group, scheduled_snapshot, load_balancer, certificate, volume, volume_snapshot, scheduled_volume_snapshot, valkey, mysql, postgres, clickhouse, kafka and object_proxy. A notification names its kind in its object field.
Lookup
Section titled “Lookup”Webhook.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
availabilityZone string
Zone it lives in, such as us-west-2a. Defaults to the credentials' zone.