# Update a trigger

`PATCH https://api.cademi.com.br/api/v3/automations/diamond/{diamond_id}/triggers/{trigger_id}`

Operation ID: `diamonds.triggers.update` · API v3

Configures a stage trigger: whether it is enabled, its channel, destination, and template. The destination field must match the selected channel.

HTTP destinations must resolve to a public host; private, loopback, and metadata addresses are rejected.

The change applies to future communications with leads; nothing is sent when the trigger is updated.

Send the trigger's current `ETag` in the `If-Match` header to avoid overwriting a newer version.

Required permissions: `diamonds.manage_triggers`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `diamond_id` | path | string | yes |  |
| `trigger_id` | path | string | yes |  |
| `If-Match` | header | string | no |  |

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `channel` | string, one of `http`, `whatsapp`, `sms`, `email` | no |  |
| `destination` | object or null | no |  |
| `enabled` | boolean | no |  |
| `template` | string or null | no |  |

## Responses

### 200

Returns the updated trigger.

Body: `data`: Trigger.

Fields of Trigger:

| Field | Type | Required | Description |
|---|---|---|---|
| `channel` | string, one of `http`, `whatsapp`, `sms`, `email` | yes |  |
| `created_at` | string (date-time) | yes |  |
| `destination` | object or null | yes | Masked destination: the URL host or the last digits of the phone number. |
| `diamond_id` | string | yes | Public ID of the Diamond, with the dmd_ prefix. |
| `enabled` | boolean | yes |  |
| `event_type` | string | yes | Event type delivered to automations, in the form spyhub.diamond.{stage}. |
| `id` | string | yes | Public ID, with the trg_ prefix. |
| `object` | string, one of `trigger` | yes |  |
| `revision` | string | yes |  |
| `stage_id` | string | yes | Stage of the trigger. |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The trigger was not found in this Diamond or is not accessible with the current credentials.

Body: Error.

### 409

Diamond automations are not enabled for the current account.

Body: Error.

### 412

The resource has changed since the supplied revision was retrieved.

Body: Error.

### 422

The channel is not supported, or the destination is invalid or not allowed.

Body: Error.

Full schema: https://cademi.dev/openapi/v3.json
