# visitors.list

Lista de visitantes. Visitantes das páginas, do mais recente ao mais antigo, com `search` (ID do visitante ou IP), os filtros de projeto, página, funil, canal e contato (`hasLead`) e paginação (`page`, `perPage` até 100). Cada linha traz canal da primeira visita, sessões, última página e funil, dispositivo e o contato vinculado. Sem rastreio no Atomiks, a lista é vazia: `{data: [], meta: {countPages: 0, countItens: 0}}`.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `search` | string | não |  |
| `projectIds` | string[] | não |  |
| `excludeProjectIds` | string[] | não |  |
| `pageIds` | string[] | não |  |
| `excludePageIds` | string[] | não |  |
| `funnelIds` | string[] | não |  |
| `excludeFunnelIds` | string[] | não |  |
| `channels` | "google" \| "facebook" \| "instagram" \| "tiktok" \| "youtube" \| "linkedin" \| "whatsapp" \| "email" \| "referral" \| "direct" \| "other"[] | não |  |
| `excludeChannels` | "google" \| "facebook" \| "instagram" \| "tiktok" \| "youtube" \| "linkedin" \| "whatsapp" \| "email" \| "referral" \| "direct" \| "other"[] | não |  |
| `hasLead` | boolean | não |  |
| `page` | integer | não |  |
| `perPage` | integer | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "search": {
      "type": "string",
      "maxLength": 120
    },
    "projectIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "excludeProjectIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "pageIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "excludePageIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "funnelIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "excludeFunnelIds": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 80
      }
    },
    "channels": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "google",
          "facebook",
          "instagram",
          "tiktok",
          "youtube",
          "linkedin",
          "whatsapp",
          "email",
          "referral",
          "direct",
          "other"
        ]
      }
    },
    "excludeChannels": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "google",
          "facebook",
          "instagram",
          "tiktok",
          "youtube",
          "linkedin",
          "whatsapp",
          "email",
          "referral",
          "direct",
          "other"
        ]
      }
    },
    "hasLead": {
      "type": "boolean"
    },
    "page": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "perPage": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  }
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/visitors.list \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"page":1,"perPage":20}'
```

CLI:

```bash
node cli/atomiks.mjs visitors.list --json '{"page":1,"perPage":20}'
```

MCP: ferramenta `visitors_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": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "channel": {
            "type": "string",
            "enum": [
              "google",
              "facebook",
              "instagram",
              "tiktok",
              "youtube",
              "linkedin",
              "whatsapp",
              "email",
              "referral",
              "direct",
              "other"
            ]
          },
          "sessionCount": {
            "type": "number"
          },
          "firstSeenAt": {
            "type": "string"
          },
          "lastSeenAt": {
            "type": "string"
          },
          "device": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "desktop",
                  "mobile",
                  "tablet",
                  "unknown"
                ]
              },
              "os": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "browser": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          "projectId": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastPage": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "imageUrl": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "id",
                  "name",
                  "imageUrl"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "lastFunnel": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "version": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "projectSlug": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "path": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "id",
                  "name",
                  "version",
                  "projectSlug",
                  "path"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "lead": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "linkedAt": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "email",
                  "linkedAt"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "channel",
          "sessionCount",
          "firstSeenAt",
          "lastSeenAt",
          "device",
          "projectId",
          "lastPage",
          "lastFunnel",
          "lead"
        ],
        "additionalProperties": false
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "countPages": {
          "type": "number"
        },
        "countItens": {
          "type": "number"
        }
      },
      "required": [
        "countPages",
        "countItens"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "data",
    "meta"
  ],
  "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).
