# Bulk CNPJ lookup

> How to look up CNPJs in bulk on CNPJá, many at once: paste the list or load a file, choose the data, estimate the usage and download the results in Excel.

A bulk lookup takes many CNPJs at once and delivers an XLSX spreadsheet with each one's data. It lives in the **CNPJ** app, under **Bulk lookup** in the sidebar, and takes three steps: **CNPJs**, **Resources and age** and **Confirm**.

## How it works

Under the hood, a bulk lookup does two things you can also do by hand: it saves the CNPJs as a new [list](https://cnpja.com/en-us/docs/lists/create) of the organization and exports that list to a spreadsheet, as in [Export to a spreadsheet](https://cnpja.com/en-us/docs/lists/export). There is no result on screen: the progress and the download stay on the page of the list created.

The list stays in **Lists** after the lookup. Once the export finishes, you can filter it, export it again with other resources or add CNPJs.

The page shows one step at a time, with the steps at the top, and the **Summary** panel beside them, or below on narrow screens. **Continue** moves on, and **Back** goes back one step. The **Summary** gathers the choices made, and each of its rows leads back to its step:

| Row | What it shows |
| --- | --- |
| **CNPJs** | How many valid CNPJs were read, against the limit of a list, and how many invalid ones will be ignored |
| **Resources and age** | The number of additional resources and the max age, such as "2 additional resources · 7 days", the names of the resources and, under them, on wide screens, the live and cached queries the lookup adds and how it stands, such as **No extra cost** |
| **List name** | The name typed in the **Confirm** step, or **Untitled list** |

On narrow screens, where the **Summary** sits below the steps, the queries and how the lookup stands move out of it onto a strip above the buttons of the **CNPJs** and **Resources and age** steps.

## Who can run it

Anyone can open the page and fill in the steps, but sending takes membership in an organization, in any role, because the lookup becomes a list of the organization and uses the plan's quota:

| Situation | What the page shows |
| --- | --- |
| No account | In the **Confirm** step, the **Create an account to look up** notice, with **Create account** and **Log in**, which bring you back to this page. In the **Summary**, or the strip above the buttons on narrow screens, **Account only** in place of the consumption |
| Account, no organization | In the **Confirm** step, the **Join an organization to look up** notice, and in the **Summary**, or the strip above the buttons on narrow screens, **Members only** in place of the consumption. Ask whoever runs your company's organization for an [invitation](https://cnpja.com/en-us/docs/organizations/invitations) |
| Member | Every step, with the consumption of each choice and the **Estimated consumption** |

Without an organization, in the **Confirm** step, the **Look up and export** button shows a lock, with the tooltip **Account only** or **Members only**. Access levels are covered in [Guests, accounts and organizations](https://cnpja.com/en-us/docs/app/access-levels#matrix).

## 1. CNPJs

1. Open **Bulk lookup**, in the sidebar of the **CNPJ** app.
2. Type or paste the CNPJs in the **CNPJs** field, or click **Load file** to read an Excel, CSV or text file.
3. Check the count under the field and click **Continue**.

The field is the same as in **Create list**: it takes CNPJs with or without punctuation, separated by lines, spaces, commas or semicolons, highlights the valid ones and counts repeats once. Only valid CNPJs move on, and the file is read in your browser. The details are in [Import CNPJs](https://cnpja.com/en-us/docs/lists/import).

Without any valid CNPJ, **Continue** does not move on and the field shows **Add at least one valid CNPJ.**

For members, as soon as there are valid CNPJs, the **Summary**, or the strip above the buttons on narrow screens, already shows what the lookup consumes with the resources and age in use. A quota already used up, with no budget to pay the overage, is flagged right in this step, before you paste the CNPJs, as [Quota usage](https://cnpja.com/en-us/docs/lists/export#quota) explains.

## 2. Resources and age

At the top of the step, choose on the ruler the maximum age accepted for the data: **Live**, one of the ready-made ages, such as **7 days**, which the step opens on the first time, or **Custom**. Data older than the age chosen is queried live at the source, which costs more and takes longer. On the ruler, the cache side is hatched in grey and the live side in teal.

Under it, choose the data the spreadsheet brings besides **Registration, activities and partners**, which is **Always included**: **Tax regime**, **State registrations**, **SUFRAMA registrations** and **Address coordinates**. The first two have the **Summary** and **Detailed** levels, and **State registrations** lets you choose the states to query. Each resource ticked is charged per establishment.

For members, each choice shows what it consumes where it is made, worked out from the CNPJs themselves: the registration and each resource ticked show the live and cached queries they add, and the **Summary**, or the strip above the buttons on narrow screens, adds it all up and says how the lookup stands, such as **No extra cost**, the overage it would spend or **Doesn't fit the quota**, worked out again for every resource ticked and every age chosen. Move the age and see at once whether the lookup fits, without changing steps.

The options and figures are the same as in an export and are described in [Resources and detail levels](https://cnpja.com/en-us/docs/lists/export#resources), [States for state registrations](https://cnpja.com/en-us/docs/lists/export#states) and [Max age](https://cnpja.com/en-us/docs/lists/export#max-age), and the statuses in [Estimated consumption](https://cnpja.com/en-us/docs/lists/export#estimate). Your choices of resources and age are saved in this browser and also apply to the next export.

## 3. Confirm

1. Fill in the **List name** that will hold the CNPJs.
2. Check the **Estimated consumption** and, if the lookup goes past the quota and the overage budget pays the difference, tick the box that authorizes the overage.
3. Click **Look up and export**.

For members, under the name, the **Estimated consumption** panel shows, per kind of query, what the period already used, what the lookup adds and what is left free, the overage budget's row whenever the organization has one and the plan prices overage queries, even when the lookup fits the quotas, and, last, the **Extra cost**, with what it means. The panel is the same as in an export, described in [Estimated consumption](https://cnpja.com/en-us/docs/lists/export#estimate), and the period's quota is read again on every step after **CNPJs**.

A bulk lookup consumes live or cached queries from the organization's quota, per CNPJ and per resource, like an export, and a CNPJ that is not in the cache, a nonexistent one included, counts as live and is left out of the spreadsheet; the rules are in the [Metering Rules](https://cnpja.com/en-us/legal/metering#platform-exports). It is accepted under the same conditions as an export, and the app holds it back the same way, as [Quota usage](https://cnpja.com/en-us/docs/lists/export#quota) explains:

- **Estimate on its way:** **Look up and export** is dimmed, with the tooltip **Wait for the consumption estimate**.
- **Does not fit:** a notice under the panel says what falls short and offers the way out your role allows and **Adjust resources and age**, and **Look up and export** shows a lock, with the same words in its tooltip.
- **Overage:** the button only goes ahead once you tick the authorization box, and until then its tooltip says **Authorize the overage to export**. While a new estimate is on its way, the box is dimmed and cannot be ticked.
- **Check before sending:** on every click, the app reads the quota again and, when a budget may pay overage or the period's quota could not be read, asks for the estimate again too. Meanwhile the button shows **Checking the cost…**, and **Back** and the **Summary** rows are held. If the overage changed, the authorization is taken back and a notice shows the new amount, for you to review and authorize again. If the estimate could not be worked out again, the authorization is taken back too.

The step's last line says what happens after sending and is left out while the lookup would be refused. The app confirms the export started and opens the new list with the **Exports** panel open. If something stops the send, such as a blank name or a custom age out of range, the page goes back to the step with the problem.

> **Important:** a bulk lookup consumes the estimate determined when the request is accepted, and that consumption does not change while the file is generated, as the [Metering Rules](https://cnpja.com/en-us/legal/metering#platform-exports) state.

## Track and download the result

The export shows on the list's page and goes from **Queued** to **Exporting**, with the percentage, and then to **Ready**. The progress also shows in the sidebar and in the **Exported** column of the **Lists** page, and updates on its own. You can leave the page meanwhile.

Once the export is **Ready**:

1. Open the list, from the sidebar or from the **Lists** page.
2. Click **Download**, at the top of the page.
3. If the export was split into parts, download each one in **Exports** (**Part 1**, **Part 2** and so on).

Until the export finishes, the list takes no changes. The states and the parts are covered in [Run and track](https://cnpja.com/en-us/docs/lists/export#status) and [Download the spreadsheet and its parts](https://cnpja.com/en-us/docs/lists/export#download).

## Limits

A bulk lookup takes up to the CNPJ limit of a list and counts toward the organization's limit of lists. The current values are in Usage limits, under [Lists, exports and bulk](https://cnpja.com/en-us/docs/billing/limits#lists) and [Organization](https://cnpja.com/en-us/docs/billing/limits#organization).

## Common problems

- **Add at least one valid CNPJ.** No value in the field is a valid CNPJ. Check the amber values, as [Import CNPJs](https://cnpja.com/en-us/docs/lists/import#troubleshooting) explains.
- **A list holds up to 1,000,000 CNPJs.** There are more valid CNPJs than a list takes, and the **Summary**, or the strip above the buttons on narrow screens, shows the same words in place of the consumption. Split them into more than one lookup.
- **Add CNPJs to estimate the consumption.** The **Summary**, or the strip above the buttons on narrow screens, only works out the consumption with valid CNPJs within the limit of a list.
- **Couldn't estimate the consumption.** or **Estimate unavailable**: the estimate did not answer. Click **Try again**, in the **Estimated consumption**, or the button beside **Estimate unavailable**, in the **Summary**, or on the strip above the buttons on narrow screens. Without it, the lookup is checked when sent, as [Quota usage](https://cnpja.com/en-us/docs/lists/export#quota) explains.
- **Enter a name for this list.** The **List name** is blank in the **Confirm** step.
- **The organization reached its limit of lists.** Every bulk lookup creates a list. Delete lists you no longer use and send again.
- **We couldn't start this lookup. Please try again.** The lookup did not start. Click **Look up and export** again.
- *The app said the quota is used up.* The quota changed after the check, or the estimate did not answer, and the export was refused with nothing consumed. The list was already created and opens on screen. Export it from its page once there is quota, as [Quota used up](https://cnpja.com/en-us/docs/billing/quota-exhausted) explains.
- *The app said the list was created, but its export couldn't start.* The list opens with **Exports**. Click **Export** there.
- *The Look up and export button shows a lock.* Sending takes membership in an organization, as [Who can run it](#access) explains. For members, the lock says the lookup does not fit the quota or the overage budget: use the way out in the notice, or click **Adjust resources and age** and choose fewer resources, send fewer CNPJs or wait for the quota to reset. If the live quota falls short, move the max age to the right of the ruler: the **Summary**, or the strip above the buttons on narrow screens, shows for each age whether the lookup fits.
- *Look up and export does not move on, with the tooltip Authorize the overage to export.* The lookup goes past the quota, and the overage budget pays the difference. Check the **Extra cost** and tick the authorization box above the buttons, or go back to the **Resources and age** step and adjust the resources and the age to fit the quotas.
- *The spreadsheet is taking a while.* Every accepted lookup is delivered. Many CNPJs and live resources take longer, and the progress may pause for a while as a source is queried again. The export carries on by itself until it is ready.

## In the API

The API has no bulk lookup. Create a list with the CNPJs and read the cached registration, in pages, with Search CNPJ and the `lists.some` filter, as [CNPJ search and lists](https://cnpja.com/en-us/docs/api/cnpj-search#lists) explains, or look up each CNPJ in [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup), with the same `expand` and `maxAge`.
