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, Companies and establishments and Create and manage lists.
Search CNPJ 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 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.
Establishment search
Each record is an establishment, and a filter on the company returns every establishment of that company that matches the other filters. Combine it with type. to get one record per company, as explained in 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 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 | GET / | Searches establishments by filters |
| Create list | POST / | Creates a list with a name and CNPJs |
| Search lists | GET / | Searches the organization’s lists by name |
| Lookup list | GET / | Returns the name, type and number of CNPJs of a list |
| Update list | PATCH / | Renames the list or adds, removes or replaces CNPJs |
| Delete list | DELETE / | Deletes the list and its CNPJs |
List operations are described in 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, 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 | 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:
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_, since search is not part of Public access.
Response fields
Response of GET /, trimmed to one of the records, with illustrative total and nextCursor values:
{
"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:
| 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 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, or null |
status, statusDate | Registration status and its date |
statusReason | Reason for the registration status, present when the establishment is not active |
specialStatus, specialStatusDate | Special status and its date, present when there is one |
address | Street, number, details, district, municipality, state, CEP (postalCode), municipality IBGE code (municipality) and country |
phones, emails | Phones in E.164 format and emails, each with its type |
primaryActivity, secondaryActivities | Economic activities, with the CNAE code and description |
company | Root (id), legal name, share capital, legal nature, 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., 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.; 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. and tradeName, with some and none | names. |
| Dates | incorporationDate (opening), statusDate (registration status) and specialStatusDate (special status), with gte and lte | incorporationDate. |
| Company | company. (gte, lte), company. (in, nin) and company. (in) | company. |
| Tax regime | company. (in); company., company., company. and company. (gte, lte) | company. |
| Type and status | type., status., statusReason. and specialStatus., with in | status. |
| Address | address., address., address., address., address. and address. (in, nin); address. (in); address. (in, gte, lte) | address. |
| Phones | phones (count, gte, lte), phones. (some), phones. (area code) and phones. (some, none) | phones. |
| Emails | emails (count, gte, lte), emails. (some), emails. and emails. (some, none) | emails. |
| Activities | economicActivities. (primary or secondary) and secondaryActivities., with some and none; primaryActivity. (in, nin) | economicActivities. |
| Lists | lists, with some and none | lists. |
Tax regime filters follow the rules in Tax regime in the API, including the estimated regime of companies without an annual return. The company. and company. filters select 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 and in Search CNPJ, in the Reference. The app’s equivalent filters, with their on-screen names, are in All filters.
Operators
| Operator | Meaning | Example |
|---|---|---|
in | Equals any of the values | address. |
nin | Equals none of the values | company. |
some | Contains any of the words or values | names. |
none | Contains none of the words or values | economicActivities. |
gte | Greater than or equal to the value | incorporationDate. |
lte | Less than or equal to the value | company. |
- Several values: with
inandsome, a record needs to match only one value; withninandnone, it is left out if it matches any of them. Send the values comma-separated or by repeating the parameter:address.is the same asstate. in=SP,RJ address.. A comma always separates values and cannot be part of a term.state. in=SP&address. state. in=RJ - Combination: different filters combine with AND, so a record must satisfy all of them.
- Ranges:
gteandlteinclude the value itself, and both on the same field make a closed range. On fields that are lists, they count items:phones.returns records with at least one phone.gte=1 - Value format: dates as
YYYY-MM-DD, codes without punctuation (CEP01452922, CNAE6311900, IBGE code3550308), phones in E.164 format and enums exactly as listed. - URL encoding: encode the
+of phone numbers as%2B, as inphones.. Without encoding, thenumber. some=%2B5511971564144 +is read as a space and the value is rejected.
An unknown parameter or a value in the wrong format returns 400 REQUEST_. An unrecognized name produces an item in errors with the code ADDITIONAL_, which does not say which name was rejected, so check the spelling of the parameters.
Text matching
Text filters, that is, names, company. and tradeName, and search ignore case and accents and compare whole words by their Portuguese stem, as explained in Words, accents and punctuation.
- In
someandnone, each word counts on its own, even inside one value:names.matches any name containingsome=pao de queijo pao,deorqueijo. searchreturns 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.address.,street address.,number address.anddetails address.compare the whole value, not separate words, with the same case, accent, punctuation and stem rules. They accept onlydistrict inandnin.- Other filters compare exact values, including
someandnoneon 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. | Company share capital | Descending, largest first |
company. | Company legal name | Ascending |
This request returns establishments in SP, starting from the most recently opened:
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.
- Ties: with any
sort, records with the same value in the chosen field follow ascendingtaxId, so the order is the same on every page. - Legal name:
company.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.legalName
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, with no other parameter, and repeat until nextCursor is null:
GET /v2/establishments?cursor=9ed11ce29dc14f9c78304c1a403e9f85 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY - Fixed parameters: the cursor keeps the filters,
sort,orderandlimitof 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
400PAGE_: 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.CURSOR_ INVALID - 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.
- Page size: larger pages take fewer requests to go through a result, and compression greatly reduces their size.
Important: keep going until
nextCursorisnull, even after a short or empty page, and drop duplicates bytaxId.
The format of paged responses is in Response format.
Lists
A list is a named set of CNPJs chosen by your organization, as explained in What a list is. 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 takes the type, the name and the CNPJs and responds with 201:
POST /v2/lists HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
Content-Type: application/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_, and errors points to its position, such as items. for the third item. To send a large list, compress the request body; the 50 MB limit, described in Limits and errors, applies to the decompressed JSON.
Use in search
Send the id in lists. to search only the list’s CNPJs, or in lists. to leave them out. For several lists, separate the ids with commas: with lists., a record must be in any of them; with lists., it is left out if it is in any of them.
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., the search returns no records, and withsome lists., it leaves nothing out. Check the id with Search lists.none - 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.
Maintenance
In Update list, 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 of the list, made in the app, is queued or running, operation is rejected with 409 LIST_, but renaming still works. The response carries the updated list, with the new count in size. Delete list removes the list and its CNPJs, with no way to recover them, and responds with 204.
List lookup
Search 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 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 and Lists, exports and bulk. In the API, they apply like this:
- On create, the values in
itemscount toward the limit with their duplicates, although duplicates are discarded when stored: remove them before sending. Above the limit, the request is rejected with400REQUEST_.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 with422LIST_: send only CNPJs not yet in the list, or remove some first.SIZE_ EXCEEDED - At the organization’s list limit, Create list is rejected with
422LIST_: delete the lists you no longer use.LIMIT_ EXCEEDED
Codes and values
| Filter | Accepted values |
|---|---|
status. | ACTIVE (active), CLOSED (closed), NONCOMPLIANT (noncompliant), SUSPENDED (suspended) and VOID (void) |
type. | HEAD (head office) and BRANCH (branch) |
company. | MICRO (micro company), SMALL (small company) and OTHER (other) |
company. | ACTUAL_, PRESUMED_, ARBITRATED_, SIMPLES_, SIMPLES_, SIMPLES_ and NOT_, described in Tax regime in the API |
phones. | LANDLINE (landline) and MOBILE (mobile) |
emails. | ACADEMIC (academic), ACCOUNTING (accounting), CORPORATE (corporate), CONSUMER (consumer) and GOVERNMENT (government) |
address. | Abbreviation of one of the 27 states, such as SP or DF |
company. | 4-digit legal nature code, such as 2062 (limited liability business company) |
statusReason. | 2-digit code of the registration status reason, such as 01 |
specialStatus. | 3-digit special status code, such as 418 (start of judicial reorganization) |
address. | 7-digit municipality 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.
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, and how long a new CNPJ or an update takes to reach the filters, in When a new CNPJ appears.
- Each record’s
updatedAtshows the establishment’s last update from the Receita Federal, andcompany., the regime’s last update via Simples Nacional.taxRegime. updatedAt - A Simples Nacional optant appears as
SIMPLES_only after the Simples Nacional is queried live, as in Lookup CNPJ withNACIONAL_ HYBRID expand=company., and the IBS or CBS regular regime option is found, as explained in IBS and CBS.taxRegime - 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.
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. Since consumption follows the records, limit also caps the consumption of each page.
Frequent errors
| Status | Code | Cause | Action |
|---|---|---|---|
400 | REQUEST_ | 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 expired, after 15 minutes, or unknown | Start again from the first request, with the same parameters |
401 | API_ | Request without an API key | Send the key in the Authorization header, as explained in First request |
402 | CACHED_, LIVE_ or OVERAGE_ | The organization’s quota or overage budget is used up. What each code means is in Error codes | Follow one of the ways out in Quota used up |
404 | LIST_ | 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_ | 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_ | The organization reached its list limit | Delete the lists you no longer use |
422 | LIST_ | 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.
Use cases
- Prospecting: combine
status., an activity incode. in=ACTIVE economicActivities.and a municipality incode. some address., leave out current customers withmunicipality. in lists.and usenone sort=company.to start from the highest share capital.shareCapital - Market sizing: read the
totalof searches withlimit=1, the lowest consumption per page, changing one filter at a time, such as the state or company size. - Customer monitoring: search with
lists.and the customer list, together withsome status., to find the customers that are no longer active.code. in=SUSPENDED,NONCOMPLIANT,CLOSED - Newly opened companies: search periodically with
incorporationDate.andgte sort=incorporationDate, which starts from the most recent, and leave out withlists.the CNPJs already worked, added to the list withnone ADDon every run. - Establishments of a company: send the CNPJ root in
searchand combine it with filters such asstatus.orcode. in=ACTIVE address.to get the branches that meet the criteria.state. in - Segment export for internal use: go through every page with
limit=1000and compression, dropping duplicates bytaxId. The results can contain personal data, such as the contacts of sole proprietors: their use follows the Terms of Use and the LGPD, as explained in 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. Lists are the same in the app and in the API, as shown in Create and manage lists.
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 and SUFRAMA in the API.
- There is no filter by municipality name: use the IBGE code in
address., which comes inmunicipality. in address.in responses. The municipality name is only considered inmunicipality search. - For every establishment of a company without filters, Lookup company returns a summary of each one, as shown in CNPJ lookup.
- Every parameter and accepted value is in Search CNPJ, and the general rules in Search filters, Sorting and Pagination, in the Reference.