# CNPJ search and lists in the API

> Search companies via the API by CNAE, address, size, tax regime and status, with free text, sorting, paging and lists to restrict or exclude CNPJs.

> **Tip:** Concepts on this page: [How company search matching works](https://cnpja.com/en-us/docs/data/search-matching), [Companies and establishments](https://cnpja.com/en-us/docs/data/company-and-establishment) and [Create and manage lists](https://cnpja.com/en-us/docs/lists/create).

[Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments) finds establishments by their characteristics, such as economic activity, address, company size, tax regime or registration status, instead of by CNPJ number. The response comes in pages of up to 1,000 records, sorted by relevance or by a chosen field, each holding the establishment's registration data and the company data. [Lists](https://cnpja.com/en-us/docs/glossary#lista--list) complement the search: they gather CNPJs your organization already knows, to search only among them or to leave them out. Search and lists always require an [API key](https://cnpja.com/en-us/docs/api/first-request).

## Establishment search

Each record is an [establishment](https://cnpja.com/en-us/docs/glossary#estabelecimento--establishment), and a filter on the company returns every establishment of that company that matches the other filters. Combine it with `type.code.in=HEAD` to get one record per company, as explained in [Each result is an establishment](https://cnpja.com/en-us/docs/data/search-matching#each-result-is-an-establishment).

Search uses cached data only and serves to find establishments without knowing their CNPJ. For a known CNPJ, [Lookup CNPJ](https://cnpja.com/en-us/docs/api/cnpj-lookup) accepts `maxAge` and optional resources. A common flow combines both: the search selects the establishments, and Lookup CNPJ returns the current data of each one or the resources the search does not return, such as state registrations.

## Request

| Operation | Method and path | Purpose |
|---|---|---|
| [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments) | `GET /v2/establishments` | Searches establishments by filters |
| [Create list](https://cnpja.com/en-us/docs/api/reference#tag/lists/POST/v2/lists) | `POST /v2/lists` | Creates a list with a name and CNPJs |
| [Search lists](https://cnpja.com/en-us/docs/api/reference#tag/lists/GET/v2/lists) | `GET /v2/lists` | Searches the organization's lists by name |
| [Lookup list](https://cnpja.com/en-us/docs/api/reference#tag/lists/GET/v2/lists/%7blistId%7d) | `GET /v2/lists/{listId}` | Returns the name, type and number of CNPJs of a list |
| [Update list](https://cnpja.com/en-us/docs/api/reference#tag/lists/PATCH/v2/lists/%7blistId%7d) | `PATCH /v2/lists/{listId}` | Renames the list or adds, removes or replaces CNPJs |
| [Delete list](https://cnpja.com/en-us/docs/api/reference#tag/lists/DELETE/v2/lists/%7blistId%7d) | `DELETE /v2/lists/{listId}` | Deletes the list and its CNPJs |

List operations are described in [Lists](#lists). Search CNPJ accepts the query parameters below, all optional:

| Parameter | Values | Effect |
|---|---|---|
| `limit` | From `1` to `1000`, default `10` | Number of records per page |
| `cursor` | The `nextCursor` of a previous response | Reads the next page; cannot be combined with any other parameter |
| `search` | Free text | Returns records containing every word, in any order |
| `sort` | Described in [Sorting](#sorting), default `relevance` | Field used to order the records |
| `order` | `ASC` or `DESC`, default depends on `sort` | Sort direction, ascending or descending |
| Filters | Described in [Filters](#filters) | Narrow the result; each added filter combines with the others |

This request finds active establishments in SP or RJ, opened in 2020, with `padaria` or `confeitaria` in the legal name or trade name:

```http
GET /v2/establishments?status.code.in=ACTIVE&address.state.in=SP,RJ&incorporationDate.gte=2020-01-01&incorporationDate.lte=2020-12-31&names.some=padaria,confeitaria HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

Search accepts neither `maxAge` nor `expand`. Requests without a key are rejected with `401` `API_KEY_MISSING`, since search is not part of [Public access](https://cnpja.com/en-us/docs/api/public-access).

## Response fields

Response of `GET /v2/establishments?address.state.in=SP&status.code.in=ACTIVE&limit=100`, trimmed to one of the records, with illustrative `total` and `nextCursor` values:

```json
{
  "total": 250,
  "limit": 100,
  "nextCursor": "9ed11ce29dc14f9c78304c1a403e9f85",
  "records": [
    {
      "updatedAt": "2026-01-27T03:00:00.000Z",
      "taxId": "37335118000180",
      "incorporationDate": "2020-06-05",
      "type": { "code": "HEAD", "label": "Matriz" },
      "tradeName": "Cnpja",
      "status": { "code": "ACTIVE", "label": "Ativa" },
      "address": {
        "city": "São Paulo",
        "state": "SP",
        "postalCode": "01452922",
        "municipality": "3550308"
      },
      "primaryActivity": {
        "code": "6311900",
        "label": "Tratamento de dados, provedores de serviços de aplicação e serviços de hospedagem na internet"
      },
      "company": {
        "id": "37335118",
        "legalName": "CNPJA TECNOLOGIA LTDA",
        "size": { "code": "SMALL", "label": "Empresa de Pequeno Porte" },
        "taxRegime": {
          "type": { "code": "PRESUMED_PROFIT", "label": "Lucro Presumido" }
        }
      }
    }
  ]
}
```

The response follows the paged format shared by all searches, described in [Response format](https://cnpja.com/en-us/docs/api/responses):

| Field | Content |
|---|---|
| `total` | Number of records matching the search, across all pages |
| `limit` | Page size applied |
| `nextCursor` | Cursor of the next page, or `null` when there are no more |
| `records` | Records of the page; the last one may hold fewer than `limit` |

Each item of `records` has the fields of [Lookup CNPJ](https://cnpja.com/en-us/docs/api/cnpj-lookup) without optional resources:

| Field | Content |
|---|---|
| `updatedAt` | Last update of the establishment from the Receita Federal |
| `taxId` | CNPJ, with 14 characters and no punctuation |
| `incorporationDate` | Opening date |
| `type` | Head office (`HEAD`) or branch (`BRANCH`) |
| `tradeName` | [Trade name](https://cnpja.com/en-us/docs/glossary#nome-fantasia--trade-name), or `null` |
| `status`, `statusDate` | [Registration status](https://cnpja.com/en-us/docs/glossary#situação-cadastral--registration-status) and its date |
| `statusReason` | Reason for the registration status, present when the establishment is not active |
| `specialStatus`, `specialStatusDate` | [Special status](https://cnpja.com/en-us/docs/glossary#situação-especial--special-status) and its date, present when there is one |
| `address` | Street, number, details, district, municipality, state, CEP (`postalCode`), municipality [IBGE code](https://www.ibge.gov.br/explica/codigos-dos-municipios.php) (`municipality`) and country |
| `phones`, `emails` | Phones in E.164 format and emails, each with its type |
| `primaryActivity`, `secondaryActivities` | Economic activities, with the [CNAE](https://cnpja.com/en-us/docs/glossary#cnae) code and description |
| `company` | Root (`id`), legal name, share capital, [legal nature](https://concla.ibge.gov.br/estrutura/natjur-estrutura/natureza-juridica-2021), size, federative entity when there is one, partners (`partners`) and tax regime (`taxRegime`) without `regularIbsStartDate`, `regularCbsStartDate` and its history |

Records do not carry `stateRegistry`, `suframa` or `address.coordinates`, which are optional resources of Lookup CNPJ. A search with no matches returns `200` with empty `records`, `total` set to `0` and `nextCursor` set to `null`, never `404`.

## Filters

Every filter is optional. Each filter name is a field path followed by an operator, such as `address.state.in`; the dots are part of the name. The table shows each field with the operators it accepts:

| Family | Fields and operators | Example |
|---|---|---|
| Free text | `search` | `search=cnpja faria lima` |
| Names | `names` (legal name or trade name), `company.legalName` and `tradeName`, with `some` and `none` | `names.some=padaria,confeitaria` |
| Dates | `incorporationDate` (opening), `statusDate` (registration status) and `specialStatusDate` (special status), with `gte` and `lte` | `incorporationDate.gte=2020-01-01` |
| Company | `company.shareCapital` (`gte`, `lte`), `company.legalNature.code` (`in`, `nin`) and `company.size.code` (`in`) | `company.size.code.in=MICRO,SMALL` |
| Tax regime | `company.taxRegime.type.code` (`in`); `company.taxRegime.simplesNacionalStartDate`, `company.taxRegime.simeiStartDate`, `company.taxRegime.regularIbsStartDate` and `company.taxRegime.regularCbsStartDate` (`gte`, `lte`) | `company.taxRegime.type.code.in=SIMPLES_NACIONAL_SIMEI` |
| Type and status | `type.code`, `status.code`, `statusReason.code` and `specialStatus.code`, with `in` | `status.code.in=ACTIVE` |
| Address | `address.street`, `address.number`, `address.details`, `address.district`, `address.municipality` and `address.country.code` (`in`, `nin`); `address.state` (`in`); `address.postalCode` (`in`, `gte`, `lte`) | `address.municipality.in=3550308` |
| Phones | `phones` (count, `gte`, `lte`), `phones.type.code` (`some`), `phones.area` (area code) and `phones.number` (`some`, `none`) | `phones.type.code.some=MOBILE` |
| Emails | `emails` (count, `gte`, `lte`), `emails.type.code` (`some`), `emails.address` and `emails.domain` (`some`, `none`) | `emails.domain.none=gmail.com,hotmail.com` |
| Activities | `economicActivities.code` (primary or secondary) and `secondaryActivities.code`, with `some` and `none`; `primaryActivity.code` (`in`, `nin`) | `economicActivities.code.some=6311900` |
| Lists | `lists`, with `some` and `none` | `lists.some=b7736fa2-fb08-4b39-a8ff-26e8a53d36c3` |

Tax regime filters follow the rules in [Tax regime in the API](https://cnpja.com/en-us/docs/api/tax-regime), including the [estimated regime](https://cnpja.com/en-us/docs/data/tax-regime#estimated) of companies without an annual return. The `company.taxRegime.regularIbsStartDate` and `company.taxRegime.regularCbsStartDate` filters select [Simples Nacional hybrid](https://cnpja.com/en-us/docs/glossary#simples-nacional-híbrido--simples-nacional-hybrid) companies by the start of the current IBS or CBS regular regime period, even though records do not return these two fields. The values accepted by each filter are in [Codes and values](#codes-and-values) and in [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments), in the Reference. The app's equivalent filters, with their on-screen names, are in [All filters](https://cnpja.com/en-us/docs/search/filters#reference).

### Operators

| Operator | Meaning | Example |
|---|---|---|
| `in` | Equals any of the values | `address.state.in=SP,RJ` |
| `nin` | Equals none of the values | `company.legalNature.code.nin=2135` |
| `some` | Contains any of the words or values | `names.some=padaria,confeitaria` |
| `none` | Contains none of the words or values | `economicActivities.code.none=4711302,5611201` |
| `gte` | Greater than or equal to the value | `incorporationDate.gte=2020-01-01` |
| `lte` | Less than or equal to the value | `company.shareCapital.lte=100000` |

- **Several values:** with `in` and `some`, a record needs to match only one value; with `nin` and `none`, it is left out if it matches any of them. Send the values comma-separated or by repeating the parameter: `address.state.in=SP,RJ` is the same as `address.state.in=SP&address.state.in=RJ`. A comma always separates values and cannot be part of a term.
- **Combination:** different filters combine with AND, so a record must satisfy all of them.
- **Ranges:** `gte` and `lte` include the value itself, and both on the same field make a closed range. On fields that are lists, they count items: `phones.gte=1` returns records with at least one phone.
- **Value format:** dates as `YYYY-MM-DD`, codes without punctuation (CEP `01452922`, [CNAE](https://concla.ibge.gov.br/busca-online-cnae.html?view=estrutura) `6311900`, IBGE code `3550308`), phones in E.164 format and enums exactly as listed.
- **URL encoding:** encode the `+` of phone numbers as `%2B`, as in `phones.number.some=%2B5511971564144`. Without encoding, the `+` is read as a space and the value is rejected.

An unknown parameter or a value in the wrong format returns `400` `REQUEST_VALIDATION_FAILED`. An unrecognized name produces an item in `errors` with the code `ADDITIONAL_PROPERTIES`, which does not say which name was rejected, so check the spelling of the parameters.

## Text matching

Text filters, that is, `names`, `company.legalName` and `tradeName`, and `search` ignore case and accents and compare whole words by their Portuguese stem, as explained in [Words, accents and punctuation](https://cnpja.com/en-us/docs/data/search-matching#text-matching).

- In `some` and `none`, each word counts on its own, even inside one value: `names.some=pao de queijo` matches any name containing `pao`, `de` or `queijo`.
- `search` returns only records containing every word, in any order, and looks in the CNPJ, the names, the phones, the emails and the address at once, as detailed in [Free text search](https://cnpja.com/en-us/docs/data/search-matching#free-text).
- `address.street`, `address.number`, `address.details` and `address.district` compare the whole value, not separate words, with the same case, accent, punctuation and stem rules. They accept only `in` and `nin`.
- Other filters compare exact values, including `some` and `none` on phones, email domains and economic activities, which compare each whole item.

## Sorting

`sort` chooses the field used to order the records, and `order`, the direction: `ASC` for ascending or `DESC` for descending. Without `order`, each field follows its default direction:

| Value | Orders by | Default direction |
|---|---|---|
| `relevance` (default) | Relevance | Descending, most relevant first |
| `taxId` | CNPJ | Ascending |
| `incorporationDate` | Opening date | Descending, most recent first |
| `company.shareCapital` | Company share capital | Descending, largest first |
| `company.legalName` | Company legal name | Ascending |

This request returns establishments in SP, starting from the most recently opened:

```http
GET /v2/establishments?address.state.in=SP&sort=incorporationDate HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

- **Relevance:** what relevance favors is in [Result order](https://cnpja.com/en-us/docs/data/search-matching#relevance).
- **Ties:** with any `sort`, records with the same value in the chosen field follow ascending `taxId`, so the order is the same on every page.
- **Legal name:** `company.legalName` is compared by character code, without ignoring case or accents, unlike the text filters: uppercase letters come before lowercase ones, and accented letters come after both.

## Pagination

The first request defines the search, with the filters, `sort`, `order` and `limit`. To read the next page, send the response's `nextCursor` as [cursor](https://cnpja.com/en-us/docs/glossary#cursor), with no other parameter, and repeat until `nextCursor` is `null`:

```http
GET /v2/establishments?cursor=9ed11ce29dc14f9c78304c1a403e9f85 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

- **Fixed parameters:** the cursor keeps the filters, `sort`, `order` and `limit` of the first request. To change any of them, start a new search.
- **Validity:** each cursor is valid for 15 minutes from the response that returned it. After that, it returns `400` `PAGE_CURSOR_INVALID`: the API does not resume the read, and the client must send the first request again, with the same parameters, to get a new cursor.
- **Results not frozen:** if data changes during the read, a record can appear on two pages or on none, and a page can come back short or empty before the end, as explained in [Results are not fixed](https://cnpja.com/en-us/docs/data/search-matching#results-are-not-fixed).
- **Page size:** larger pages take fewer requests to go through a result, and [compression](https://cnpja.com/en-us/docs/api/reference#description/compression) greatly reduces their size.

> **Important:** keep going until `nextCursor` is `null`, even after a short or empty page, and drop duplicates by `taxId`.

The format of paged responses is in [Response format](https://cnpja.com/en-us/docs/api/responses).

## Lists

A [list](https://cnpja.com/en-us/docs/glossary#lista--list) is a named set of CNPJs chosen by your organization, as explained in [What a list is](https://cnpja.com/en-us/docs/lists/create#static). Lists belong to the organization: a list created with one key can be used and changed with any other key of the same organization, and in the app as well.

### Creation

[Create list](https://cnpja.com/en-us/docs/api/reference#tag/lists/POST/v2/lists) takes the type, the name and the CNPJs and responds with `201`:

```http
POST /v2/lists HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
Content-Type: application/json
```

```json
{
  "type": "ESTABLISHMENT",
  "name": "Customers",
  "items": ["37335118000180"]
}
```

| Field | Content |
|---|---|
| `type` | Type of the items; always `ESTABLISHMENT`, establishments identified by CNPJ |
| `name` | List name. Names can repeat across lists, so identify each one by its `id` |
| `items` | 14-character CNPJs, with no punctuation, uppercase letters if any and valid check digits. Duplicates are discarded |

The response, in the same format as Lookup list and Update list, carries the list's `id`, used in filters and in the other operations, `type`, `name`, `size`, with the number of distinct CNPJs, and the creation and last update dates in `createdAt` and `updatedAt`.

An invalid item returns `400` `REQUEST_VALIDATION_FAILED`, and `errors` points to its position, such as `items.2` for the third item. To send a large list, [compress](https://cnpja.com/en-us/docs/api/reference#description/compression) the request body; the 50 MB limit, described in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors), applies to the decompressed JSON.

### Use in search

Send the `id` in `lists.some` to search only the list's CNPJs, or in `lists.none` to leave them out. For several lists, separate the ids with commas: with `lists.some`, a record must be in any of them; with `lists.none`, it is left out if it is in any of them.

```http
GET /v2/establishments?lists.some=b7736fa2-fb08-4b39-a8ff-26e8a53d36c3&status.code.in=SUSPENDED,NONCOMPLIANT,CLOSED HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

- Search uses each list's content at the time of each request: CNPJs added with Update list count immediately, including on the next pages of a search already in progress.
- A nonexistent list id raises no error: with `lists.some`, the search returns no records, and with `lists.none`, it leaves nothing out. Check the id with Search lists.
- A CNPJ in the list that is not yet in the search does not appear in the results until it enters cached data and the search index, as explained in [When a new CNPJ appears](https://cnpja.com/en-us/docs/data/search-matching#index-lag).

### Maintenance

In [Update list](https://cnpja.com/en-us/docs/api/reference#tag/lists/PATCH/v2/lists/%7blistId%7d), `operation` and `items` always go together:

| `operation` | Effect |
|---|---|
| `ADD` | Adds the CNPJs and ignores those already in the list |
| `REMOVE` | Removes the CNPJs and ignores those not in it |
| `REPLACE` | Replaces every CNPJ; with an empty `items`, empties the list while keeping its `id` |

To only rename, send just `name`: the CNPJs stay unchanged. While an [export](https://cnpja.com/en-us/docs/lists/export) of the list, made in the app, is queued or running, `operation` is rejected with `409` `LIST_EXPORT_IN_PROGRESS`, but renaming still works. The response carries the updated list, with the new count in `size`. [Delete list](https://cnpja.com/en-us/docs/api/reference#tag/lists/DELETE/v2/lists/%7blistId%7d) removes the list and its CNPJs, with no way to recover them, and responds with `204`.

### List lookup

[Search lists](https://cnpja.com/en-us/docs/api/reference#tag/lists/GET/v2/lists) returns the organization's lists in pages, with the same `limit`, `cursor`, `order` and response format as Search CNPJ. The `search` filter returns the lists whose name contains every word sent, in any order, and does not change the sorting. `sort` accepts `createdAt` (default), `updatedAt`, `name` and `size`: without `order`, `name` is ascending and the others start from the most recent or largest lists. Ties follow ascending `id`. [Lookup list](https://cnpja.com/en-us/docs/api/reference#tag/lists/GET/v2/lists/%7blistId%7d) returns the name, type and number of CNPJs of a list by its `id`.

### List limits

The number of lists per organization and of CNPJs per list have current limits, described in Usage limits, under [Organization](https://cnpja.com/en-us/docs/billing/limits#organization) and [Lists, exports and bulk](https://cnpja.com/en-us/docs/billing/limits#lists). In the API, they apply like this:

- On create, the values in `items` count toward the limit with their duplicates, although duplicates are discarded when stored: remove them before sending. Above the limit, the request is rejected with `400` `REQUEST_VALIDATION_FAILED`.
- In an `ADD`, the list's current size plus the distinct CNPJs sent count, even those already in it. Above the limit, the request is rejected with `422` `LIST_SIZE_EXCEEDED`: send only CNPJs not yet in the list, or remove some first.
- At the organization's list limit, Create list is rejected with `422` `LIST_LIMIT_EXCEEDED`: delete the lists you no longer use.

## Codes and values

| Filter | Accepted values |
|---|---|
| `status.code.in` | `ACTIVE` (active), `CLOSED` (closed), `NONCOMPLIANT` (noncompliant), `SUSPENDED` (suspended) and `VOID` (void) |
| `type.code.in` | `HEAD` (head office) and `BRANCH` (branch) |
| `company.size.code.in` | `MICRO` (micro company), `SMALL` (small company) and `OTHER` (other) |
| `company.taxRegime.type.code.in` | `ACTUAL_PROFIT`, `PRESUMED_PROFIT`, `ARBITRATED_PROFIT`, `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID`, `SIMPLES_NACIONAL_SIMEI` and `NOT_APPLICABLE`, described in [Tax regime in the API](https://cnpja.com/en-us/docs/api/tax-regime) |
| `phones.type.code.some` | `LANDLINE` (landline) and `MOBILE` (mobile) |
| `emails.type.code.some` | `ACADEMIC` (academic), `ACCOUNTING` (accounting), `CORPORATE` (corporate), `CONSUMER` (consumer) and `GOVERNMENT` (government) |
| `address.state.in` | Abbreviation of one of the 27 [states](https://cnpja.com/en-us/docs/glossary#uf), such as `SP` or `DF` |
| `company.legalNature.code` | 4-digit [legal nature](https://cnpja.com/en-us/docs/glossary#natureza-jurídica--legal-nature) code, such as `2062` (limited liability business company) |
| `statusReason.code.in` | 2-digit code of the registration status reason, such as `01` |
| `specialStatus.code.in` | 3-digit special status code, such as `418` (start of judicial reorganization) |
| `address.municipality` | 7-digit municipality [IBGE code](https://cnpja.com/en-us/docs/glossary#código-ibge--ibge-code), such as `3550308` |

In responses, each `code` comes with a readable `label`. Base your logic on `code`: the `label` is for display only and changes with the language, as explained in [Response format](https://cnpja.com/en-us/docs/api/responses).

## Sources and updates

Search reads cached data only: it accepts no `maxAge` and makes no live queries. Where each piece of data comes from is in [Data sources](https://cnpja.com/en-us/docs/data/sources), and how long a new CNPJ or an update takes to reach the filters, in [When a new CNPJ appears](https://cnpja.com/en-us/docs/data/search-matching#index-lag).

- Each record's `updatedAt` shows the establishment's last update from the Receita Federal, and `company.taxRegime.updatedAt`, the regime's last update via Simples Nacional.
- A Simples Nacional optant appears as `SIMPLES_NACIONAL_HYBRID` only after the Simples Nacional is queried live, as in Lookup CNPJ with `expand=company.taxRegime`, and the IBS or CBS regular regime option is found, as explained in [IBS and CBS](https://cnpja.com/en-us/docs/data/tax-regime#ibs-and-cbs).
- For the current data on a CNPJ found, look it up in Lookup CNPJ with a smaller `maxAge`. The rules are in [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age#syntax).

## Billing

Search CNPJ consumes cached queries only, according to the number of records returned on each page, including pages read with `cursor`, and list operations consume no quota today. The consumption of each case, including the minimum per page, is in the metering rules, under [Consumption in the API](https://cnpja.com/en-us/legal/metering#api). Since consumption follows the records, `limit` also caps the consumption of each page.

## Frequent errors

| Status | Code | Cause | Action |
|---|---|---|---|
| `400` | `REQUEST_VALIDATION_FAILED` | Unknown or misspelled filter, value in the wrong format, invalid `sort` or `order` value, `cursor` with another parameter, invalid CNPJ in `items`, or `operation` without `items`, or the reverse, in Update list | Fix what `errors` points to and check the spelling of the filters |
| `400` | `PAGE_CURSOR_INVALID` | Cursor expired, after 15 minutes, or unknown | Start again from the first request, with the same parameters |
| `401` | `API_KEY_MISSING` | Request without an API key | Send the key in the `Authorization` header, as explained in [First request](https://cnpja.com/en-us/docs/api/first-request) |
| `402` | `CACHED_QUERY_QUOTA_EXCEEDED`, `LIVE_QUERY_QUOTA_EXCEEDED` or `OVERAGE_BUDGET_EXCEEDED` | The organization's quota or overage budget is used up. What each code means is in [Error codes](https://cnpja.com/en-us/docs/api/limits-and-errors#error-codes) | Follow one of the ways out in [Quota used up](https://cnpja.com/en-us/docs/billing/quota-exhausted#ways-out) |
| `404` | `LIST_NOT_FOUND` | Lookup, Update or Delete list with an `id` that does not exist or belongs to another organization | Check the `id` with Search lists |
| `409` | `LIST_EXPORT_IN_PROGRESS` | Update list with `operation` while an export of the list is queued or running | Retry once the export finishes. To only rename, send just `name` |
| `422` | `LIST_LIMIT_EXCEEDED` | The organization reached its list limit | Delete the lists you no longer use |
| `422` | `LIST_SIZE_EXCEEDED` | The `ADD` would take the list above the limit of CNPJs per list | Send only new CNPJs or remove some first |

Other errors are in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors).

## Use cases

- **Prospecting:** combine `status.code.in=ACTIVE`, an activity in `economicActivities.code.some` and a municipality in `address.municipality.in`, leave out current customers with `lists.none` and use `sort=company.shareCapital` to start from the highest share capital.
- **Market sizing:** read the `total` of searches with `limit=1`, the lowest consumption per page, changing one filter at a time, such as the state or company size.
- **Customer monitoring:** search with `lists.some` and the customer list, together with `status.code.in=SUSPENDED,NONCOMPLIANT,CLOSED`, to find the customers that are no longer active.
- **Newly opened companies:** search periodically with `incorporationDate.gte` and `sort=incorporationDate`, which starts from the most recent, and leave out with `lists.none` the CNPJs already worked, added to the list with `ADD` on every run.
- **Establishments of a company:** send the CNPJ root in `search` and combine it with filters such as `status.code.in=ACTIVE` or `address.state.in` to get the branches that meet the criteria.
- **Segment export for internal use:** go through every page with `limit=1000` and compression, dropping duplicates by `taxId`. The results can contain personal data, such as the contacts of sole proprietors: their use follows the [Terms of Use](https://cnpja.com/en-us/legal/terms#acceptable-use) and the LGPD, as explained in [Responsible use](https://cnpja.com/en-us/docs/data/contacts#responsible-use).

## In the app

On the platform, the same search is in the **CNPJ** app > **Search CNPJ**, with filters under their on-screen names, free text search and views, as explained in [Search CNPJs](https://cnpja.com/en-us/docs/search/companies). Lists are the same in the app and in the API, as shown in [Create and manage lists](https://cnpja.com/en-us/docs/lists/create).

## Notes

- Search does not filter by state registration or SUFRAMA registration and does not return this data. Look up each CNPJ found as described in [State registrations in the API](https://cnpja.com/en-us/docs/api/state-registrations) and [SUFRAMA in the API](https://cnpja.com/en-us/docs/api/suframa).
- There is no filter by municipality name: use the IBGE code in `address.municipality.in`, which comes in `address.municipality` in responses. The municipality name is only considered in `search`.
- For every establishment of a company without filters, [Lookup company](https://cnpja.com/en-us/docs/api/reference#tag/companies/GET/v2/companies/%7bid%7d) returns a summary of each one, as shown in [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup).
- Every parameter and accepted value is in [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments), and the general rules in [Search filters](https://cnpja.com/en-us/docs/api/reference#description/search-filters), [Sorting](https://cnpja.com/en-us/docs/api/reference#description/sorting) and [Pagination](https://cnpja.com/en-us/docs/api/reference#description/pagination), in the Reference.
