# crm.field_create

Criar campo personalizado. Cria a definição. `key` (a-z, 0-9, _) sai do rótulo se omitida e é única na conta. `options` é obrigatório (e só vale) para `select`. O tipo não muda depois.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/crm.field_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_field_create`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `crm.field_create`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `label` | string | sim |  |
| `type` | "text" \| "number" \| "date" \| "select" \| "boolean" \| "file" | sim |  |
| `key` | string | não |  |
| `options` | string[] | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "label": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "type": {
      "type": "string",
      "enum": [
        "text",
        "number",
        "date",
        "select",
        "boolean",
        "file"
      ]
    },
    "key": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,39}$"
    },
    "options": {
      "minItems": 1,
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80
      }
    }
  },
  "required": [
    "label",
    "type"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.field_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"label":"Cidade","type":"text"}'
```

CLI:

```bash
node cli/atomiks.mjs crm.field_create --json '{"label":"Cidade","type":"text"}'
```

MCP: ferramenta `crm_field_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": {
    "id": {
      "type": "string"
    },
    "key": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "enum": [
        "text",
        "number",
        "date",
        "select",
        "boolean",
        "file"
      ]
    },
    "fieldType": {
      "type": "string",
      "enum": [
        "text",
        "textarea",
        "number",
        "currency",
        "percentage",
        "date",
        "select",
        "multi_select",
        "radio",
        "link",
        "rating",
        "boolean",
        "file",
        "image"
      ]
    },
    "options": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "position": {
      "type": "number"
    },
    "archived": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "key",
    "label",
    "type",
    "fieldType",
    "options",
    "position",
    "archived"
  ],
  "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).
