Skip to content
betterstack-alchemyUnofficial

Incidents.IncomingEmailIntegration

Kind ResourceType id BetterStack.Incidents.IncomingEmailIntegrationSource src/Incidents/IncomingEmailIntegration.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_PAID_INTEGRATIONS=1 because the test account's plan refuses this integration (test/Incidents/IncomingEmailIntegration.test.ts).

An e-mail address that opens incidents from the e-mails it receives. Better Stack gives you an emailAddress: have the other system (a legacy monitoring tool, a cron daemon’s MAILTO, a vendor’s status e-mails) send its alerts there. Fields you set pick values such as the cause out of each e-mail (fieldTarget: from_email, subject or body), and rules decide whether an e-mail opens (startedRuleType + startedRules), acknowledges or resolves an incident. By default the cause is the whole subject.

Every prop updates in place except teamId, which replaces the integration (and gives it a new emailAddress). name defaults to a generated unique name. Removing escalationPolicyId, teamWait, titleField, an alert id field or an other*Fields list clears it; removing causeField, the rule lists or metadata keeps what the integration has.

The API adds createdAt/updatedAt to every rule and returns every member of a field (unset ones null, plus its role in specialType); the attributes drop those, so they read like the props and an update sends only what changed.

Subjects starting with [ALERT] open, [OK] resolve

const subjectId: AlertField = { fieldTarget: "subject", matchType: "match_after", content: "] " };
const inbox = yield* BetterStack.Incidents.IncomingEmailIntegration("legacy-alerts", {
startedRuleType: "any",
startedRules: [{ ruleTarget: "subject", matchType: "contains", content: "[ALERT]" }],
resolvedRuleType: "any",
resolvedRules: [{ ruleTarget: "subject", matchType: "contains", content: "[OK]" }],
startedAlertIdField: subjectId,
resolvedAlertIdField: subjectId,
});

A crontab MAILTO line from the deployed address

const crontab = (address: string) => `MAILTO=${address}\n0 3 * * * /usr/local/bin/backup`;
const line = crontab(inbox.emailAddress ?? "");

acknowledgedAlertIdField CreateIncidentsIncomingEmailIntegrationRequestAcknowledgedAlertIdField | null

How to extract the alert ID from an e-mail that acknowledges an incident, with the same keys as cause_field. Required when acknowledged_rule_type isn't unused.

acknowledgedRules CreateIncidentsIncomingEmailIntegrationRequestAcknowledgedRulesItem[]

The conditions acknowledged_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

acknowledgedRuleType "any" | "all" | "unused" | string

When e-mails acknowledge an incident. Any value other than unused needs started_alert_id_field, acknowledged_alert_id_field and at least one rule.

call boolean

Whether to call the on-call person. Ignored while an escalation policy is set.

causeField CreateIncidentsIncomingEmailIntegrationRequestCauseField | null

How to extract the incident cause from the e-mail that starts an incident. Defaults to the whole subject.

criticalAlert boolean

Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.

email boolean

Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.

escalationPolicyId string | null

ID of the escalation policy for alerts, or null to alert the current on-call person directly. Returned as a string.

metadata CreateIncidentsIncomingEmailIntegrationRequestMetadataMap

Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. A key accepts a single value or a list. Values under one key must all be the same type and can't repeat. An update replaces all of the integration's metadata with the object, {} removes it all, and leaving metadata out keeps it.

name string

The name shown in the dashboard. Defaults to a unique name generated from the stack, stage and logical id.

otherAcknowledgedFields CreateIncidentsIncomingEmailIntegrationRequestOtherAcknowledgedFieldsItem[] | null

Custom fields extracted from an e-mail that acknowledges an incident.

otherResolvedFields CreateIncidentsIncomingEmailIntegrationRequestOtherResolvedFieldsItem[] | null

Custom fields extracted from an e-mail that resolves an incident.

otherStartedFields CreateIncidentsIncomingEmailIntegrationRequestOtherStartedFieldsItem[] | null

Custom fields extracted from the e-mail that opens an incident, saved as incident metadata.

paused boolean

Whether the integration is paused. A paused integration opens no incidents.

push boolean

Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.

recoveryPeriod 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200 | number

How long to wait after a resolving e-mail before the incident resolves, in seconds. A new alert during the wait keeps the incident open. Applies only while resolved_rule_type isn't unused.

resolvedAlertIdField CreateIncidentsIncomingEmailIntegrationRequestResolvedAlertIdField | null

How to extract the alert ID from an e-mail that resolves an incident, with the same keys as cause_field. Required when resolved_rule_type isn't unused.

resolvedRules CreateIncidentsIncomingEmailIntegrationRequestResolvedRulesItem[]

The conditions resolved_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

resolvedRuleType "any" | "all" | "unused" | string

When e-mails resolve an incident. Any value other than unused needs started_alert_id_field, resolved_alert_id_field and at least one rule. Each e-mail is checked against the resolve rules first, then the acknowledge rules, then the open rules. An e-mail that matches no open incident can still open one.

