# custom_fields.list

Listar campos customizados de Contatos ou Oportunidades. Todos os campos do escopo (`entityType`: `leads` = Contatos, `opportunities` = Oportunidades), ativos e inativos, em ordem. Cada um traz a chave (`fieldName`), o rótulo (`displayName`), o tipo, as opções, a descrição, `required`, `filterable`, `pinned`, `isActive`, o grupo (`groupName`, nulo = sem grupo), `unique`, o preenchimento (`fillRate` de 0 a 1, `filledCount` de `totalRecords`) e os consumidores reais (`usageCount`, `usageByKind`: segmentos, automações e agendas que citam o campo). Também devolve `totalFields` (ativos), `inactiveFields`, `healthDistribution`, `typeCounts` e `groups` (quantidade de campos ativos e preenchimento médio por grupo).

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `entityType` | "leads" \| "opportunities" | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "entityType": {
      "type": "string",
      "enum": [
        "leads",
        "opportunities"
      ]
    }
  },
  "required": [
    "entityType"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/custom_fields.list \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"entityType":"leads"}'
```

CLI:

```bash
node cli/atomiks.mjs custom_fields.list --json '{"entityType":"leads"}'
```

MCP: ferramenta `custom_fields_list` 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": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "objectId": {
            "type": "string"
          },
          "fieldName": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "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": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "required": {
            "type": "boolean"
          },
          "filterable": {
            "type": "boolean"
          },
          "pinned": {
            "type": "boolean"
          },
          "isActive": {
            "type": "boolean"
          },
          "position": {
            "type": "number"
          },
          "usageCount": {
            "type": "number"
          },
          "usageByKind": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          },
          "fillRate": {
            "type": "number"
          },
          "filledCount": {
            "type": "number"
          },
          "totalRecords": {
            "type": "number"
          },
          "isTitle": {
            "type": "boolean"
          },
          "groupName": {
            "type": [
              "string",
              "null"
            ]
          },
          "unique": {
            "type": "boolean"
          },
          "lastEditedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "objectId",
          "fieldName",
          "displayName",
          "fieldType",
          "options",
          "description",
          "required",
          "filterable",
          "pinned",
          "isActive",
          "position",
          "usageCount",
          "usageByKind",
          "fillRate",
          "filledCount",
          "totalRecords",
          "isTitle",
          "groupName",
          "unique",
          "lastEditedAt",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "totalFields": {
      "type": "number"
    },
    "inactiveFields": {
      "type": "number"
    },
    "healthDistribution": {
      "type": "object",
      "properties": {
        "healthy": {
          "type": "number"
        },
        "attention": {
          "type": "number"
        },
        "critical": {
          "type": "number"
        },
        "unused": {
          "type": "number"
        }
      },
      "required": [
        "healthy",
        "attention",
        "critical",
        "unused"
      ],
      "additionalProperties": false
    },
    "typeCounts": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "number"
      }
    },
    "groups": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "number"
          },
          "avgFillRate": {
            "type": "number"
          }
        },
        "required": [
          "name",
          "count",
          "avgFillRate"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "items",
    "totalFields",
    "inactiveFields",
    "healthDistribution",
    "typeCounts",
    "groups"
  ],
  "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).
