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

# Fluxo de trabalho principal

::: info
Os fluxos de trabalho principais são diferentes dos [gatilhos](/pt_BR/reference/rest-api/trigger):
eles controlam o formulário de criação/edição de ticket enquanto alguém o preenche, por
exemplo restringindo quais valores podem ser selecionados em outro campo. O
formulário envia seus valores atuais ao Zammad, que avalia os fluxos de trabalho
e retorna as alterações de campo resultantes. Diferente dos gatilhos, eles não atuam
em tickets existentes em segundo plano.

Compare com os [perfis de relatório](/pt_BR/reference/rest-api/report-profile), cujo
campo `condition`, diferente do fluxo de trabalho principal, valida que os campos
referenciados realmente existem.
:::

## Listar

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

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

::: details

```json
// HTTP-Code 200 OK

[
  {
    "id": 11,
    "name": "Restrict priority for incidents",
    "object": "Ticket",
    "preferences": {},
    "condition_saved": {},
    "condition_selected": {
      "ticket.type": {
        "operator": "is",
        "value": [
          "Incident"
        ]
      }
    },
    "perform": {
      "ticket.state_id": {
        "operator": "set_fixed_to",
        "set_fixed_to": [
          "new",
          "open"
        ]
      }
    },
    "active": true,
    "stop_after_match": false,
    "changeable": true,
    "priority": 100,
    "updated_by_id": 3,
    "created_by_id": 3,
    "created_at": "2026-09-24T12:32:01.736Z",
    "updated_at": "2026-09-24T12:32:01.736Z"
  }
]

```

:::

::: info
Este endpoint retorna apenas fluxos de trabalho com `changeable: true`. Os fluxos
de trabalho de sistema integrados ao Zammad não são alteráveis e não são incluídos, então
a resposta em uma instância nova é um array vazio. Show, Update e
Delete também operam apenas em fluxos de trabalho alteráveis.
:::

## Mostrar

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

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

::: details

```json
// HTTP-Code 200 OK

{
  "id": 11,
  "name": "Restrict priority for incidents",
  "object": "Ticket",
  "preferences": {},
  "condition_saved": {},
  "condition_selected": {
    "ticket.type": {
      "operator": "is",
      "value": [
        "Incident"
      ]
    }
  },
  "perform": {
    "ticket.state_id": {
      "operator": "set_fixed_to",
      "set_fixed_to": [
        "new",
        "open"
      ]
    }
  },
  "active": true,
  "stop_after_match": false,
  "changeable": true,
  "priority": 100,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:32:01.736Z",
  "updated_at": "2026-09-24T12:32:01.736Z"
}

```

:::

::: details

```json
// HTTP-Code 404 Not Found

{
  "error": "Couldn't find CoreWorkflow with 'id'=\"12\" [WHERE \"core_workflows\".\"changeable\" = $1]",
  "error_human": "Couldn't find CoreWorkflow with 'id'=\"12\" [WHERE \"core_workflows\".\"changeable\" = $1]"
}

```

:::

## Criar

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

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

:::: details

::: tabs key:reqres

\=== Request

```json
{
  "name": "Restrict priority for incidents",
  "object": "Ticket",
  "condition_saved": {},
  "condition_selected": {
    "ticket.type": {
      "operator": "is",
      "value": [
        "Incident"
      ]
    }
  },
  "perform": {
    "ticket.state_id": {
      "operator": "set_fixed_to",
      "set_fixed_to": [
        "new",
        "open"
      ]
    }
  },
  "active": true,
  "stop_after_match": false,
  "changeable": true,
  "priority": 100
}

```

\=== Response

```json
// HTTP-Code 201 Created

{
  "id": 11,
  "name": "Restrict priority for incidents",
  "object": "Ticket",
  "preferences": {},
  "condition_saved": {},
  "condition_selected": {
    "ticket.type": {
      "operator": "is",
      "value": [
        "Incident"
      ]
    }
  },
  "perform": {
    "ticket.state_id": {
      "operator": "set_fixed_to",
      "set_fixed_to": [
        "new",
        "open"
      ]
    }
  },
  "active": true,
  "stop_after_match": false,
  "changeable": true,
  "priority": 100,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:32:01.736Z",
  "updated_at": "2026-09-24T12:32:01.736Z"
}

```

:::

::::

::: info
O fluxo de trabalho principal *não* valida se os campos referenciados em
`condition_selected` ou `perform` existem. Um fluxo de trabalho que referencia um
campo que ainda não existe é salvo sem erro. Ele não tem efeito visível
no formulário do ticket até que o campo referenciado exista.
:::

## Atualização

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

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

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

::: info
Enviar o payload completo de Create para o `id` de um fluxo de trabalho existente atualiza
esse registro no lugar. Não cria uma duplicata.
:::

:::: details

::: tabs key:reqres

\=== Request

```json
{
  "name": "Restrict priority for incidents",
  "object": "Ticket",
  "condition_saved": {},
  "condition_selected": {
    "ticket.type": {
      "operator": "is",
      "value": [
        "Incident"
      ]
    }
  },
  "perform": {
    "ticket.state_id": {
      "operator": "set_fixed_to",
      "set_fixed_to": [
        "new",
        "open"
      ]
    }
  },
  "active": true,
  "stop_after_match": false,
  "changeable": true,
  "priority": 100,
  "id": 11
}

```

\=== Response

```json
// HTTP-Code 200 OK

{
  "id": 11,
  "name": "Restrict priority for incidents",
  "object": "Ticket",
  "preferences": {},
  "condition_saved": {},
  "condition_selected": {
    "ticket.type": {
      "operator": "is",
      "value": [
        "Incident"
      ]
    }
  },
  "perform": {
    "ticket.state_id": {
      "operator": "set_fixed_to",
      "set_fixed_to": [
        "new",
        "open"
      ]
    }
  },
  "active": true,
  "stop_after_match": false,
  "changeable": true,
  "priority": 100,
  "updated_by_id": 3,
  "created_by_id": 3,
  "created_at": "2026-09-24T12:32:01.736Z",
  "updated_at": "2026-09-24T12:32:44.519Z"
}

```

:::

::::

## Excluir

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

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

Observe que remover fluxos de trabalho principais não pode ser desfeito.
:::

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

::: details

```json
// HTTP-Code 200 OK

{}

```

:::
