Skip to contentSkip to page list

Docs

Update a trigger

Update an automation. Every field is optional and what is left out is left alone, except actionParams, which replaces the delivery configuration as a whole. The delivery channel and an alert's graph cannot be changed.

PATCH/api/v1/triggers/{triggerId}
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/triggers/<triggerId>"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {    "report": {        "schedule": {},    },}​response = requests.patch(    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/update-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.

Path parameters

triggerIdstringrequired
At least 1 character

Request body

application/json

namestring
At least 1 character
activeboolean
messagestring | null
alertTypestring | null
Option 1string
Option 2null
filtersobject
filterQuerystring | null

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

actionstring
One of"SEND_EMAIL""ADD_TO_DATASET""ADD_TO_ANNOTATION_QUEUE""SEND_SLACK_MESSAGE""SEND_WEBHOOK"
customGraphIdstring | null

The graph this alert watches, which an update cannot change. Accepted so that writing the read response back works; a different graph is refused. Create an alert on the other graph and delete this one.

actionParamsobject

Replaces the delivery configuration as a whole rather than merging into it: send the fields this automation should have from now on, and anything left out is removed. The one exception is a credential the read hid: send back the [redacted] placeholder and the stored credential is kept (a Slack automation not yet on a connection has its stored secret moved into one), so reading an automation, changing one field and writing the whole object back is safe. Only this channel's fields are accepted; anything else is refused rather than dropped, and the rule this automation fires by belongs in graphAlert or report.

Option 1object
Email delivery.
membersstring[]required

Who receives the email. Any address, not only teammates.

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

The Slack connection this automation posts through: an organization connection or one of this project's, listed under Settings, Integrations, Slack. A bot connection also needs slackChannelId; a webhook connection needs nothing else. Preferred over slackWebhook and slackBotToken, and what a read returns in their place.

slackDeliverystring

How the message reaches Slack. webhook posts to an incoming webhook URL, bot posts as the LangWatch Slack app. With slackIntegrationId it follows the connection's kind. Absent without a connection means webhook.

One of"webhook""bot"
slackWebhookstring

Legacy, accepted for one release: an incoming webhook URL, for webhook delivery. It is stored as a Slack connection (an existing one holding the same URL, else a new project connection) and the automation keeps only that connection's id. Send slackIntegrationId instead.

slackChannelIdstring

The channel the bot posts in, for a bot connection or bot delivery. Invite the LangWatch app to it first.

slackBotTokenstring

Legacy, accepted for one release: a bot token, for bot delivery. It is stored as a Slack connection (an existing one holding the same token, else a new project connection) and never reads back. Send slackIntegrationId instead.

slackBotTokenSetboolean

Legacy and ignored: no read returns it. An update that retypes no secret moves an automation's own stored secret into a connection.

Option 3object
Delivery to a customer endpoint over HTTP, with a body in any media type.
urlstringrequired

Where the request goes. https only, and not a private host.

methodstring

The HTTP method. Absent means POST.

One of"POST""PUT""PATCH"
headersobject

Static headers sent with every delivery. The values are credentials: they read back as the placeholder, and sending the placeholder back keeps the stored ones. Changing url means sending the values again in the same request.

bodyTemplatestring | null

A Liquid template for the body. Absent sends the standard LangWatch envelope for a JSON content type, and an empty body for any other.

contentTypestring

The Content-Type the delivery announces, which also decides how the body is treated: application/json (and any +json type) is checked and re-serialised; any other media type sends the rendered template verbatim. Absent means application/json.

signingSecretstring | null

Signs every delivery so the receiver can verify it came from LangWatch. A credential: it reads back as the placeholder, and sending the placeholder back keeps the stored one.

Option 4object
Append matched traces to a dataset.
datasetIdstringrequired

The dataset matched traces are appended to.

datasetMappingobjectrequired

How a trace becomes a row in that dataset.

Option 5object
Queue matched traces for a person to label.
annotatorsobject[]required

Who the queued items go to.

graphAlertobject

The rule this alert fires by. Only for an automation that is one.

thresholdnumberrequired
operatorstringrequired
One of"gt""lt""gte""lte""eq"
timePeriodnumberrequired
seriesNamestringrequired
At least 1 character
reportobject

What this report renders and when. Only for one that is a report.

sourceobjectrequired
scheduleobjectrequired
compareToPreviousboolean
Default: false
templatesobject

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

200

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
404

Not Found

application/json

errorstringrequired
messagestring

Documentation