# custom_fields.records

Quem preencheu um campo customizado. A aba Quem preencheu: os registros (contatos ou oportunidades) que têm valor no campo, do preenchimento mais recente para o mais antigo (`limit` até 100, padrão 50). Cada um traz `entityId`, `name`, `value` em texto, `filledAt` e `source` (manual, import, form, booking, webchat, flow, api, system, unknown; valor sem origem registrada vem como `unknown`).

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `entityType` | "leads" \| "opportunities" | sim |  |
| `id` | string (uuid) | sim |  |
| `limit` | integer | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "entityType": {
      "type": "string",
      "enum": [
        "leads",
        "opportunities"
      ]
    },
    "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)$"
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "required": [
    "entityType",
    "id"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs custom_fields.records --json '{"entityType":"leads","id":"00000000-0000-0000-0000-000000000000"}'
```

MCP: ferramenta `custom_fields_records` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "entityId": {
        "type": "string"
      },
      "entityType": {
        "type": "string",
        "enum": [
          "leads",
          "opportunities"
        ]
      },
      "name": {
        "type": [
          "string",
          "null"
        ]
      },
      "value": {
        "type": "string"
      },
      "filledAt": {
        "type": "string"
      },
      "source": {
        "type": "string",
        "enum": [
          "manual",
          "import",
          "form",
          "booking",
          "webchat",
          "flow",
          "api",
          "system",
          "unknown"
        ]
      }
    },
    "required": [
      "entityId",
      "entityType",
      "name",
      "value",
      "filledAt",
      "source"
    ],
    "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).
