# companies.list

Listar empresas. Empresas da conta (20 por página). `q` busca na razão social, no nome fantasia e no CNPJ; filtros `states` (UF), `cities`, `sizeTiers` (`SMB`, `MID`, `ENTERPRISE`) e `sectors`; `sort`: `name_asc` (padrão), `name_desc`, `created_desc`, `employees_desc`, `revenue_desc` (os dois últimos dependem do Econodata e ordenam por nome). Os filtros do Econodata (`cnaes`, `sizes`, `statuses`, `empMin`, `empMax`, `revMin`, `revMax`, `debt`, `enriched`) não têm dado no Atomiks: com qualquer um a lista vem vazia. `metrics` conta a conta inteira, sem os filtros; `enriched` é sempre 0.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `q` | string | não |  |
| `sort` | "name_asc" \| "name_desc" \| "created_desc" \| "employees_desc" \| "revenue_desc" | não |  |
| `states` | string[] | não |  |
| `cities` | string[] | não |  |
| `sizeTiers` | "SMB" \| "MID" \| "ENTERPRISE"[] | não |  |
| `sectors` | string[] | não |  |
| `cnaes` | string[] | não |  |
| `sizes` | string[] | não |  |
| `statuses` | string[] | não |  |
| `empMin` | number | não |  |
| `empMax` | number | não |  |
| `revMin` | number | não |  |
| `revMax` | number | não |  |
| `debt` | boolean | não |  |
| `enriched` | 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": {
    "q": {
      "type": "string",
      "maxLength": 255
    },
    "sort": {
      "type": "string",
      "enum": [
        "name_asc",
        "name_desc",
        "created_desc",
        "employees_desc",
        "revenue_desc"
      ]
    },
    "states": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 2
      }
    },
    "cities": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 100
      }
    },
    "sizeTiers": {
      "maxItems": 3,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "SMB",
          "MID",
          "ENTERPRISE"
        ]
      }
    },
    "sectors": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 100
      }
    },
    "cnaes": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 20
      }
    },
    "sizes": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 40
      }
    },
    "statuses": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 40
      }
    },
    "empMin": {
      "type": "number",
      "minimum": 0
    },
    "empMax": {
      "type": "number",
      "minimum": 0
    },
    "revMin": {
      "type": "number",
      "minimum": 0
    },
    "revMax": {
      "type": "number",
      "minimum": 0
    },
    "debt": {
      "type": "boolean"
    },
    "enriched": {
      "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/companies.list \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"page":1,"sort":"name_asc"}'
```

CLI:

```bash
node cli/atomiks.mjs companies.list --json '{"page":1,"sort":"name_asc"}'
```

MCP: ferramenta `companies_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"
          },
          "legalName": {
            "type": "string"
          },
          "tradeName": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxId": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxIdType": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "addressStreet": {
            "type": [
              "string",
              "null"
            ]
          },
          "addressCity": {
            "type": [
              "string",
              "null"
            ]
          },
          "addressState": {
            "type": [
              "string",
              "null"
            ]
          },
          "addressPostalCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "countryCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "industry": {
            "type": [
              "string",
              "null"
            ]
          },
          "sizeTier": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "SMB",
                  "MID",
                  "ENTERPRISE"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "enrichment": {
            "type": "null"
          }
        },
        "required": [
          "id",
          "legalName",
          "tradeName",
          "taxId",
          "taxIdType",
          "email",
          "phone",
          "website",
          "addressStreet",
          "addressCity",
          "addressState",
          "addressPostalCode",
          "countryCode",
          "industry",
          "sizeTier",
          "createdAt",
          "updatedAt",
          "enrichment"
        ],
        "additionalProperties": false
      }
    },
    "total": {
      "type": "number"
    },
    "metrics": {
      "type": "object",
      "properties": {
        "total": {
          "type": "number"
        },
        "smb": {
          "type": "number"
        },
        "mid": {
          "type": "number"
        },
        "enterprise": {
          "type": "number"
        },
        "enriched": {
          "type": "number"
        }
      },
      "required": [
        "total",
        "smb",
        "mid",
        "enterprise",
        "enriched"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "items",
    "total",
    "metrics"
  ],
  "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).
