# crm.temperature_model_create

Salvar um modelo de Temperatura próprio. Admin. Guarda como modelo próprio (até 10 por conta) os blocos ajustados sobre um modelo pronto: `basedOn`, `thresholds`, `channels`, `windowDays` e `halflives`. Não ativa o modelo: para usá-lo, `crm.indicators_update` com `temperature.customModelId` e os mesmos blocos. Depende de uma migration; sem ela responde migration_pendente.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `name` | string | sim |  |
| `basedOn` | "lancamento" \| "perpetuo" \| "highticket" \| "afiliado" \| "lowticket" \| "ecommerce" | sim |  |
| `thresholds` | object | sim |  |
| `channels` | object | sim |  |
| `windowDays` | integer | sim |  |
| `halflives` | object | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "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"
      ]
    },
    "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"
      ]
    }
  },
  "required": [
    "name",
    "basedOn",
    "thresholds",
    "channels",
    "windowDays",
    "halflives"
  ],
  "additionalProperties": false
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.temperature_model_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Lançamento de infoproduto customizado","basedOn":"lancamento","thresholds":{"morno":30,"quente":60},"channels":{"email":25,"msg":70,"page":50,"pay":100,"crm":70},"windowDays":14,"halflives":{"R":5,"F":7}}'
```

CLI:

```bash
node cli/atomiks.mjs crm.temperature_model_create --json '{"name":"Lançamento de infoproduto customizado","basedOn":"lancamento","thresholds":{"morno":30,"quente":60},"channels":{"email":25,"msg":70,"page":50,"pay":100,"crm":70},"windowDays":14,"halflives":{"R":5,"F":7}}'
```

MCP: ferramenta `crm_temperature_model_create` 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": {
    "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
}
```

## 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).
