# contacts.temperature_explain

Explicar a temperatura de um contato. O porquê do número: `stored` é o último cálculo gravado (o que a lista mostra), `live` refaz a conta agora com os mesmos sinais (a temperatura esfria sozinha; a varredura diária regrava o número). `components` traz índice e contribuição de Recência, Frequência, Profundidade e Declaração (a soma das contribuições é o valor). `events` = o que pesou (agrupado por evento, com pontos e se define a Recência); `notDone` = sinais que o Atomiks observa e o contato ainda não fez na janela, com os pontos que dariam. `history` = valor por dia (60 dias) e as mudanças.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/contacts.temperature_explain` (corpo JSON)
- Quem pode chamar: membro da conta
- Escopo da chave: `contacts:read`
- Grava dados: não
- Pela chave de API: sim
- Ferramenta MCP: `contacts_temperature_explain`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `contacts.temperature_explain`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `contactId` | string (uuid) | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contactId": {
      "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": [
    "contactId"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/contacts.temperature_explain \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contactId":"00000000-0000-0000-0000-000000000000"}'
```

CLI:

```bash
node cli/atomiks.mjs contacts.temperature_explain --json '{"contactId":"00000000-0000-0000-0000-000000000000"}'
```

MCP: ferramenta `contacts_temperature_explain` 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": {
    "contactId": {
      "type": "string"
    },
    "isCustomer": {
      "type": "boolean"
    },
    "stored": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "value": {
              "type": "number"
            },
            "band": {
              "type": "string",
              "enum": [
                "cold",
                "warm",
                "hot"
              ]
            },
            "trend7d": {
              "type": [
                "number",
                "null"
              ]
            },
            "computedAt": {
              "type": [
                "string",
                "null"
              ]
            },
            "components": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "R": {
                      "type": "object",
                      "properties": {
                        "index": {
                          "type": "number"
                        },
                        "contribution": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "index",
                        "contribution"
                      ],
                      "additionalProperties": false
                    },
                    "F": {
                      "type": "object",
                      "properties": {
                        "index": {
                          "type": "number"
                        },
                        "contribution": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "index",
                        "contribution"
                      ],
                      "additionalProperties": false
                    },
                    "P": {
                      "type": "object",
                      "properties": {
                        "index": {
                          "type": "number"
                        },
                        "contribution": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "index",
                        "contribution"
                      ],
                      "additionalProperties": false
                    },
                    "D": {
                      "type": "object",
                      "properties": {
                        "index": {
                          "type": "number"
                        },
                        "contribution": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "index",
                        "contribution"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "R",
                    "F",
                    "P",
                    "D"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ]
            },
            "events": {
              "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"
                    ]
                  },
                  "count": {
                    "type": "number"
                  },
                  "weightedPoints": {
                    "type": "number"
                  },
                  "latestAt": {
                    "type": "string"
                  },
                  "drivesRecency": {
                    "type": "boolean"
                  },
                  "teamAction": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "eventName",
                  "label",
                  "dimension",
                  "channel",
                  "count",
                  "weightedPoints",
                  "latestAt",
                  "drivesRecency",
                  "teamAction"
                ],
                "additionalProperties": false
              }
            },
            "eventsTotal": {
              "type": "number"
            },
            "notDone": {
              "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"
                    ]
                  },
                  "potentialPoints": {
                    "type": "number"
                  }
                },
                "required": [
                  "eventName",
                  "label",
                  "dimension",
                  "channel",
                  "potentialPoints"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "value",
            "band",
            "trend7d",
            "computedAt",
            "components",
            "events",
            "eventsTotal",
            "notDone"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "live": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "value": {
              "type": "number"
            },
            "band": {
              "type": "string",
              "enum": [
                "cold",
                "warm",
                "hot"
              ]
            },
            "components": {
              "type": "object",
              "properties": {
                "R": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "contribution": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "index",
                    "contribution"
                  ],
                  "additionalProperties": false
                },
                "F": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "contribution": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "index",
                    "contribution"
                  ],
                  "additionalProperties": false
                },
                "P": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "contribution": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "index",
                    "contribution"
                  ],
                  "additionalProperties": false
                },
                "D": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "contribution": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "index",
                    "contribution"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "R",
                "F",
                "P",
                "D"
              ],
              "additionalProperties": false
            },
            "events": {
              "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"
                    ]
                  },
                  "count": {
                    "type": "number"
                  },
                  "weightedPoints": {
                    "type": "number"
                  },
                  "latestAt": {
                    "type": "string"
                  },
                  "drivesRecency": {
                    "type": "boolean"
                  },
                  "teamAction": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "eventName",
                  "label",
                  "dimension",
                  "channel",
                  "count",
                  "weightedPoints",
                  "latestAt",
                  "drivesRecency",
                  "teamAction"
                ],
                "additionalProperties": false
              }
            },
            "eventsTotal": {
              "type": "number"
            },
            "notDone": {
              "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"
                    ]
                  },
                  "potentialPoints": {
                    "type": "number"
                  }
                },
                "required": [
                  "eventName",
                  "label",
                  "dimension",
                  "channel",
                  "potentialPoints"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "value",
            "band",
            "components",
            "events",
            "eventsTotal",
            "notDone"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "model": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "windowDays": {
          "type": "number"
        },
        "thresholds": {
          "type": "object",
          "properties": {
            "morno": {
              "type": "number"
            },
            "quente": {
              "type": "number"
            }
          },
          "required": [
            "morno",
            "quente"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "name",
        "windowDays",
        "thresholds"
      ],
      "additionalProperties": false
    },
    "history": {
      "type": "object",
      "properties": {
        "points": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "day": {
                "type": "string"
              },
              "value": {
                "type": "number"
              }
            },
            "required": [
              "day",
              "value"
            ],
            "additionalProperties": false
          }
        },
        "changes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "day": {
                "type": "string"
              },
              "from": {
                "type": "number"
              },
              "to": {
                "type": "number"
              },
              "delta": {
                "type": "number"
              }
            },
            "required": [
              "day",
              "from",
              "to",
              "delta"
            ],
            "additionalProperties": false
          }
        },
        "changesTotal": {
          "type": "number"
        }
      },
      "required": [
        "points",
        "changes",
        "changesTotal"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contactId",
    "isCustomer",
    "stored",
    "live",
    "model",
    "history"
  ],
  "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).
