# Migrate from OpenCNPJ

> How to replace the OpenCNPJ CNPJ lookup with the CNPJá API, with live or cached Receita Federal data: parameters, fields and behavior differences.

This guide moves an integration that queries the OpenCNPJ `receita` dataset to [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) in the CNPJá API. It covers swapping the request, mapping parameters and fields, and the behavior differences that require changes in your code.

## Overview

- The `GET /{cnpj}?datasets=receita` lookup becomes `GET /v2/establishments/{taxId}`, with the API key in the `Authorization` header.
- Only the `receita` dataset has an equivalent. The other datasets, the dataset download and the analytics table don't exist in the CNPJá API.
- Fields are renamed to English and grouped: company data goes in `company`, the address in `address` and the partners in `company.partners`.
- Descriptive values such as registration status, company size and head office or branch become `code` and `label` pairs. Your logic compares the `code`.
- Simples Nacional and MEI options are no longer returned by default: request `expand=company.taxRegime`.
- OpenCNPJ publishes the dataset monthly. In CNPJá, each CNPJ comes from a live query at the [Receita Federal](https://solucoes.receita.fazenda.gov.br/Servicos/cnpjreva/) or from the cache, depending on the maximum age you accept in `maxAge`.

Effort: low to medium. If you only use the `receita` dataset, the switch involves one operation and one response format, and the work centers on mapping fields.

## Prerequisites

- **Account and key:** [sign up](https://cnpja.com/en-us/signup) and create a key in [API keys](https://cnpja.com/en-us/organizations/current/api-keys). The walkthrough is in [First request](https://cnpja.com/en-us/docs/api/first-request).
- **Authentication:** send the key as the entire value of the `Authorization` header, with no prefix: `Authorization: YOUR_API_KEY`. With `Bearer`, the request is rejected with `401` `API_KEY_INVALID`. See [Authentication](https://cnpja.com/en-us/docs/api/reference#description/authentication).
- **Base URL:** `https://api.cnpja.com/v2`.
- **What carries over:** the 14-character unmasked CNPJ, alphanumeric included, dates in `YYYY-MM-DD` format, 7-digit [CNAEs](https://concla.ibge.gov.br/busca-online-cnae.html?view=estrutura) and the partners' masked CPF, in the `***650245**` format.
- **What changes:** field names and structure, codes instead of text, numeric share capital, phones in international format, missing fields instead of empty strings, and a masked CNPJ in the URL, which is now rejected.

> **Important:** without a key, Lookup CNPJ only accepts requests with no query parameters at all. Carrying `?datasets=receita` over to the new URL results in `401` `API_KEY_MISSING`. See [Public access](https://cnpja.com/en-us/docs/api/public-access).

## Matching operations

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `GET /{cnpj}` with `datasets=receita` or without `datasets` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) | One establishment per request. See [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup). |
| `GET /{cnpj}` with other datasets | No equivalent | CNO, RNTRC and Portal da Transparência are not part of the CNPJá API. |
| Dataset download | No equivalent | To extract establishments by criteria, use [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments), which is paginated. See [CNPJ search and lists](https://cnpja.com/en-us/docs/api/cnpj-search). |
| `opencnpj-bigquery.public.receita` table | No equivalent | [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments) filters by activity, address, size, status and tax regime, and sorts by relevance, CNPJ, opening date, share capital or legal name. |
| Contract at `/schema` | [API reference](https://cnpja.com/en-us/docs/api/reference) | Every CNPJá API operation, parameter and field. |

CNPJá also has operations with no OpenCNPJ counterpart, such as [Lookup company](https://cnpja.com/en-us/docs/api/reference#tag/companies/GET/v2/companies/%7bid%7d), which lists every establishment of a CNPJ root, and [Lookup person](https://cnpja.com/en-us/docs/api/reference#tag/people/GET/v2/people/%7bid%7d), which lists a partner's companies. See [Partners and people](https://cnpja.com/en-us/docs/api/partners).

## Request example

OpenCNPJ:

```http
GET /37335118000180?datasets=receita HTTP/1.1
Host: api.opencnpj.org
Accept: application/json
```

CNPJá, with the tax regime:

```http
GET /v2/establishments/37335118000180?expand=company.taxRegime HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

## Parameters

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `cnpj` (path) | `taxId` (path) | OpenCNPJ accepts the CNPJ with or without a mask. CNPJá requires exactly 14 characters, unmasked, and rejects a masked CNPJ with `400`. |
| `datasets=receita` | Not needed | Lookup CNPJ always returns the Receita Federal registration. |
| `dataset` | Not needed | Same as `datasets`. |
| `datasets` with `cno`, `rntrc`, `favorecidos_pj`, `ceis`, `cepim`, `cnep`, `acordos_leniencia`, `licitacoes`, `contratos`, `renuncias_fiscais`, `notas_fiscais`, `convenios`, `emendas_parlamentares` or `emendas_documentos` | No equivalent | |
| No equivalent | `maxAge` | Maximum data age you accept, from `5m` to `1y`, default `45d`. See [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age). |
| No equivalent | `expand` | Optional resources: `company.taxRegime`, `stateRegistry`, `suframa` and `address.coordinates`. See [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup). |

## Response fields

CNPJá paths are relative to the Lookup CNPJ response. OpenCNPJ empty strings, such as `""`, correspond in CNPJá to `null` or a missing field, as explained in [Missing vs empty values](https://cnpja.com/en-us/docs/api/responses#missing-and-empty-values).

### Identification and status

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `cnpj` | `taxId` | Same format. |
| `updated_at` | `updatedAt` | In OpenCNPJ, the release of the whole base, the same for every CNPJ; in CNPJá, the establishment's last update from the Receita Federal. |
| `nome_fantasia` | `tradeName` | `null` when there is no trade name. |
| `matriz_filial` | `type.code` | `HEAD` (Matriz) or `BRANCH` (Filial). |
| `data_inicio_atividade` | `incorporationDate` | Same format. |
| `situacao_cadastral` | `status.code` | Fixed code, with the text in `status.label`. See the code table below. |
| `data_situacao_cadastral` | `statusDate` | Same format. |
| `motivo_situacao_cadastral.codigo` | `statusReason.code` | `statusReason` only appears when the establishment is not active. |
| `motivo_situacao_cadastral.descricao` | `statusReason.label` | |
| `situacao_especial` | `specialStatus.label` | 3-digit code in `specialStatus.code`. Missing outside a special status. |
| `data_situacao_especial` | `specialStatusDate` | Missing outside a special status. |
| `lgpd_anonimizado` | No equivalent | |

### Address and contacts

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `tipo_logradouro` | No field of its own | There is no separate field for the street type. |
| `logradouro` | `address.street` | |
| `numero` | `address.number` | Text or `null`. |
| `complemento` | `address.details` | |
| `bairro` | `address.district` | |
| `cep` | `address.postalCode` | 8 digits. |
| `uf` | `address.state` | UF abbreviation. |
| `municipio` | `address.city` | |
| `codigo_municipio` | No equivalent | OpenCNPJ returns the Receita Federal municipality code, such as `9701` for Brasília. CNPJá returns the 7-digit [IBGE code](https://www.ibge.gov.br/explica/codigos-dos-municipios.php) in `address.municipality`. |
| `nome_cidade_exterior` | No equivalent | |
| `codigo_pais` and `pais.codigo` | `address.country.code` | 2-letter country code, such as `BR`. |
| `pais.descricao` | `address.country.label` | |
| `email` | `emails[].address` | A list of emails, each with its type in `emails[].type`. |
| `telefones[].ddd` and `telefones[].numero` | `phones[].number` | A single field in international format: area code `11` and number `900000000` become `+5511900000000`. |
| `telefones[].is_fax` | No equivalent | CNPJá tells landline from mobile in `phones[].type.code`: `LANDLINE` or `MOBILE`. |

### Activities

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `cnae_principal` | `primaryActivity.code` | 7 digits. |
| `cnaes_secundarios[]` | `secondaryActivities[].code` | |
| `cnaes[].codigo` and `cnaes[].descricao` | `primaryActivity` and `secondaryActivities[]`, with `code` and `label` | The primary activity has a field of its own, replacing `cnaes[].is_principal`. |

### Company and partners

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `razao_social` | `company.legalName` | |
| `codigo_natureza_juridica` | `company.legalNature.code` | Same 4-digit format. |
| `natureza_juridica` | `company.legalNature.label` | |
| `capital_social` | `company.shareCapital` | A number with a decimal point: `"99999,99"` becomes `99999.99`. |
| `porte_empresa` | `company.size.code` | `MICRO`, `SMALL` or `OTHER`. |
| `ente_federativo` | `company.federativeEntity` | An object with `code` and `label`, present only when the [legal nature](https://concla.ibge.gov.br/estrutura/natjur-estrutura/natureza-juridica-2021) is public administration. |
| `qualificacao_responsavel` | No equivalent | |
| `QSA[]` | `company.partners[]` | |
| `QSA[].nome_socio` | `company.partners[].person.legalName` | |
| `QSA[].cnpj_cpf_socio` | `company.partners[].person.taxId` | Masked CPF or CNPJ. `null` for foreign or unknown partners. |
| `QSA[].identificador_socio` | `company.partners[].person.type.code` | See the code table below. |
| `QSA[].qualificacao_socio` | `company.partners[].role.label` | 2-digit code in `role.code`. |
| `QSA[].data_entrada_sociedade` | `company.partners[].admissionDate` | |
| `QSA[].codigo_pais` and `QSA[].pais.codigo` | `company.partners[].person.domicileCountry.code` | 2-letter country code. |
| `QSA[].pais.descricao` | `company.partners[].person.domicileCountry.label` | |
| `QSA[].faixa_etaria` | `company.partners[].person.ageGroup` | A code with no label: `41 a 50 anos` becomes `41-50`. Present only for individuals. |
| `QSA[].representante_legal` | `company.partners[].legalRepresentative.person.taxId` | `legalRepresentative` only appears when the partner has a legal representative. |
| `QSA[].nome_representante` | `company.partners[].legalRepresentative.person.legalName` | |
| `QSA[].qualificacao_representante` | `company.partners[].legalRepresentative.role` | `code` and `label`. |

Each partner gets a `person.id`, a stable identifier to look up all of the person's participations. See [Partners and people](https://cnpja.com/en-us/docs/api/partners).

### Simples Nacional and MEI

These fields require `expand=company.taxRegime`, billed separately. See [Tax regime](https://cnpja.com/en-us/docs/api/tax-regime).

| OpenCNPJ | CNPJá | Notes |
|---|---|---|
| `opcao_simples` | `company.taxRegime.type.code` | `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID` or `SIMPLES_NACIONAL_SIMEI` for [Simples Nacional optants](https://consopt.www8.receita.fazenda.gov.br/consultaoptantes), with `SIMPLES_NACIONAL_HYBRID` for those that also opt into the IBS or CBS regular regime and `SIMPLES_NACIONAL_SIMEI` for MEIs. Other regimes are reported too, such as `PRESUMED_PROFIT`. With no annual declaration, the regime is estimated, as explained in [Tax regime](https://cnpja.com/en-us/docs/api/tax-regime). |
| `data_opcao_simples` | `company.taxRegime.simplesNacionalStartDate` | Start of the current period. Present only when `type.code` is `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID` or `SIMPLES_NACIONAL_SIMEI`, and may be `null`. Previous periods are in `company.taxRegime.timeline[].startDate`, with `company.taxRegime.view=DETAILED`. |
| `data_exclusao_simples` | `company.taxRegime.timeline[].endDate` | Items whose `type.code` is `SIMPLES_NACIONAL_PERIOD`. Requires `company.taxRegime.view=DETAILED`. |
| `opcao_mei` | `company.taxRegime.type.code` | `S` matches `SIMPLES_NACIONAL_SIMEI`. |
| `data_opcao_mei` | `company.taxRegime.simeiStartDate` | Start of the current SIMEI period. Present only when `type.code` is `SIMPLES_NACIONAL_SIMEI`, and may be `null`. |
| `data_exclusao_mei` | `company.taxRegime.timeline[].endDate` | Items whose `type.code` is `SIMEI_PERIOD`. Requires `company.taxRegime.view=DETAILED`. |

When `company.taxRegime.type.code` is `SIMPLES_NACIONAL_HYBRID`, `company.taxRegime.view=DETAILED` also returns `company.taxRegime.regularIbsStartDate` and `company.taxRegime.regularCbsStartDate`, the start of the current IBS and CBS regular regime periods, which come only from live queries at the Simples Nacional. Either may be `null` when the company opts into only one of the two.

### Codes instead of text

Each OpenCNPJ text matches a fixed CNPJá `code`, which your logic compares instead.

| CNPJá field | OpenCNPJ text and CNPJá `code` |
|---|---|
| `status` | `Ativa` becomes `ACTIVE`, `Baixada` becomes `CLOSED`, `Inapta` becomes `NONCOMPLIANT`, `Suspensa` becomes `SUSPENDED` and `Nula` becomes `VOID`. |
| `type` | `Matriz` becomes `HEAD` and `Filial` becomes `BRANCH`. |
| `company.size` | `Microempresa (ME)` becomes `MICRO`, `Empresa de Pequeno Porte (EPP)` becomes `SMALL`, and `Demais` and `Não informado` become `OTHER`. |
| `company.partners[].person.type` | `Pessoa Física` becomes `INDIVIDUAL`, `Pessoa Jurídica` becomes `ESTABLISHMENT` and `Estrangeiro` becomes `FOREIGNER`. CNPJá also has `UNKNOWN`, a partner known only by name. |

### New fields

- `company.id`, the CNPJ root, for use with Lookup company.
- With `expand`: state registrations (`stateRegistry`), SUFRAMA registrations (`suframa`) and address coordinates (`address.coordinates`). See [State registrations](https://cnpja.com/en-us/docs/api/state-registrations), [SUFRAMA](https://cnpja.com/en-us/docs/api/suframa) and [Location and maps](https://cnpja.com/en-us/docs/api/location).

## Behavior differences

### Freshness and caching

OpenCNPJ publishes the `receita` dataset monthly, and a CNPJ outside the release returns `404`. In CNPJá, each resource comes from the cache while it is within `maxAge` and is queried live, before the response, when it is older or was never fetched. `maxAge` ranges from `5m` to `1y`, with a `45d` default, and each resource reports its last update in its own `updatedAt`. With a key, a CNPJ not yet in the cache is queried live at the Receita Federal. See [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age).

### Partial success

When a live query fails or runs past its [time limit](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size), the response is `206`, with the same shape as `200`: the affected resource keeps its cached data, or comes back empty if it was never fetched, and is not billed. With no cached data to fall back on, such as on a CNPJ's first lookup, the request fails instead of returning `206`. Treat `206` as success and compare each resource's `updatedAt` with the limit you asked for. See [Partial success](https://cnpja.com/en-us/docs/api/reference#description/partial-success).

### Errors

| OpenCNPJ | CNPJá |
|---|---|
| `400`, invalid CNPJ or dataset filter | `400` `REQUEST_VALIDATION_FAILED`, with the details in `errors[]`. For an invalid query parameter, `errors[].field` names it; for an invalid CNPJ in the path, it is empty. |
| `404`, CNPJ not in the published release | `404` `ESTABLISHMENT_NOT_FOUND`, after a live query confirms it doesn't exist |
| `502`, temporary failure | `500` `UNEXPECTED_ERROR` or `504` `REQUEST_TIMED_OUT`, worth retrying with backoff |

CNPJá also returns `401` for key problems, `402` for a used-up quota or overage budget and `429` for an exceeded limit. Every error body carries `status`, `code`, `message` and `traceId`. Handle errors by `code`, which is stable, and use `message` for display only. See [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors).

### Limits

With a key, the requests-per-second and concurrent-request limits apply to the whole organization, across all of its keys, and follow its plan; without a key, they apply to each source IP. The values are in [Usage limits](https://cnpja.com/en-us/docs/api/limits-and-errors#usage-limits). Above them, the response is `429`, not billed. Each request has a maximum duration, and the client timeout must stay above it, as shown in [Timeout and size](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size).

### Billing

Each resource in the response is billed separately, as a live query, which costs more, or a cached query, and each unit has its own quota in the plan, renewed every month. On Pro, the quota of each unit can grow with [packs](https://cnpja.com/en-us/docs/billing/packs-and-budget#packs), and the organization can set a budget to pay for each query beyond the quota at the per-query overage price, so an exhausted quota does not have to stop the integration. When a quota runs out with no overage budget, or the month's budget runs out, every request made with one of the organization's keys gets `402`, as explained in [Quota used up](https://cnpja.com/en-us/docs/billing/quota-exhausted#api); on Free, which has no packs or budget, this happens as soon as the quota runs out. Requests without a key, rejected requests and server failures are not billed, as listed in [What is not charged](https://cnpja.com/en-us/legal/metering#not-charged). In Lookup CNPJ, the registration and each resource requested in `expand` count separately. A `404` is billed too, as detailed in [What is charged even without a useful result](https://cnpja.com/en-us/legal/metering#charged-without-result). Responses carry no cost headers: track usage under [Usage](https://cnpja.com/en-us/organizations/current/usage). See [Queries and quota](https://cnpja.com/en-us/docs/billing/queries-and-quotas), what each operation consumes in the [Metering Rules](https://cnpja.com/en-us/legal/metering#api) and [Pricing](https://cnpja.com/en-us/pricing).

### Language and labels

`label` values and error messages come in Portuguese by default; send `Accept-Language: en-US` to get them in English. Codes, field names and official source data are never translated. Use `code` in your logic and `label` for display only. See [Language](https://cnpja.com/en-us/docs/api/reference#description/language).

## No equivalent

- The CNO, RNTRC and Portal da Transparência datasets, queried through the other `datasets` values.
- The full dataset download and the `opencnpj-bigquery.public.receita` analytics table.
- The `tipo_logradouro`, `codigo_municipio`, `nome_cidade_exterior`, `telefones[].is_fax`, `qualificacao_responsavel` and `lgpd_anonimizado` fields.

## Step by step

1. List the OpenCNPJ fields your code reads and find each one in the tables above.
2. Remove dependencies on the datasets and downloads that have no equivalent.
3. Open in the browser, without a key and without parameters, a lookup such as `https://api.cnpja.com/v2/establishments/37335118000180` to see the response format, as shown in [Public access](https://cnpja.com/en-us/docs/api/public-access).
4. Create an account and an API key, and keep the key in your backend.
5. Change the URL, remove `datasets` and send the `Authorization` header.
6. Add `expand=company.taxRegime` if you use the Simples Nacional or MEI fields, and set `maxAge` if the 45-day default doesn't fit.
7. Adapt your code to the new formats: `code` instead of text, numeric `company.shareCapital`, phones in international format and `null` or missing fields instead of empty strings.
8. Handle errors by `code`, accept `206` as success and retry `429`, `500` and `504` with a delay.
9. Test with the key: compare both APIs' responses for a sample of your CNPJs and track consumption in [Usage](https://cnpja.com/en-us/organizations/current/usage).
10. Move traffic gradually and turn off the old integration once the results check out.

## Sources for this comparison

What this page says about OpenCNPJ comes from its public pages:

- OpenCNPJ: the lookup, the dataset and the monthly update.
- OpenCNPJ repository: the `receita` dataset, the fields and the BigQuery table.

Sources accessed on November 19, 2026.

Third-party trademarks on this page are used only to identify them, with no affiliation or endorsement ([Terms of Use](https://cnpja.com/en-us/legal/terms#data)).
