---
url: https://next.zammad.org/pt_BR/reference/rest-api/trigger.md
---

# Gatilho

::: info
Os gatilhos podem executar uma ação `notification.webhook` que referencia um
[webhook](/pt_BR/reference/rest-api/webhook) pelo id
(`{"notification.webhook": {"webhook_id": <id>}}`) em vez de, ou
junto com, `notification.email`. Crie o webhook primeiro e depois aponte
a ação perform do gatilho para o `id` dele.
:::

## Listar

Permissão necessária: `admin.trigger`

Solicitação `GET` enviada: `/api/v1/triggers`

::: details

```json
// HTTP-Code 200 OK

[
  {
    "id": 2,
    "name": "auto reply (on follow-up of tickets)",
    "condition": {
      "ticket.action": {
        "operator": "is",
        "value": "update"
      },
      "article.sender_id": {
        "operator": "is",
        "value": 2
      },
      "article.type_id": {
        "operator": "is",
        "value": [
          1,
          5,
          11
        ]
      }
    },
    "perform": {
      "notification.email": {
        "body": "<div>Your follow-up for <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>\n<br/>\n<div>To provide additional information, please reply to this email or click on the following link:\n<a href=\"#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}\">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>\n</div>\n<br/>\n<div>Your #{config.product_name} Team</div>\n<br/>\n<div><i><a href=\"https://zammad.com\">Zammad</a>, your customer support system</i></div>",
        "recipient": "article_last_sender",
        "subject": "Thanks for your follow-up (#{ticket.title})"
      }
    },
    "disable_notification": true,
    "localization": null,
    "timezone": null,
    "note": null,
    "activator": "action",
    "execution_condition_mode": "selective",
    "active": false,
    "updated_by_id": 1,
    "created_by_id": 1,
    "created_at": "2026-09-07T06:40:27.193Z",
    "updated_at": "2026-09-07T06:40:27.193Z"
  }
]

```

:::

::: info
`recipient: "article_last_sender"` envia o email para quem escreveu o artigo
que disparou o gatilho. Neste exemplo, é sempre o cliente, porque a
condição exige que `article.sender_id` seja `2` (Customer). Se um agente
tivesse escrito o artigo, o agente receberia o email. Use
`recipient: "ticket_customer"` (veja Create abaixo) para sempre direcionar ao
cliente, independentemente de quem realizou a ação.
:::

## Mostrar

Permissão necessária: `admin.trigger`

Solicitação `GET` enviada: `/api/v1/triggers/{id}`

::: details

```json
// HTTP-Code 200 OK

{
  "id": 4,
  "name": "Notify customer on auto-close",
  "condition": {
    "operator": "AND",
    "conditions": [
      {
        "name": "ticket.state_id",
        "operator": "is",
        "value": [
          4
        ]
      }
    ]
  },
  "perform": {
    "notification.email": {
      "recipient": "ticket_customer",
      "subject": "Your ticket #{ticket.number} has been closed",
      "body": "<div>Your ticket <b>#{ticket.number}</b> has been closed. Thank you for contacting us.</div>"
    }
  },
  "disable_notification": false,
  "localization": null,
  "timezone": null,
  "note": "Sends a confirmation email when a ticket is closed.",
  "activator": "action",
  "execution_condition_mode": "selective",
  "active": true,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:31:52.822Z",
  "updated_at": "2026-09-24T12:31:52.822Z"
}

```

:::

## Criar

Permissão necessária: `admin.trigger`

Solicitação `POST` enviada: `/api/v1/triggers`

`condition` aceita dois formatos: um objeto plano indexado pelo nome do
campo (como mostrado no exemplo de List acima, igual aos gatilhos padrão do
Zammad) e a forma explícita `{"operator": "AND", "conditions": [...]}` usada
abaixo.

No exemplo abaixo, fechar um ticket faz o cliente do ticket receber um email
de confirmação, porque `recipient: "ticket_customer"` sempre aponta para o
cliente, independentemente de quem realizou o fechamento.

:::: details

::: tabs key:reqres

\=== Request

