# crm.indicators_update

Ajustar Temperatura e Score. Admin. `temperature` substitui os ajustes sobre o modelo (`{}` restaura tudo ao padrão): `modelId` (modelo pronto base), `customModelId` (modelo próprio ativo, de `crm.temperature_model_create`; os blocos dele vão junto nos ajustes), `thresholds {morno, quente}` (Morno ao menos 5 abaixo de Quente), `channels` (0 a 100), `windowDays` (7, 14, 21, 30 ou 60), `halflives {R, F}` (1 a 30 dias) e `eventWeights` (−100 a 100 por evento do catálogo). `score` troca `maxScore`, `thresholdMedium`, `thresholdHigh` e `rules` (cada regra: `name`, `description`, `points` de −1000 a 1000, `enabled` e `filters`, o filtro de segmento de `contacts.list`; ao menos uma condição e sem filtrar pelo próprio Score). Ao salvar, a conta inteira é recalculada pelo worker em alguns minutos.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `temperature` | object | não |  |
| `score` | object | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "temperature": {
      "type": "object",
      "properties": {
        "modelId": {
          "type": "string",
          "enum": [
            "lancamento",
            "perpetuo",
            "highticket",
            "afiliado",
            "lowticket",
            "ecommerce"
          ]
        },
        "customModelId": {
          "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)$"
        },
        "thresholds": {
          "type": "object",
          "properties": {
            "morno": {
              "type": "integer",
              "minimum": 1,
              "maximum": 95
            },
            "quente": {
              "type": "integer",
              "minimum": 6,
              "maximum": 100
            }
          },
          "required": [
            "morno",
            "quente"
          ]
        },
        "channels": {
          "type": "object",
          "properties": {
            "email": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "msg": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "page": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "pay": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "crm": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "required": [
            "email",
            "msg",
            "page",
            "pay",
            "crm"
          ]
        },
        "windowDays": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "halflives": {
          "type": "object",
          "properties": {
            "R": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30
            },
            "F": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30
            }
          },
          "required": [
            "R",
            "F"
          ]
        },
        "eventWeights": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "integer",
            "minimum": -100,
            "maximum": 100
          }
        }
      },
      "additionalProperties": false
    },
    "score": {
      "type": "object",
      "properties": {
        "maxScore": {
          "default": 100,
          "type": "integer",
          "minimum": 10,
          "maximum": 1000
        },
        "thresholdMedium": {
          "default": 30,
          "type": "integer",
          "minimum": 1,
          "maximum": 999
        },
        "thresholdHigh": {
          "default": 60,
          "type": "integer",
          "minimum": 2,
          "maximum": 1000
        },
        "rules": {
          "default": [],
          "maxItems": 100,
          "type": "array",
          "items": {
            "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": 80
              },
              "description": {
                "type": "string",
                "maxLength": 300
              },
              "points": {
                "type": "integer",
                "minimum": -1000,
                "maximum": 1000
              },
              "enabled": {
                "type": "boolean"
              },
              "filters": {
                "maxItems": 200,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "maxLength": 64
                    },
                    "order": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    },
                    "field": {
                      "type": "string",
                      "maxLength": 60
                    },
                    "operator": {
                      "type": "string",
                      "maxLength": 30
                    },
                    "negation": {
                      "default": false,
                      "type": "boolean"
                    },
                    "parentId": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 64
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueString": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 4000
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueNumber": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "valueDate": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 40
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueBool": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "valueUuid": {
                      "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"
                        }
                      ]
                    }
                  },
                  "required": [
                    "field",
                    "operator"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "name",
              "points",
              "enabled",
              "filters"
            ]
          }
        }
      }
    }
  }
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.indicators_update \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"temperature":{"thresholds":{"morno":30,"quente":60}}}'
```

CLI:

```bash
node cli/atomiks.mjs crm.indicators_update --json '{"temperature":{"thresholds":{"morno":30,"quente":60}}}'
```

MCP: ferramenta `crm_indicators_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": {
    "temperature": {
      "type": "object",
      "properties": {
        "modelId": {
          "type": "string"
        },
        "modelName": {
          "type": "string"
        },
        "dimensions": {
          "type": "object",
          "properties": {
            "R": {
              "type": "number"
            },
            "F": {
              "type": "number"
            },
            "P": {
              "type": "number"
            },
            "D": {
              "type": "number"
            }
          },
          "required": [
            "R",
            "F",
            "P",
            "D"
          ],
          "additionalProperties": false
        },
        "thresholds": {
          "type": "object",
          "properties": {
            "morno": {
              "type": "number"
            },
            "quente": {
              "type": "number"
            }
          },
          "required": [
            "morno",
            "quente"
          ],
          "additionalProperties": false
        },
        "channels": {
          "type": "object",
          "properties": {
            "email": {
              "type": "number"
            },
            "msg": {
              "type": "number"
            },
            "page": {
              "type": "number"
            },
            "pay": {
              "type": "number"
            },
            "crm": {
              "type": "number"
            }
          },
          "required": [
            "email",
            "msg",
            "page",
            "pay",
            "crm"
          ],
          "additionalProperties": false
        },
        "windowDays": {
          "type": "number"
        },
        "halflives": {
          "type": "object",
          "properties": {
            "R": {
              "type": "number"
            },
            "F": {
              "type": "number"
            }
          },
          "required": [
            "R",
            "F"
          ],
          "additionalProperties": false
        },
        "eventWeights": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "number"
          }
        }
      },
      "required": [
        "modelId",
        "modelName",
        "dimensions",
        "thresholds",
        "channels",
        "windowDays",
        "halflives",
        "eventWeights"
      ],
      "additionalProperties": false
    },
    "catalog": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "eventName": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "dimension": {
            "type": "string",
            "enum": [
              "R",
              "F",
              "P",
              "D"
            ]
          },
          "channel": {
            "type": "string",
            "enum": [
              "email",
              "msg",
              "page",
              "pay",
              "crm"
            ]
          },
          "baseWeight": {
            "type": "number"
          },
          "weight": {
            "type": "number"
          },
          "teamAction": {
            "type": "boolean"
          },
          "effectiveFrom": {
            "type": [
              "string",
              "null"
            ]
          },
          "available": {
            "type": "boolean"
          }
        },
        "required": [
          "eventName",
          "label",
          "dimension",
          "channel",
          "baseWeight",
          "weight",
          "teamAction",
          "effectiveFrom",
          "available"
        ],
        "additionalProperties": false
      }
    },
    "activeModelId": {
      "type": "string"
    },
    "models": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "shortName": {
            "type": "string"
          },
          "tagline": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "windowDays": {
            "type": "number"
          },
          "halflifeR": {
            "type": "number"
          },
          "halflifeF": {
            "type": "number"
          },
          "thresholds": {
            "type": "object",
            "properties": {
              "morno": {
                "type": "number"
              },
              "quente": {
                "type": "number"
              }
            },
            "required": [
              "morno",
              "quente"
            ],
            "additionalProperties": false
          },
          "channels": {
            "type": "object",
            "properties": {
              "email": {
                "type": "number"
              },
              "msg": {
                "type": "number"
              },
              "page": {
                "type": "number"
              },
              "pay": {
                "type": "number"
              },
              "crm": {
                "type": "number"
              }
            },
            "required": [
              "email",
              "msg",
              "page",
              "pay",
              "crm"
            ],
            "additionalProperties": false
          },
          "dimensions": {
            "type": "object",
            "properties": {
              "R": {
                "type": "number"
              },
              "F": {
                "type": "number"
              },
              "P": {
                "type": "number"
              },
              "D": {
                "type": "number"
              }
            },
            "required": [
              "R",
              "F",
              "P",
              "D"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "name",
          "shortName",
          "tagline",
          "description",
          "icon",
          "windowDays",
          "halflifeR",
          "halflifeF",
          "thresholds",
          "channels",
          "dimensions"
        ],
        "additionalProperties": false
      }
    },
    "customModels": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "basedOn": {
            "type": "string",
            "enum": [
              "lancamento",
              "perpetuo",
              "highticket",
              "afiliado",
              "lowticket",
              "ecommerce"
            ]
          },
          "thresholds": {
            "type": "object",
            "properties": {
              "morno": {
                "type": "integer",
                "minimum": 1,
                "maximum": 95
              },
              "quente": {
                "type": "integer",
                "minimum": 6,
                "maximum": 100
              }
            },
            "required": [
              "morno",
              "quente"
            ],
            "additionalProperties": false
          },
          "channels": {
            "type": "object",
            "properties": {
              "email": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "msg": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "page": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "pay": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "crm": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              }
            },
            "required": [
              "email",
              "msg",
              "page",
              "pay",
              "crm"
            ],
            "additionalProperties": false
          },
          "windowDays": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "halflives": {
            "type": "object",
            "properties": {
              "R": {
                "type": "integer",
                "minimum": 1,
                "maximum": 30
              },
              "F": {
                "type": "integer",
                "minimum": 1,
                "maximum": 30
              }
            },
            "required": [
              "R",
              "F"
            ],
            "additionalProperties": false
          },
          "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)$"
          }
        },
        "required": [
          "name",
          "basedOn",
          "thresholds",
          "channels",
          "windowDays",
          "halflives",
          "id"
        ],
        "additionalProperties": false
      }
    },
    "limits": {
      "type": "object",
      "properties": {
        "windowOptions": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "halflifeMin": {
          "type": "number"
        },
        "halflifeMax": {
          "type": "number"
        }
      },
      "required": [
        "windowOptions",
        "halflifeMin",
        "halflifeMax"
      ],
      "additionalProperties": false
    },
    "score": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "maxScore": {
          "type": "number"
        },
        "thresholdMedium": {
          "type": "number"
        },
        "thresholdHigh": {
          "type": "number"
        },
        "rules": {
          "type": "array",
          "items": {
            "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": 80
              },
              "description": {
                "type": "string",
                "maxLength": 300
              },
              "points": {
                "type": "integer",
                "minimum": -1000,
                "maximum": 1000
              },
              "enabled": {
                "type": "boolean"
              },
              "filters": {
                "maxItems": 200,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "maxLength": 64
                    },
                    "order": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    },
                    "field": {
                      "type": "string",
                      "maxLength": 60
                    },
                    "operator": {
                      "type": "string",
                      "maxLength": 30
                    },
                    "negation": {
                      "default": false,
                      "type": "boolean"
                    },
                    "parentId": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 64
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueString": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 4000
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueNumber": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "valueDate": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 40
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valueBool": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "valueUuid": {
                      "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"
                        }
                      ]
                    }
                  },
                  "required": [
                    "field",
                    "operator",
                    "negation"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "name",
              "points",
              "enabled",
              "filters"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "enabled",
        "maxScore",
        "thresholdMedium",
        "thresholdHigh",
        "rules"
      ],
      "additionalProperties": false
    },
    "updatedAt": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "temperature",
    "catalog",
    "activeModelId",
    "models",
    "customModels",
    "limits",
    "score",
    "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).
