# Ensure a stage trigger

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

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

Ensures that the trigger for a given stage exists. Every stage already has a trigger when the Diamond is created, so this operation normally returns the existing trigger; it creates a new one only if the stage's trigger is missing.

Changes to triggers affect future communications with leads.

Required permissions: `diamonds.manage_triggers`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `diamond_id` | path | string | yes |  |
| `Idempotency-Key` | header | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `stage_id` | string | yes |  |

## Responses

### 200

The trigger already exists. Returns the existing 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 |  |

### 201

Returns the newly created 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 Diamond was not found or is not accessible with the current credentials.

Body: Error.

### 409

Diamond automations are not enabled for the current account.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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