# ai_agents.update

Editar agente de IA. Altera o agente. Só o que for enviado muda; `null` limpa objetivo e rosto. Nome, objetivo e rosto valem na hora; chave (`credentialId`, que também troca o provedor), modelo, temperatura, persona, ferramentas e regras só entram em uso depois de `ai_agents.publish` (`dirty` fica `true` até lá).

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `id` | string (uuid) | sim |  |
| `name` | string | não |  |
| `credentialId` | string (uuid) | não |  |
| `purpose` | string \| null | não |  |
| `avatarPreset` | "pedro" \| "ana" \| "fernando" \| "clara" \| "mateus" \| "beatriz" \| "rodrigo" \| "samuel" \| "laura" \| "felipe" \| "alice" \| "joao" \| "henrique" \| "isabela" \| "daniel" \| "yasmin" \| "otavio" \| "manuela" \| "eduardo" \| "lara" \| "gabriel" \| "valentina" \| "cecilia" \| "leo" \| "amanda" \| "theo" \| "leila" \| "murilo" \| "lorena" \| "enzo" \| "priscila" \| "ricardo" \| null | não |  |
| `avatarUrl` | string \| null | não |  |
| `modelId` | string | não |  |
| `temperature` | number | não |  |
| `persona` | string | não |  |
| `tools` | "consultar_agenda" \| "agendar_reuniao" \| "registrar_qualificacao" \| "registrar_oportunidade" \| "criar_tarefa" \| "registrar_nota" \| "criar_campo" \| "aplicar_tag" \| "escalar_para_humano" \| "encerrar_conversa"[] | não |  |
| `escalation` | object[] | não |  |
| `primaryRole` | "sdr_inbound" \| "sdr_outbound" \| "support" | 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
    },
    "credentialId": {
      "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)$"
    },
    "purpose": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 300
        },
        {
          "type": "null"
        }
      ]
    },
    "avatarPreset": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "pedro",
            "ana",
            "fernando",
            "clara",
            "mateus",
            "beatriz",
            "rodrigo",
            "samuel",
            "laura",
            "felipe",
            "alice",
            "joao",
            "henrique",
            "isabela",
            "daniel",
            "yasmin",
            "otavio",
            "manuela",
            "eduardo",
            "lara",
            "gabriel",
            "valentina",
            "cecilia",
            "leo",
            "amanda",
            "theo",
            "leila",
            "murilo",
            "lorena",
            "enzo",
            "priscila",
            "ricardo"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "avatarUrl": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    },
    "modelId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "temperature": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "persona": {
      "type": "string",
      "maxLength": 12000
    },
    "tools": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "consultar_agenda",
          "agendar_reuniao",
          "registrar_qualificacao",
          "registrar_oportunidade",
          "criar_tarefa",
          "registrar_nota",
          "criar_campo",
          "aplicar_tag",
          "escalar_para_humano",
          "encerrar_conversa"
        ]
      }
    },
    "escalation": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "trigger": {
            "type": "string",
            "maxLength": 300
          },
          "action": {
            "type": "string",
            "maxLength": 300
          },
          "enabled": {
            "default": true,
            "type": "boolean"
          }
        },
        "required": [
          "trigger",
          "action"
        ]
      }
    },
    "primaryRole": {
      "type": "string",
      "enum": [
        "sdr_inbound",
        "sdr_outbound",
        "support"
      ]
    }
  },
  "required": [
    "id"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/ai_agents.update \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"00000000-0000-0000-0000-000000000000","temperature":0.2}'
```

CLI:

```bash
node cli/atomiks.mjs ai_agents.update --json '{"id":"00000000-0000-0000-0000-000000000000","temperature":0.2}'
```

MCP: ferramenta `ai_agents_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"
    },
    "ownerId": {
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "type": "string"
    },
    "purpose": {
      "type": [
        "string",
        "null"
      ]
    },
    "avatarPreset": {
      "type": [
        "string",
        "null"
      ]
    },
    "avatarUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "active",
        "paused"
      ]
    },
    "provider": {
      "type": "string",
      "enum": [
        "openai",
        "anthropic"
      ]
    },
    "credentialId": {
      "type": "string"
    },
    "modelId": {
      "type": "string"
    },
    "temperature": {
      "type": "number"
    },
    "persona": {
      "type": "string"
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "escalation": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "trigger": {
            "type": "string",
            "maxLength": 300
          },
          "action": {
            "type": "string",
            "maxLength": 300
          },
          "enabled": {
            "default": true,
            "type": "boolean"
          }
        },
        "required": [
          "trigger",
          "action",
          "enabled"
        ],
        "additionalProperties": false
      }
    },
    "knowledgeStoreId": {
      "type": [
        "string",
        "null"
      ]
    },
    "primaryRole": {
      "type": "string",
      "enum": [
        "sdr_inbound",
        "sdr_outbound",
        "support"
      ]
    },
    "version": {
      "type": "number"
    },
    "publishedAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "dirty": {
      "type": "boolean"
    },
    "conversationsCount": {
      "type": "number"
    },
    "resolvedCount": {
      "type": "number"
    },
    "scheduledCount": {
      "type": "number"
    },
    "escalatedCount": {
      "type": "number"
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "ownerId",
    "name",
    "purpose",
    "avatarPreset",
    "avatarUrl",
    "status",
    "provider",
    "credentialId",
    "modelId",
    "temperature",
    "persona",
    "tools",
    "escalation",
    "knowledgeStoreId",
    "primaryRole",
    "version",
    "publishedAt",
    "dirty",
    "conversationsCount",
    "resolvedCount",
    "scheduledCount",
    "escalatedCount",
    "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).