sms boolean

Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.

startedAlertIdField CreateIncidentsIncomingEmailIntegrationRequestStartedAlertIdField | null

How to extract the alert ID from the e-mail that starts an incident, with the same keys as cause_field. Later e-mails acknowledge or resolve the open incident with the same alert ID. Required when acknowledged_rule_type or resolved_rule_type isn't unused.

startedRules CreateIncidentsIncomingEmailIntegrationRequestStartedRulesItem[]

The conditions started_rule_type checks. At least one rule is required when the type is any or all.

startedRuleType "any" | "all" | "unused" | string

When e-mails open an incident. Every value other than unused needs at least one rule. When started_alert_id_field finds an alert ID that matches an open incident, the e-mail goes to that incident instead of opening a new one.

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.

teamWait number | null

Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.

titleField CreateIncidentsIncomingEmailIntegrationRequestTitleField | null

Field that extracts the incident title, with the same keys as cause_field.

id string always set

The incidents_incoming_email_integration's id.

acknowledgedAlertIdField IncidentsIncomingEmailIntegrationAcknowledgedAlertIdField | null

How to extract the alert ID from an e-mail that acknowledges an incident, with the same keys as cause_field. Required when acknowledged_rule_type isn't unused.

acknowledgedRules IncidentsIncomingEmailIntegrationAcknowledgedRulesItem[]

The conditions acknowledged_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

acknowledgedRuleType "any" | "all" | "unused"

When e-mails acknowledge an incident. Any value other than unused needs started_alert_id_field, acknowledged_alert_id_field and at least one rule.

call boolean

Whether to call the on-call person. Ignored while an escalation policy is set.

causeField IncidentsIncomingEmailIntegrationCauseField | null

How to extract the incident cause from the e-mail that starts an incident. Defaults to the whole subject.

createdAt string

When the integration was created.

criticalAlert boolean

Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.

email boolean

Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.

emailAddress string

The address to forward your e-mails to. E-mails sent to it open incidents.

escalationPolicyId string | null

ID of the escalation policy for alerts, or null to alert the current on-call person directly. Returned as a string.

metadata IncidentsIncomingEmailIntegrationMetadataMap

Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. A key accepts a single value or a list. Values under one key must all be the same type and can't repeat.

name string | null

The name of the e-mail integration shown in the dashboard.

otherAcknowledgedFields IncidentsIncomingEmailIntegrationOtherAcknowledgedFieldsItem[] | null

Custom fields extracted from an e-mail that acknowledges an incident.

otherResolvedFields IncidentsIncomingEmailIntegrationOtherResolvedFieldsItem[] | null

Custom fields extracted from an e-mail that resolves an incident.

otherStartedFields IncidentsIncomingEmailIntegrationOtherStartedFieldsItem[] | null

Custom fields extracted from the e-mail that opens an incident, saved as incident metadata.

paused boolean

Whether the integration is paused. A paused integration opens no incidents.

push boolean

Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.

recoveryPeriod 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200

How long to wait after a resolving e-mail before the incident resolves, in seconds. A new alert during the wait keeps the incident open. Applies only while resolved_rule_type isn't unused.

resolvedAlertIdField IncidentsIncomingEmailIntegrationResolvedAlertIdField | null

How to extract the alert ID from an e-mail that resolves an incident, with the same keys as cause_field. Required when resolved_rule_type isn't unused.

resolvedRules IncidentsIncomingEmailIntegrationResolvedRulesItem[]

The conditions resolved_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

resolvedRuleType "any" | "all" | "unused"

When e-mails resolve an incident. Any value other than unused needs started_alert_id_field, resolved_alert_id_field and at least one rule. Each e-mail is checked against the resolve rules first, then the acknowledge rules, then the open rules. An e-mail that matches no open incident can still open one.

sms boolean

Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.

startedAlertIdField IncidentsIncomingEmailIntegrationStartedAlertIdField | null

How to extract the alert ID from the e-mail that starts an incident, with the same keys as cause_field. Later e-mails acknowledge or resolve the open incident with the same alert ID. Required when acknowledged_rule_type or resolved_rule_type isn't unused.

startedRules IncidentsIncomingEmailIntegrationStartedRulesItem[]

The conditions started_rule_type checks. At least one rule is required when the type is any or all.

startedRuleType "any" | "all" | "unused"

When e-mails open an incident. Every value other than unused needs at least one rule. When started_alert_id_field finds an alert ID that matches an open incident, the e-mail goes to that incident instead of opening a new one.

teamId string

Team that owns this integration, such as t123.

teamName string

Name of the team that owns this integration.

teamWait number | null

Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.

titleField IncidentsIncomingEmailIntegrationTitleField | null

Field that extracts the incident title, with the same keys as cause_field.

updatedAt string

When the integration was last updated.

IncomingEmailIntegration.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.