> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update an Alert

> Update an alert (event subscription) with JSON Patch or by sending the full definition again through the Collate REST API or Python SDK.

# Update an Alert

Update an alert in one of two ways:

* Send the full definition with `PUT /v1/events/subscriptions`. Collate matches on `name`, so a request with an existing name replaces the alert's configuration. This is the simplest option for managing alerts as code.
* Patch individual fields with JSON Patch.

## Body Parameters

**name** `string` *required*

Name that uniquely identifies the alert. A request with an existing name updates that alert.

**alertType** `string` *required*

Type of alert, for example `Observability`, `Notification`, or `ActivityFeed`.

**displayName** `string`

Display name of the alert.

**description** `string`

Description of the alert in Markdown format.

**enabled** `boolean`

Whether the alert is enabled.

**resources** `array`

Source the alert listens to, for example `testCase`. An alert has exactly one value.

**input** `object`

Filters and triggers that decide which events the alert acts on.

**destinations** `array`

Where the alert sends notifications, for example a webhook, Slack, or email.

**owners** `array`

Owner references (users or teams) to assign to the alert.

For the full request schema, see the [Alerts overview](https://docs.getcollate.io/api-reference/alerts.md#request-schema).

## Update with JSON Patch

* By ID: `PATCH /v1/events/subscriptions/{id}`
* By name: `PATCH /v1/events/subscriptions/name/{name}`

Send a JSON Patch document and set the `Content-Type` header to `application/json-patch+json`.

Replace `{id}` with the UUID of the alert.

```bash PUT /v1/events/subscriptions theme={null}
curl -X PUT "https://your-company.getcollate.io/api/v1/events/subscriptions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "dq-failed-tests-to-webhook",
    "displayName": "DQ failed tests to webhook",
    "description": "Notify the endpoint when a test case fails.",
    "alertType": "Observability",
    "resources": ["testCase"],
    "enabled": true,
    "input": {
      "filters": [
        {
          "name": "filterByFqn",
          "effect": "include",
          "prefixCondition": "AND",
          "arguments": [{ "name": "fqnList", "input": ["svc.db.schema.orders"] }]
        }
      ],
      "actions": [
        {
          "name": "GetTestCaseStatusUpdates",
          "effect": "include",
          "prefixCondition": "AND",
          "arguments": [{ "name": "testResultList", "input": ["Failed"] }]
        }
      ]
    },
    "destinations": [
      {
        "category": "External",
        "type": "Webhook",
        "timeout": 10,
        "readTimeout": 12,
        "enabled": true,
        "config": {
          "endpoint": "https://hooks.example.com/collate",
          "httpMethod": "POST",
          "headers": { "X-Source": "collate" },
          "authType": { "type": "bearer", "secretKey": "<hmac-secret>" }
        }
      }
    ]
  }'
```

```bash PATCH /v1/events/subscriptions/{id} theme={null}
# Disable an alert
curl -X PATCH "https://your-company.getcollate.io/api/v1/events/subscriptions/$ALERT_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json-patch+json" \
  -d '[{ "op": "replace", "path": "/enabled", "value": false }]'
```

```python PUT /v1/events/subscriptions theme={null}
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
    OpenMetadataConnection,
)
from metadata.generated.schema.security.client.openMetadataJWTClientConfig import (
    OpenMetadataJWTClientConfig,
)
from metadata.generated.schema.events.api.createEventSubscription import (
    CreateEventSubscription,
)
from metadata.generated.schema.events.eventSubscription import (
    AlertType,
    Destination,
    SubscriptionCategory,
    SubscriptionType,
)

server_config = OpenMetadataConnection(
    hostPort="https://your-company.getcollate.io/api",
    authProvider="openmetadata",
    securityConfig=OpenMetadataJWTClientConfig(jwtToken="<YOUR-JWT-TOKEN>"),
)
metadata = OpenMetadata(server_config)

# Send the full definition again with the same name to update the alert
request = CreateEventSubscription(
    name="dq-failed-tests-to-webhook",
    alertType=AlertType.Observability,
    resources=["testCase"],
    input={
        "filters": [
            {
                "name": "filterByFqn",
                "effect": "include",
                "prefixCondition": "AND",
                "arguments": [{"name": "fqnList", "input": ["svc.db.schema.orders"]}],
            }
        ],
        "actions": [
            {
                "name": "GetTestCaseStatusUpdates",
                "effect": "include",
                "prefixCondition": "AND",
                "arguments": [{"name": "testResultList", "input": ["Failed"]}],
            }
        ],
    },
    destinations=[
        Destination(
            category=SubscriptionCategory.External,
            type=SubscriptionType.Webhook,
            config={"endpoint": "https://hooks.example.com/collate"},
        )
    ],
    enabled=False,
)
metadata.create_or_update(data=request)
```

## Notes

Keep these points in mind when you update an alert.

* **Delivery restart**: after an update, Collate restarts the alert's delivery process so the change takes effect for new events.
* **Changing filters or triggers**: to change `input` (filters and triggers) or `destinations`, send the full definition with `PUT`. This is more reliable than patching the nested `input` field, because Collate rebuilds the expanded conditions from the full request.
* **Changing sources**: `resources` can hold several sources. When you change them, check that every filter and trigger in `input` still applies to the new sources. Otherwise the update fails with a `400` error.
* **Existing events**: an update doesn't replay past events.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.