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

> Page: https://langwatch.ai/docs/api-reference/triggers/update-triggers
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/triggers/update-triggers.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`PATCH https://app.langwatch.ai/api/v1/triggers/{triggerId}`

## Authentication

### project_api_key

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.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Parameters

### triggerId (path, required)

```json
{"type":"string","minLength":1}
```

## Request body (optional)

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "name": {"type":"string","minLength":1},
    "active": {"type":"boolean"},
    "message": {"type":["string","null"]},
    "alertType": {
      "anyOf": [{"type":"string","enum":["CRITICAL","WARNING","INFO"]},{"type":"null"}]
    },
    "filters": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {
        "anyOf": [
          {"type":"array","items":{"type":"string"}},
          {
            "type": "object",
            "propertyNames": {"type":"string"},
            "additionalProperties": {"type":"array","items":{"type":"string"}}
          },
          {
            "type": "object",
            "propertyNames": {"type":"string"},
            "additionalProperties": {
              "type": "object",
              "propertyNames": {"type":"string"},
              "additionalProperties": {"type":"array","items":{"type":"string"}}
            }
          }
        ]
      }
    },
    "filterQuery": {
      "description": "The trace query this automation is about, in the syntax the traces view uses. When set it supersedes `filters`.",
      "type": ["string","null"]
    },
    "action": {
      "type": "string",
      "enum": [
        "SEND_EMAIL",
        "ADD_TO_DATASET",
        "ADD_TO_ANNOTATION_QUEUE",
        "SEND_SLACK_MESSAGE",
        "SEND_WEBHOOK"
      ]
    },
    "customGraphId": {
      "description": "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.",
      "type": ["string","null"]
    },
    "actionParams": {
      "description": "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`.",
      "anyOf": [
        {
          "type": "object",
          "required": ["members"],
          "additionalProperties": {},
          "description": "Email delivery.",
          "properties": {
            "members": {
              "minItems": 1,
              "type": "array",
              "items": {"type":"string"},
              "description": "Who receives the email. Any address, not only teammates."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": {},
          "description": "Slack delivery through a Slack connection (`slackIntegrationId`), plus `slackChannelId` when the connection is a bot.",
          "properties": {
            "slackIntegrationId": {
              "description": "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.",
              "type": "string"
            },
            "slackDelivery": {
              "description": "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`.",
              "type": "string",
              "enum": ["webhook","bot"]
            },
            "slackWebhook": {
              "description": "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.",
              "type": "string"
            },
            "slackChannelId": {
              "description": "The channel the bot posts in, for a bot connection or `bot` delivery. Invite the LangWatch app to it first.",
              "type": "string"
            },
            "slackBotToken": {
              "description": "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.",
              "type": "string"
            },
            "slackBotTokenSet": {
              "description": "Legacy and ignored: no read returns it. An update that retypes no secret moves an automation's own stored secret into a connection.",
              "type": "boolean"
            }
          }
        },
        {
          "type": "object",
          "required": ["url"],
          "additionalProperties": {},
          "description": "Delivery to a customer endpoint over HTTP, with a body in any media type.",
          "properties": {
            "url": {
              "type": "string",
              "description": "Where the request goes. https only, and not a private host."
            },
            "method": {
              "description": "The HTTP method. Absent means POST.",
              "type": "string",
              "enum": ["POST","PUT","PATCH"]
            },
            "headers": {
              "description": "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.",
              "type": "object",
              "propertyNames": {"type":"string"},
              "additionalProperties": {"type":"string"}
            },
            "bodyTemplate": {
              "description": "A Liquid template for the body. Absent sends the standard LangWatch envelope for a JSON content type, and an empty body for any other.",
              "type": ["string","null"]
            },
            "contentType": {
              "description": "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`.",
              "type": "string"
            },
            "signingSecret": {
              "description": "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.",
              "type": ["string","null"]
            }
          }
        },
        {
          "type": "object",
          "required": ["datasetId","datasetMapping"],
          "additionalProperties": {},
          "description": "Append matched traces to a dataset.",
          "properties": {
            "datasetId": {
              "type": "string",
              "description": "The dataset matched traces are appended to."
            },
            "datasetMapping": {
              "type": "object",
              "properties": {
                "mapping": {
                  "type": "object",
                  "propertyNames": {"type":"string"},
                  "additionalProperties": {}
                },
                "expansions": {"type":"array","items":{"type":"string"}}
              },
              "required": ["mapping"],
              "description": "How a trace becomes a row in that dataset."
            }
          }
        },
        {
          "type": "object",
          "required": ["annotators"],
          "additionalProperties": {},
          "description": "Queue matched traces for a person to label.",
          "properties": {
            "annotators": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {"id":{"type":"string"},"name":{"type":"string"}},
                "required": ["id","name"]
              },
              "description": "Who the queued items go to."
            }
          }
        }
      ]
    },
    "graphAlert": {
      "description": "The rule this alert fires by. Only for an automation that is one.",
      "type": "object",
      "properties": {
        "threshold": {"type":"number"},
        "operator": {"type":"string","enum":["gt","lt","gte","lte","eq"]},
        "timePeriod": {
          "anyOf": [
            {"type":"number","const":1},
            {"type":"number","const":5},
            {"type":"number","const":15},
            {"type":"number","const":30},
            {"type":"number","const":60},
            {"type":"number","const":1440}
          ]
        },
        "seriesName": {"type":"string","minLength":1}
      },
      "required": ["threshold","operator","timePeriod","seriesName"]
    },
    "report": {
      "description": "What this report renders and when. Only for one that is a report.",
      "type": "object",
      "properties": {
        "source": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {"type":"string","const":"dashboard"},
                "dashboardId": {"type":"string","minLength":1}
              },
              "required": ["kind","dashboardId"]
            },
            {
              "type": "object",
              "properties": {
                "kind": {"type":"string","const":"customGraph"},
                "customGraphId": {"type":"string","minLength":1}
              },
              "required": ["kind","customGraphId"]
            },
            {
              "type": "object",
              "properties": {
                "kind": {"type":"string","const":"traceQuery"},
                "filters": {
                  "default": {},
                  "type": "object",
                  "propertyNames": {"type":"string"},
                  "additionalProperties": {}
                },
                "metric": {"type":"string"},
                "topN": {"default":5,"type":"integer","minimum":1,"maximum":100}
              },
              "required": ["kind"]
            }
          ]
        },
        "schedule": {
          "type": "object",
          "properties": {
            "cron": {"type":"string","minLength":1,"maxLength":120},
            "timezone": {"type":"string","minLength":1,"maxLength":64}
          },
          "required": ["cron","timezone"]
        },
        "compareToPrevious": {"default":false,"type":"boolean"}
      },
      "required": ["source","schedule"]
    },
    "templates": {
      "type": "object",
      "properties": {
        "slackTemplateType": {
          "anyOf": [{"type":"string","enum":["string","block_kit"]},{"type":"null"}]
        },
        "slackTemplate": {"type":["string","null"]},
        "emailSubjectTemplate": {"type":["string","null"]},
        "emailBodyTemplate": {"type":["string","null"]}
      },
      "description": "The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel."
    },
    "notificationCadence": {
      "type": "string",
      "enum": ["immediate","5min_digest","15min_digest","hourly_digest"],
      "description": "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."
    },
    "traceDebounceMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 600000,
      "description": "How long to wait for a trace to settle before the conditions are read."
    }
  }
}
```

## Request example

```bash
curl --request PATCH \
  --url 'https://app.langwatch.ai/api/v1/triggers/<triggerId>' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"name":"string","active":false,"message":"string","alertType":"CRITICAL","filters":{},"filterQuery":"string","action":"SEND_EMAIL","customGraphId":"string","actionParams":{"members":["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}'
```

## Responses

### 200

Success

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "id": {"type":"string"},
    "name": {"type":"string"},
    "action": {
      "type": "string",
      "enum": [
        "SEND_EMAIL",
        "ADD_TO_DATASET",
        "ADD_TO_ANNOTATION_QUEUE",
        "SEND_SLACK_MESSAGE",
        "SEND_WEBHOOK"
      ]
    },
    "actionParams": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {},
      "description": "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."
    },
    "graphAlert": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "threshold": {"type":"number"},
            "operator": {"type":"string","enum":["gt","lt","gte","lte","eq"]},
            "timePeriod": {
              "anyOf": [
                {"type":"number","const":1},
                {"type":"number","const":5},
                {"type":"number","const":15},
                {"type":"number","const":30},
                {"type":"number","const":60},
                {"type":"number","const":1440}
              ]
            },
            "seriesName": {"type":"string","minLength":1}
          },
          "required": ["threshold","operator","timePeriod","seriesName"],
          "additionalProperties": false
        },
        {"type":"null"}
      ],
      "description": "The rule an alert fires by. Null for anything that is not one."
    },
    "report": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "source": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {"type":"string","const":"dashboard"},
                    "dashboardId": {"type":"string","minLength":1}
                  },
                  "required": ["kind","dashboardId"],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {"type":"string","const":"customGraph"},
                    "customGraphId": {"type":"string","minLength":1}
                  },
                  "required": ["kind","customGraphId"],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {"type":"string","const":"traceQuery"},
                    "filters": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {"type":"string"},
                      "additionalProperties": {}
                    },
                    "metric": {"type":"string"},
                    "topN": {"default":5,"type":"integer","minimum":1,"maximum":100}
                  },
                  "required": ["kind","filters","topN"],
                  "additionalProperties": false
                }
              ]
            },
            "schedule": {
              "type": "object",
              "properties": {
                "cron": {"type":"string","minLength":1,"maxLength":120},
                "timezone": {"type":"string","minLength":1,"maxLength":64}
              },
              "required": ["cron","timezone"],
              "additionalProperties": false
            },
            "compareToPrevious": {"default":false,"type":"boolean"}
          },
          "required": ["source","schedule","compareToPrevious"],
          "additionalProperties": false
        },
        {"type":"null"}
      ],
      "description": "What a report renders and when. Null for anything else."
    },
    "filters": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "filterQuery": {"type":["string","null"]},
    "kind": {
      "type": "string",
      "enum": ["AUTOMATION","ALERT","REPORT"],
      "description": "What this automation is about: matching traces, a metric crossing a threshold, or a schedule."
    },
    "customGraphId": {"type":["string","null"]},
    "notificationCadence": {"type":["string","null"]},
    "traceDebounceMs": {"type":["number","null"]},
    "templates": {
      "type": "object",
      "properties": {
        "slackTemplateType": {
          "anyOf": [{"type":"string","enum":["string","block_kit"]},{"type":"null"}]
        },
        "slackTemplate": {"type":["string","null"]},
        "emailSubjectTemplate": {"type":["string","null"]},
        "emailBodyTemplate": {"type":["string","null"]}
      },
      "additionalProperties": false,
      "description": "The Liquid templates this automation's message is rendered from. Absent fields render the LangWatch default for the channel."
    },
    "active": {"type":"boolean"},
    "message": {"type":["string","null"]},
    "alertType": {
      "anyOf": [{"type":"string","enum":["CRITICAL","WARNING","INFO"]},{"type":"null"}]
    },
    "createdAt": {"type":"string"},
    "updatedAt": {"type":"string"},
    "platformUrl": {"type":"string","format":"uri"}
  },
  "required": [
    "id",
    "name",
    "action",
    "actionParams",
    "graphAlert",
    "report",
    "filters",
    "filterQuery",
    "kind",
    "customGraphId",
    "notificationCadence",
    "traceDebounceMs",
    "templates",
    "active",
    "message",
    "alertType",
    "createdAt",
    "updatedAt",
    "platformUrl"
  ],
  "additionalProperties": false
}
```

### 404

Not Found

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
