Skip to contentSkip to page list

Docs

Create a new trigger

Create an automation. Send customGraphId + graphAlert for an alert on a metric, report for a scheduled report, or conditions for a trace automation. The delivery channel is fixed at creation.

POST/api/v1/triggers
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/triggers"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {    "action": "SEND_EMAIL",    "actionParams": {        "members": [            "string",        ],    },    "name": "string",    "filters": {},    "filterQuery": "string",    "message": "string",    "alertType": "CRITICAL",    "customGraphId": "string",    "graphAlert": {        "threshold": 0,        "operator": "gt",        "timePeriod": 1,        "seriesName": "string",    },    "report": {        "source": {            "kind": "dashboard",            "dashboardId": "string",        },        "schedule": {            "cron": "string",            "timezone": "string",        },        "compareToPrevious": False,    },    "templates": {        "slackTemplateType": "string",        "slackTemplate": "string",        "emailSubjectTemplate": "string",        "emailBodyTemplate": "string",    },    "notificationCadence": "immediate",    "traceDebounceMs": 0,}​response = requests.post(    origin + path,    headers=headers,    json=payload,)print(response.json())

Success

application/json · Generated from schema

{  "id": "string",  "name": "string",  "action": "SEND_EMAIL",  "actionParams": {},  "graphAlert": {    "threshold": 0,    "operator": "gt",    "timePeriod": 1,    "seriesName": "string"  },  "report": {    "source": {      "kind": "dashboard",      "dashboardId": "string"    },    "schedule": {      "cron": "string",      "timezone": "string"    },    "compareToPrevious": false  },  "filters": {},  "filterQuery": "string",  "kind": "AUTOMATION",  "customGraphId": "string",  "notificationCadence": "string",  "traceDebounceMs": 0,  "templates": {    "slackTemplateType": "string",    "slackTemplate": "string",    "emailSubjectTemplate": "string",    "emailBodyTemplate": "string"  },  "active": false,  "message": "string",  "alertType": "CRITICAL",  "createdAt": "string",  "updatedAt": "string",  "platformUrl": "string"}
api-reference/triggers/create-triggers

Authorization

X-Auth-Tokenstringheaderrequired

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

Request body

application/json · Required

One of 5
Option 1action: "SEND_EMAIL"object
actionstringrequired
Always"SEND_EMAIL"
actionParamsobjectrequired

Email delivery.

namestringrequired
At least 1 character
filtersobject
filterQuerystring | null

The trace query this automation is about, in the syntax the traces view uses. When set it supersedes filters.

messagestring
alertTypestring
One of"CRITICAL""WARNING""INFO"
customGraphIdstring

Set to make this an alert on that graph. graphAlert and alertType are then required.

graphAlertobject

The rule an alert fires by: series, operator, threshold, window.

reportobject

What a scheduled report renders and when it sends.

templatesobject

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

notificationCadencestring

How often a notification automation is allowed to send. A new one starts on a five-minute digest, which is what keeps a broad condition from sending a message per matching trace.

One of"immediate""5min_digest""15min_digest""hourly_digest"
traceDebounceMsinteger

How long to wait for a trace to settle before the conditions are read.

Minimum 0Maximum 600000
Option 2action: "SEND_SLACK_MESSAGE"object
actionstringrequired
Always"SEND_SLACK_MESSAGE"
actionParamsobjectrequired

Slack delivery through a Slack connection (slackIntegrationId), plus slackChannelId when the connection is a bot.

namestringrequired
At least 1 character
filtersobject
filterQuerystring | null

The trace query this automation is about, in the syntax the traces view uses. When set it supersedes filters.

messagestring
alertTypestring
One of"CRITICAL""WARNING""INFO"
customGraphIdstring

Set to make this an alert on that graph. graphAlert and alertType are then required.

graphAlertobject

The rule an alert fires by: series, operator, threshold, window.

reportobject

What a scheduled report renders and when it sends.

templatesobject

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

notificationCadencestring

How often a notification automation is allowed to send. A new one starts on a five-minute digest, which is what keeps a broad condition from sending a message per matching trace.

One of"immediate""5min_digest""15min_digest""hourly_digest"
traceDebounceMsinteger

How long to wait for a trace to settle before the conditions are read.

Minimum 0Maximum 600000
Option 3action: "SEND_WEBHOOK"object
actionstringrequired
Always"SEND_WEBHOOK"
actionParamsobjectrequired

Delivery to a customer endpoint over HTTP, with a body in any media type.

namestringrequired
At least 1 character
filtersobject
filterQuerystring | null

The trace query this automation is about, in the syntax the traces view uses. When set it supersedes filters.