```json
{
  "name": "Notify customer on auto-close",
  "condition": {
    "operator": "AND",
    "conditions": [
      {
        "name": "ticket.state_id",
        "operator": "is",
        "value": [
          4
        ]
      }
    ]
  },
  "perform": {
    "notification.email": {
      "recipient": "ticket_customer",
      "subject": "Your ticket #{ticket.number} has been closed",
      "body": "<div>Your ticket <b>#{ticket.number}</b> has been closed. Thank you for contacting us.</div>"
    }
  },
  "disable_notification": false,
  "activator": "action",
  "execution_condition_mode": "selective",
  "active": true,
  "note": "Sends a confirmation email when a ticket is closed."
}

```

\=== Response

```json
// HTTP-Code 201 Created

{
  "id": 4,
  "name": "Notify customer on auto-close",
  "condition": {
    "operator": "AND",
    "conditions": [
      {
        "name": "ticket.state_id",
        "operator": "is",
        "value": [
          4
        ]
      }
    ]
  },
  "perform": {
    "notification.email": {
      "recipient": "ticket_customer",
      "subject": "Your ticket #{ticket.number} has been closed",
      "body": "<div>Your ticket <b>#{ticket.number}</b> has been closed. Thank you for contacting us.</div>"
    }
  },
  "disable_notification": false,
  "localization": null,
  "timezone": null,
  "note": "Sends a confirmation email when a ticket is closed.",
  "activator": "action",
  "execution_condition_mode": "selective",
  "active": true,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:31:52.822Z",
  "updated_at": "2026-09-24T12:31:52.822Z"
}

```

:::

::::

## Atualização

Permissão necessária: `admin.trigger`

Solicitação `PUT` enviada: `/api/v1/triggers/{id}`

O formato do payload é idêntico ao de Create. A resposta é o registro
atualizado, no mesmo formato de Show/Create, com `updated_at` atualizado.

::: tip
Um payload parcial também funciona, por exemplo `{"active": false}` para alternar apenas
esse campo. Para atualizar um gatilho pelo nome, consulte primeiro o `id` dele via
`GET /api/v1/triggers` e depois envie a solicitação `PUT` para
`/api/v1/triggers/{id}`.
:::

:::: details

::: tabs key:reqres

\=== Request

```json
{
  "name": "Notify customer on auto-close",
  "condition": {
    "operator": "AND",
    "conditions": [
      {
        "name": "ticket.state_id",
        "operator": "is",
        "value": [
          4
        ]
      }
    ]
  },
  "perform": {
    "notification.email": {
      "recipient": "ticket_customer",
      "subject": "Your ticket #{ticket.number} has been closed",
      "body": "<div>Your ticket <b>#{ticket.number}</b> has been closed. Thank you for contacting us.</div>"
    }
  },
  "disable_notification": false,
  "activator": "action",
  "execution_condition_mode": "selective",
  "active": true,
  "note": "Sends a confirmation email when a ticket is closed.",
  "id": 4
}

```

\=== Response

```json
// HTTP-Code 200 OK

{
  "id": 4,
  "name": "Notify customer on auto-close",
  "condition": {
    "operator": "AND",
    "conditions": [
      {
        "name": "ticket.state_id",
        "operator": "is",
        "value": [
          4
        ]
      }
    ]
  },
  "perform": {
    "notification.email": {
      "recipient": "ticket_customer",
      "subject": "Your ticket #{ticket.number} has been closed",
      "body": "<div>Your ticket <b>#{ticket.number}</b> has been closed. Thank you for contacting us.</div>"
    }
  },
  "disable_notification": false,
  "localization": null,
  "timezone": null,
  "note": "Sends a confirmation email when a ticket is closed.",
  "activator": "action",
  "execution_condition_mode": "selective",
  "active": true,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:31:52.822Z",
  "updated_at": "2026-09-24T12:32:20.104Z"
}

```

:::

::::

## Excluir

Permissão necessária: `admin.trigger`

::: danger
**Esta é uma remoção permanente**

Observe que remover gatilhos não pode ser desfeito.
:::

Solicitação `DELETE` enviada: `/api/v1/triggers/{id}`

::: details

```json
// HTTP-Code 200 OK

{}

```

:::
