# cadences.update

Editar cadência de follow-up. Altera a cadência. Só o que for enviado muda; `phases` substitui todos os passos. Execuções em andamento seguem pelo número do passo (passo removido conta como fim da lista). `stageId`, `businessHoursCalendarId`, `dailyLimitPerAttendant` e `description` aceitam null para limpar. Mesmas regras de `cadences.create`.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/cadences.update` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `crm:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `cadences_update`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `cadences.update`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `id` | string (uuid) | sim |  |
| `name` | string | não |  |
| `description` | string \| null | não |  |
| `isActive` | boolean | não |  |
| `stageId` | string (uuid) \| null | não |  |
| `businessHoursCalendarId` | string (uuid) \| null | não |  |
| `dailyLimitPerAttendant` | integer \| null | não |  |
| `phases` | object[] | não |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "description": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    },
    "isActive": {
      "type": "boolean"
    },
    "stageId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        {
          "type": "null"
        }
      ]
    },
    "businessHoursCalendarId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        {
          "type": "null"
        }
      ]
    },
    "dailyLimitPerAttendant": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 500
        },
        {
          "type": "null"
        }
      ]
    },
    "phases": {
      "minItems": 1,
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 80
              },
              {
                "type": "null"
              }
            ]
          },
          "steps": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "call",
                    "whatsapp",
                    "meeting",
                    "task"
                  ]
                },
                "priority": {
                  "default": "none",
                  "type": "string",
                  "enum": [
                    "none",
                    "urgent",
                    "high",
                    "medium",
                    "low"
                  ]
                },
                "waitMinutes": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 129600
                },
                "durationMinutes": {
                  "anyOf": [
                    {
                      "type": "integer",
                      "minimum": 5,
                      "maximum": 1440
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "title": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "description": {
                  "anyOf": [
                    {
                      "type": "string",
                      "maxLength": 2000
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "type",
                "waitMinutes",
                "title"
              ]
            }
          }
        },
        "required": [
          "steps"
        ]
      }
    }
  },
  "required": [
    "id"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/cadences.update \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"00000000-0000-0000-0000-000000000000","name":"Reativação","isActive":true}'
```

CLI:

```bash
node cli/atomiks.mjs cadences.update --json '{"id":"00000000-0000-0000-0000-000000000000","name":"Reativação","isActive":true}'
```

MCP: ferramenta `cadences_update` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "isActive": {
      "type": "boolean"
    },
    "stageId": {
      "type": [
        "string",
        "null"
      ]
    },
    "stageName": {
      "type": [
        "string",
        "null"
      ]
    },
    "businessHoursCalendarId": {
      "type": [
        "string",
        "null"
      ]
    },
    "dailyLimitPerAttendant": {
      "type": [
        "number",
        "null"
      ]
    },
    "phaseNames": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "position": {
            "type": "number"
          },
          "phase": {
            "type": "number"
          },
          "type": {
            "type": "string",
            "enum": [
              "call",
              "whatsapp",
              "meeting",
              "task"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "none",
              "urgent",
              "high",
              "medium",
              "low"
            ]
          },
          "waitMinutes": {
            "type": "number"
          },
          "durationMinutes": {
            "type": [
              "number",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "position",
          "phase",
          "type",
          "priority",
          "waitMinutes",
          "durationMinutes",
          "title",
          "description"
        ],
        "additionalProperties": false
      }
    },
    "liveRuns": {
      "type": "number"
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "description",
    "isActive",
    "stageId",
    "stageName",
    "businessHoursCalendarId",
    "dailyLimitPerAttendant",
    "phaseNames",
    "steps",
    "liveRuns",
    "createdAt",
    "updatedAt"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