messagestring
alertTypestring
One of"CRITICAL""WARNING""INFO"
customGraphIdstring

Set to make this an alert on that graph. graphAlert and alertType are then required.

graphAlertobject

The rule an alert fires by: series, operator, threshold, window.

reportobject

What a scheduled report renders and when it sends.

templatesobject

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

notificationCadencestring

How often a notification automation is allowed to send. A new one starts on a five-minute digest, which is what keeps a broad condition from sending a message per matching trace.

One of"immediate""5min_digest""15min_digest""hourly_digest"
traceDebounceMsinteger

How long to wait for a trace to settle before the conditions are read.

Minimum 0Maximum 600000
Option 4action: "ADD_TO_DATASET"object
actionstringrequired
Always"ADD_TO_DATASET"
actionParamsobjectrequired

Append matched traces to a dataset.

namestringrequired
At least 1 character
filtersobject
filterQuerystring | null

The trace query this automation is about, in the syntax the traces view uses. When set it supersedes filters.

messagestring
alertTypestring
One of"CRITICAL""WARNING""INFO"
customGraphIdstring

Set to make this an alert on that graph. graphAlert and alertType are then required.

graphAlertobject

The rule an alert fires by: series, operator, threshold, window.

reportobject

What a scheduled report renders and when it sends.

templatesobject

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

notificationCadencestring

How often a notification automation is allowed to send. A new one starts on a five-minute digest, which is what keeps a broad condition from sending a message per matching trace.

One of"immediate""5min_digest""15min_digest""hourly_digest"
traceDebounceMsinteger

How long to wait for a trace to settle before the conditions are read.

Minimum 0Maximum 600000
Option 5action: "ADD_TO_ANNOTATION_QUEUE"object
actionstringrequired
Always"ADD_TO_ANNOTATION_QUEUE"
actionParamsobjectrequired

Queue matched traces for a person to label.

namestringrequired
At least 1 character
filtersobject
filterQuerystring | null

The trace query this automation is about, in the syntax the traces view uses. When set it supersedes filters.

messagestring
alertTypestring
One of"CRITICAL""WARNING""INFO"
customGraphIdstring

Set to make this an alert on that graph. graphAlert and alertType are then required.

graphAlertobject

The rule an alert fires by: series, operator, threshold, window.

reportobject

What a scheduled report renders and when it sends.

templatesobject

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

notificationCadencestring

How often a notification automation is allowed to send. A new one starts on a five-minute digest, which is what keeps a broad condition from sending a message per matching trace.

One of"immediate""5min_digest""15min_digest""hourly_digest"
traceDebounceMsinteger

How long to wait for a trace to settle before the conditions are read.

Minimum 0Maximum 600000

Responses

201

Success

application/json

idstringrequired
namestringrequired
actionstringrequired
One of"SEND_EMAIL""ADD_TO_DATASET""ADD_TO_ANNOTATION_QUEUE""SEND_SLACK_MESSAGE""SEND_WEBHOOK"
actionParamsobjectrequired

Where this automation delivers, with every credential value replaced by the [redacted] placeholder. Which channel is configured, which destination is set and which header names are in play all survive; the values never leave; a Slack automation names its connection by slackIntegrationId and carries no secret. Sending the placeholder back on an update keeps the stored value. The rule this automation fires by is not here: it is stated in graphAlert or report, and sending it in this field is refused.

graphAlertobject | nullrequired

The rule an alert fires by. Null for anything that is not one.

Option 1object
thresholdnumberrequired
operatorstringrequired
One of"gt""lt""gte""lte""eq"
timePeriodnumberrequired
seriesNamestringrequired
At least 1 character
Option 2null
reportobject | nullrequired

What a report renders and when. Null for anything else.

Option 1object
sourceobjectrequired
scheduleobjectrequired
compareToPreviousbooleanrequired
Default: false
Option 2null
filtersobjectrequired
filterQuerystring | nullrequired
kindstringrequired

What this automation is about: matching traces, a metric crossing a threshold, or a schedule.

One of"AUTOMATION""ALERT""REPORT"
customGraphIdstring | nullrequired
notificationCadencestring | nullrequired
traceDebounceMsnumber | nullrequired
templatesobjectrequired

The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel.

slackTemplateTypestring | null
slackTemplatestring | null
emailSubjectTemplatestring | null
emailBodyTemplatestring | null
activebooleanrequired
messagestring | nullrequired
alertTypestring | nullrequired
Option 1string
Option 2null
createdAtstringrequired
updatedAtstringrequired
platformUrlstring (uri)required

Documentation