# Migrate from CNPJ.ws

> How to replace the CNPJ.ws commercial API with the CNPJá API: CNPJ and CNPJ root lookups, company search, SUFRAMA and the equivalent of each field.

This guide moves an integration with the CNPJ.ws commercial API to the CNPJá API. It covers the CNPJ lookup, the CNPJ root lookup, the company search and the [SUFRAMA](https://www4.suframa.gov.br/cadsuf/#/menu-externo) registration check, with the equivalent of each parameter and each response field.

## Overview

- **Authentication:** the key goes alone in the `Authorization` header, with no `Bearer`. The `x_api_token` header and the `token` URL parameter no longer exist.
- **Response format:** fields have English names, the establishment sits at the root of the response and the company under `company`. Classified values come as a stable `code` plus a display `label`, including the registration status, the establishment type and the partner type, which CNPJ.ws returns as text only.
- **Tax data on demand:** tax regime, state registrations and SUFRAMA registrations are optional resources, requested in `expand` and billed separately.
- **Data age under your control:** the `maxAge` parameter sets the maximum accepted age; older data is queried live at the official source during the request.
- **CNPJ root:** Lookup company returns every establishment of the root in a single response, with a summary of each, without pagination.
- **Search:** results carry each establishment's registration data, not just CNPJs, with operator-based filters and forward-only cursor pagination.
- **SUFRAMA:** checking a registration becomes `expand=suframa` on Lookup CNPJ.

Effort: medium. Switching authentication and URLs is straightforward; most of the work is in mapping the response fields and the search filters.

## 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`. The key never goes in the URL. 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 CNPJ without punctuation, the 8-character root, dates as `YYYY-MM-DD`, the 7-digit [CNAE](https://concla.ibge.gov.br/busca-online-cnae.html?view=estrutura), the municipality's 7-digit [IBGE code](https://www.ibge.gov.br/explica/codigos-dos-municipios.php), the partners' masked CPF in the same format (`***650245**`) and the 4-digit [legal nature](https://concla.ibge.gov.br/estrutura/natjur-estrutura/natureza-juridica-2021) code.
- **What changes:** the CNPJ.ws token, the field names, page-number pagination, the state, city and country `id` fields, the BACEN country code and text-only classified values.

## Matching operations

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `GET /cnpj/{cnpj}` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) | Tax regime, state registrations and SUFRAMA are requested in `expand`. |
| `GET /cnpj-raiz/{cnpj-raiz}` | [Lookup company](https://cnpja.com/en-us/docs/api/reference#tag/companies/GET/v2/companies/%7bid%7d) | Every establishment in one response, with a summary of each in `establishments[]`. |
| `GET /v2/pesquisa` | [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments) | Each establishment's registration data in `records[]`; operator-based filters. |
| `GET /v2/pesquisa` with `socio_nome` or `socio_cpf_cnpj` | [Search people](https://cnpja.com/en-us/docs/api/reference#tag/people/GET/v2/people) | The person found lists the companies in `participations[]`. See [Partners and people](https://cnpja.com/en-us/docs/api/partners). |
| `POST /suframa` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) with `expand=suframa` | Compare the registration number in `suframa.registrations[].number`. |
| `GET /consumo` | No equivalent in the API | Track usage in [Usage](https://cnpja.com/en-us/organizations/current/usage). |
| `GET /auth/token/renew` | No equivalent in the API | Create a key in [API keys](https://cnpja.com/en-us/organizations/current/api-keys) and revoke the old one. |

## Request example

CNPJ.ws:

```http
GET /cnpj/37335118000180 HTTP/1.1
Host: comercial.cnpj.ws
x_api_token: YOUR_TOKEN
```

CNPJá:

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

Without `expand`, the CNPJá response carries the registration, the company data and the partners. Request in `expand` only the resources your integration read from the CNPJ.ws response, as the tables below show. See [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup).

## Parameters

### Authentication

| CNPJ.ws | CNPJá |
|---|---|
| `x_api_token` header | `Authorization` header, with the key only |
| `Authorization: Bearer` header | `Authorization` header, without `Bearer` |
| `token` URL parameter | No equivalent |

### CNPJ and root lookups

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `cnpj` in the path | `taxId` in the Lookup CNPJ path | 14 characters; CNPJá also accepts the alphanumeric CNPJ, in uppercase. |
| `cnpj-raiz` in the path | `id` in the Lookup company path | 8 characters. |
| `page` on `/cnpj-raiz` | No equivalent | Lookup company returns every establishment at once. |
| `/cnpj-raiz` filters named in `filtros_disponiveis` and `filtros_aplicados`: `nome_fantasia`, `pais_id`, `estado_id`, `cidade_id`, `atividade_principal_id`, `tipo` | No equivalent | Filter `establishments[]` by `tradeName`, `address.country.code`, `address.state`, `address.municipality`, `primaryActivity.code` and `type.code`. |
| No equivalent | `maxAge` | Maximum data age, default `45d`. See [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age). |
| No equivalent | `expand` | `company.taxRegime`, `stateRegistry`, `suframa` and `address.coordinates`. |

### Search

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `cursor` | `cursor` | Send `nextCursor` alone, with no other parameter. |
| `limite` or `limit` | `limit` | From `1` to `1000`, default `10`. |
| `atividade_principal_id` | `primaryActivity.code.in` | 7-digit CNAE. |
| `atividade_secundaria_id` | `secondaryActivities.code.some` | 7-digit CNAE. |
| `atividade_id` | `economicActivities.code.some` | Primary or secondary activity. |
| `natureza_juridica_id` | `company.legalNature.code.in` | 4 digits. |
| `razao_social` | `company.legalName.some` | Each word counts on its own; to require every word, use `search`. |
| `nome_fantasia` | `tradeName.some` | `names.some` searches the legal name or the trade name. |
| `pais_id` | `address.country.code.in` | Alpha-2 code, such as `BR`, instead of the BACEN code. |
| `estado_id` | `address.state.in` | UF abbreviation, such as `SP`, instead of the state's IBGE code. |
| `cidade_id` | `address.municipality.in` | 7-digit IBGE code. |
| `cep` | `address.postalCode.in` | 8 digits; `address.postalCode.gte` and `.lte` form a range. |
| `situacao_cadastral` | `status.code.in` | `ACTIVE`, `CLOSED`, `NONCOMPLIANT`, `VOID`, `SUSPENDED`. |
| `data_situacao_cadastral_de` and `_ate` | `statusDate.gte` and `statusDate.lte` | Closed range. |
| `porte_id` | `company.size.code.in` | `01` becomes `MICRO` and `03` becomes `SMALL`; `00` and `05` fall under `OTHER`. |
| `socio_nome` | No equivalent in Search CNPJ | Use `search` or `legalName.in` in Search people. |
| `socio_cpf_cnpj` | No equivalent in Search CNPJ | Use `taxId.in` in Search people. A CPF is matched on its fourth to ninth digits and can match other people with the same digits. |
| `data_inicio_atividade_de` and `_ate` | `incorporationDate.gte` and `incorporationDate.lte` | Closed range. |
| `token` | No equivalent | The key goes in the header. |
| No equivalent | `sort` and `order` | `relevance` by default, or `taxId`, `incorporationDate`, `company.shareCapital` or `company.legalName`, in `ASC` or `DESC` order. See [Sorting](https://cnpja.com/en-us/docs/api/reference#description/sorting). |

CNPJá has more filters, such as share capital, tax regime, phones, emails and CNPJ lists. See [CNPJ search and lists](https://cnpja.com/en-us/docs/api/cnpj-search) and [Search filters](https://cnpja.com/en-us/docs/api/reference#description/search-filters).

### SUFRAMA check

| CNPJ.ws | CNPJá |
|---|---|
| `cnpj` in the body | `taxId` in the Lookup CNPJ path, with `expand=suframa` |
| `inscricao` in the body | No equivalent: look for the number in `suframa.registrations[].number` |

## Response fields

CNPJ.ws paths starting with `estabelecimento.` come from inside the `estabelecimento` object. In CNPJá, the establishment sits at the root of the Lookup CNPJ response.

### Identification and status

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `estabelecimento.cnpj` | `taxId` | |
| `cnpj_raiz`, `estabelecimento.cnpj_raiz` | `company.id` | |
| `estabelecimento.cnpj_ordem` | No equivalent | Characters 9 to 12 of `taxId`. |
| `estabelecimento.cnpj_digito_verificador` | No equivalent | Characters 13 and 14 of `taxId`. |
| `estabelecimento.tipo` | `type.code` and `type.label` | `HEAD` head office, `BRANCH` branch. |
| `estabelecimento.nome_fantasia` | `tradeName` | |
| `estabelecimento.data_inicio_atividade` | `incorporationDate` | |
| `estabelecimento.situacao_cadastral` | `status.code` and `status.label` | `Ativa` becomes `ACTIVE`, `Baixada` becomes `CLOSED`, `Inapta` becomes `NONCOMPLIANT`, `Nula` becomes `VOID`, `Suspensa` becomes `SUSPENDED`. |
| `estabelecimento.data_situacao_cadastral` | `statusDate` | |
| `estabelecimento.motivo_situacao_cadastral` | `statusReason.code` and `statusReason.label` | 2-digit code; present only when not active. |
| `estabelecimento.situacao_especial` | `specialStatus.code` and `specialStatus.label` | 3-digit code; present only for active establishments with a special status. |
| `estabelecimento.data_situacao_especial` | `specialStatusDate` | Same condition as `specialStatus`. |
| `estabelecimento.atualizado_em` | `updatedAt` | Last update from the [Receita Federal](https://solucoes.receita.fazenda.gov.br/Servicos/cnpjreva/). |

### Address and contacts

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `estabelecimento.tipo_logradouro` and `estabelecimento.logradouro` | `address.street` | The street type comes with the name, as in `Avenida Brigadeiro Faria Lima`. |
| `estabelecimento.numero` | `address.number` | |
| `estabelecimento.complemento` | `address.details` | |
| `estabelecimento.bairro` | `address.district` | |
| `estabelecimento.cep` | `address.postalCode` | 8 digits. |
| `estabelecimento.cidade.nome` | `address.city` | |
| `estabelecimento.cidade.ibge_id` | `address.municipality` | 7-digit string, not a number. |
| `estabelecimento.cidade.id`, `estabelecimento.cidade.siafi_id` | No equivalent | |
| `estabelecimento.nome_cidade_exterior` | `address.city` | For establishments abroad. |
| `estabelecimento.estado.sigla` | `address.state` | |
| `estabelecimento.estado.nome`, `estabelecimento.estado.id`, `estabelecimento.estado.ibge_id` | No equivalent | |
| `estabelecimento.pais.iso2` | `address.country.code` | |
| `estabelecimento.pais.nome` | `address.country.label` | |
| `estabelecimento.pais.id`, `estabelecimento.pais.iso3`, `estabelecimento.pais.comex_id` | No equivalent | |
| `estabelecimento.ddd1` and `estabelecimento.telefone1`, `estabelecimento.ddd2` and `estabelecimento.telefone2` | `phones[].number` | One item per phone, in E.164 with the area code: `+5511900000000`. The type is in `phones[].type`: `LANDLINE` or `MOBILE`. |
| `estabelecimento.ddd_fax` and `estabelecimento.fax` | No equivalent | |
| `estabelecimento.email` | `emails[].address` | A list of emails, each with its type in `emails[].type`. |
| No equivalent | `address.coordinates` | Latitude and longitude with `expand=address.coordinates`. See [Location and maps](https://cnpja.com/en-us/docs/api/location). |

### Activities

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `estabelecimento.atividade_principal.id` | `primaryActivity.code` | 7-digit CNAE. |
| `estabelecimento.atividade_principal.descricao` | `primaryActivity.label` | |
| `estabelecimento.atividades_secundarias[].id` | `secondaryActivities[].code` | |
| `estabelecimento.atividades_secundarias[].descricao` | `secondaryActivities[].label` | |
| Activity `secao`, `divisao`, `grupo`, `classe` and `subclasse` | No equivalent | |

### Company and partners

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `razao_social` | `company.legalName` | |
| `capital_social` | `company.shareCapital` | A number, not a string: `99999.99`. |
| `porte.id` and `porte.descricao` | `company.size.code` and `company.size.label` | `01` becomes `MICRO`, `03` becomes `SMALL`, the rest become `OTHER`. |
| `natureza_juridica.id` and `natureza_juridica.descricao` | `company.legalNature.code` and `company.legalNature.label` | Same 4-digit code. |
| `responsavel_federativo` | `company.federativeEntity.code` and `company.federativeEntity.label` | Object present only for public-administration legal natures: `BR` for the federal government, the UF abbreviation or the municipality's IBGE code. |
| `qualificacao_do_responsavel` | No equivalent | |
| `atualizado_em` | `updatedAt` | CNPJá has an update date for the establishment, not for the company. |
| `socios[]` | `company.partners[]` | Details in [Partners and people](https://cnpja.com/en-us/docs/api/partners). |
| `socios[].nome` | `company.partners[].person.legalName` | |
| `socios[].cpf_cnpj_socio` | `company.partners[].person.taxId` | Masked CPF or CNPJ; `null` for foreigners and for partners known only by name. |
| `socios[].tipo` | `company.partners[].person.type.code` and `.label` | `Pessoa Física` becomes `INDIVIDUAL`; also `ESTABLISHMENT`, `FOREIGNER` and `UNKNOWN`. |
| `socios[].data_entrada` | `company.partners[].admissionDate` | |
| `socios[].faixa_etaria` | `company.partners[].person.ageGroup` | `41 a 50 anos` becomes `41-50`; no `label`. |
| `socios[].qualificacao_socio.id` | `company.partners[].role.code` | A 2-digit string, not a number: `5` becomes `05`. |
| `socios[].qualificacao_socio.descricao` | `company.partners[].role.label` | |
| `socios[].pais.iso2` | `company.partners[].person.domicileCountry.code` | |
| `socios[].pais.nome` | `company.partners[].person.domicileCountry.label` | |
| `socios[].pais_id`, `socios[].pais.id`, `socios[].pais.iso3`, `socios[].pais.comex_id` | No equivalent | |
| `socios[].cpf_representante_legal` | `company.partners[].legalRepresentative.person.taxId` | In CNPJá, `legalRepresentative` appears only when there is a representative. |
| `socios[].nome_representante` | `company.partners[].legalRepresentative.person.legalName` | |
| `socios[].qualificacao_representante` | `company.partners[].legalRepresentative.role.code` and `.label` | |
| `socios[].atualizado_em` | No equivalent | |
| No equivalent | `company.partners[].person.id` | The person's CNPJá ID, used in [Lookup person](https://cnpja.com/en-us/docs/api/reference#tag/people/GET/v2/people/%7bid%7d). |

### Tax data

These fields require `expand`. The tax regime comes with `expand=company.taxRegime`, state registrations with `expand=stateRegistry` and SUFRAMA registrations with `expand=suframa`. See [Tax regime](https://cnpja.com/en-us/docs/api/tax-regime), [State registrations](https://cnpja.com/en-us/docs/api/state-registrations) and [SUFRAMA](https://cnpja.com/en-us/docs/api/suframa).

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `simples.simples` | `company.taxRegime.type.code` | [Simples Nacional optants](https://consopt.www8.receita.fazenda.gov.br/consultaoptantes) come as `SIMPLES_NACIONAL`, as `SIMPLES_NACIONAL_HYBRID` when they also opt into the IBS or CBS regular regime or, for MEIs, as `SIMPLES_NACIONAL_SIMEI`. |
| `simples.data_opcao_simples` | `company.taxRegime.simplesNacionalStartDate` | Start of the current Simples Nacional period. Present only when `type.code` is `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID` or `SIMPLES_NACIONAL_SIMEI`, and may be `null`. |
| `simples.mei` | `company.taxRegime.type.code` | MEIs come as `SIMPLES_NACIONAL_SIMEI`. |
| `simples.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`. |
| `simples.data_exclusao_simples`, `simples.data_exclusao_mei` | `company.taxRegime.timeline[].endDate` | With `company.taxRegime.view=DETAILED`, in the `SIMPLES_NACIONAL_PERIOD` and `SIMEI_PERIOD` items. An exclusion with a future date comes in `startDate`, in the `SIMPLES_NACIONAL_EXCLUSION` and `SIMEI_EXCLUSION` items. |
| `simples.atualizado_em` | `company.taxRegime.updatedAt` | |
| `estabelecimento.regimes_tributarios[]` | `company.taxRegime.timeline[]` | With `company.taxRegime.view=DETAILED` on Lookup CNPJ. CNPJ.ws returns one row per year; CNPJá returns periods with a start and an end. Actual, presumed and arbitrated profit have one period per calendar year declared in the ECF, and Simples Nacional, SIMEI and the IBS and CBS regular regime have periods of any length. See [Regime history](https://cnpja.com/en-us/docs/api/tax-regime#regime-history). |
| `estabelecimento.regimes_tributarios[].ano` | `company.taxRegime.timeline[].startDate` and `company.taxRegime.timeline[].endDate` | In ECF periods, from January 1 to December 31 of the calendar year. |
| `estabelecimento.regimes_tributarios[].regime_tributario` | `company.taxRegime.timeline[].type.code` | `LUCRO REAL` becomes `ACTUAL_PROFIT_PERIOD`; also `PRESUMED_PROFIT_PERIOD`, `ARBITRATED_PROFIT_PERIOD`, `SIMPLES_NACIONAL_PERIOD`, `SIMEI_PERIOD`, `REGULAR_IBS_PERIOD` and `REGULAR_CBS_PERIOD`. `IMUNES E ISENTAS` has no equivalent. The current regime is in `company.taxRegime.type.code`: `ACTUAL_PROFIT`, `PRESUMED_PROFIT`, `ARBITRATED_PROFIT`, `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID`, `SIMPLES_NACIONAL_SIMEI` or `NOT_APPLICABLE`. |
| `estabelecimento.regimes_tributarios[].forma_de_tributacao` | `company.taxRegime.timeline[].type.code` | The period type already states the taxation method, with no separate field. |
| `estabelecimento.regimes_tributarios[].atualizado_em` | `company.taxRegime.updatedAt` | One date for the whole tax regime, not per year. |
| `estabelecimento.inscricoes_estaduais[]` | `stateRegistry.registrations[]` | By default only the establishment's UF; for every UF, send `stateRegistry.states=ALL`. |
| `estabelecimento.inscricoes_estaduais[].inscricao_estadual` | `stateRegistry.registrations[].number` | |
| `estabelecimento.inscricoes_estaduais[].ativo` | `stateRegistry.registrations[].isEnabled` | Registration enabled as a taxpayer. |
| `estabelecimento.inscricoes_estaduais[].estado.sigla` | `stateRegistry.registrations[].state` | |
| `estabelecimento.inscricoes_estaduais[].atualizado_em` | `stateRegistry.registrations[].updatedAt` | |
| `estabelecimento.inscricoes_suframa[]` | `suframa.registrations[]` | The registration's number, status, dates, address and activities. |

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.

CNPJá also returns in `stateRegistry` each registration's type, the recipient restriction and the interstate blocks, and with `stateRegistry.view=DETAILED` the activity, the address and the authorized tax documents.

### CNPJ root

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `data[]` | `establishments[].taxId` | Each `establishments[]` item also carries type, trade name, status, address and primary activity. |
| `paginacao` | No equivalent | No pagination. |
| `ordenacao`, `filtros_disponiveis`, `filtros_aplicados` | No equivalent | |

Lookup company also returns the company data, the partners in `partners[]` and the tax regime in `taxRegime`, always present and without the history or the IBS and CBS regular regime dates.

### Search

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `data[]` | `records[].taxId` | Each record carries the establishment's registration data, the company, the partners and the tax regime without the history or the IBS and CBS regular regime dates. |
| `paginacao.limite` | `limit` | |
| `paginacao.total` | `total` | May vary between pages. |
| `paginacao.proximo_cursor` | `nextCursor` | `null` on the last page. |
| `paginacao.tem_proxima_pagina` | `nextCursor` other than `null` | |
| `paginacao.tem_pagina_anterior`, `paginacao.cursor_anterior`, `paginacao.cursor_pagina_atual`, `paginacao.cursor_consulta_atual` | No equivalent | Pagination only moves forward. |
| `filtros_disponiveis`, `filtros_aplicados` | No equivalent | |

### SUFRAMA check

| CNPJ.ws | CNPJá | Notes |
|---|---|---|
| `cnpj_raiz` | `company.id` | |
| `cnpj` | `taxId` | |
| `inscricao_suframa` | `suframa.registrations[].number` | |
| `ativo` | `suframa.registrations[].status.code` | `ACTIVE`, `INACTIVE`, `BLOCKED` or `CANCELLED`. |
| `atualizado_em` | `suframa.registrations[].updatedAt` | |

### Formats

- Classified values come as `code` and `label`. Use the `code` in logic and the `label` only for display, since it changes with the language. See [Response format](https://cnpja.com/en-us/docs/api/responses).
- Numbers are numbers: `company.shareCapital` is not a string. Codes are strings without punctuation, including the municipality's IBGE code and the partner role.
- Phones come in E.164, with `+55` and the area code in the same value.
- A resource requested in `expand` is always present, even when empty; a resource you don't request is absent.

## Behavior differences

### Freshness and caching

The CNPJ.ws documentation states that its lookup and search use the service's own database, which can lag up to 45 days behind the Receita Federal. 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`. Lookup company and Search CNPJ don't accept `maxAge` and serve cached data only. 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

The CNPJ.ws documentation lists the `401`, `404` and `429` statuses on the lookups and the SUFRAMA check, and `400`, `401`, `403` and `429` on the search. In CNPJá, every error body carries `status`, `code`, `message` and `traceId`. Handle errors by `code`, which is stable, such as `ESTABLISHMENT_NOT_FOUND` or `COMPANY_NOT_FOUND`, and use `message` for display only. See [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors).

### Limits

The CNPJ.ws commercial API serves up to 500 requests per minute per subscription. In CNPJá, 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). On Lookup CNPJ, the registration and each resource requested in `expand` count separately, and Search CNPJ and Lookup company consume cached queries. 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).

### Pagination

Search CNPJ uses a cursor like CNPJ.ws, but forward only. Send each page's `nextCursor` as `cursor`, on its own, without repeating filters or `limit`, until `nextCursor` comes back `null`. The cursor keeps the filters, `sort`, `order` and `limit` of the first request and is valid for a set time between one page and the next, given in [Timeout and size](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size); once expired, the response is `400` `PAGE_CURSOR_INVALID` and the search starts over. Drop duplicates by `taxId`. See [Pagination](https://cnpja.com/en-us/docs/api/reference#description/pagination).

> **Important:** `cursor` must be the request's only parameter. With any other, including `limit`, CNPJá returns `400` `REQUEST_VALIDATION_FAILED`.

### 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

- Checking monthly request usage through the API. Track usage in [Usage](https://cnpja.com/en-us/organizations/current/usage) and [Requests](https://cnpja.com/en-us/organizations/current/usage-events).
- Renewing the token through the API. Create and revoke keys in [API keys](https://cnpja.com/en-us/organizations/current/api-keys).
- A dedicated SUFRAMA check call, with the registration number in the body.
- Page-number pagination on the CNPJ root and the previous page on the search.
- Partner filters inside the company search.
- The list of available and applied filters in the response.
- The state, city and country `id` fields, the SIAFI code, the BACEN code and the country's ISO alpha-3.
- The CNAE hierarchy in section, division, group, class and subclass.
- Years with the `IMUNES E ISENTAS` regime in `regimes_tributarios`.
- The fax and the responsible person's role.

## Step by step

1. Create the account and an API key, as in [First request](https://cnpja.com/en-us/docs/api/first-request).
2. Switch authentication: send the key alone in the `Authorization` header and remove `token` from the URLs.
3. Switch the URLs: `/cnpj/{cnpj}` to `/v2/establishments/{taxId}`, `/cnpj-raiz/{cnpj-raiz}` to `/v2/companies/{id}` and `/v2/pesquisa` to `/v2/establishments`.
4. Set each call's `expand` to match the tax fields you use, and `maxAge` to match the data age you accept.
5. Rewrite the field mapping with the tables above, converting text descriptions into `code` values.
6. On the CNPJ root, remove the page loop and filter `establishments[]` in your code.
7. On the search, convert the filters, send `cursor` alone and read the data straight from `records[]`.
8. For the SUFRAMA check, use `expand=suframa` and compare the number in `suframa.registrations[].number`.
9. Handle errors by `code`, accept `206` as success and retry `429`, `500` and `504` with backoff.
10. Validate the integration with the key. Lookup CNPJ also accepts requests without a key and with no parameters in the URL, as in [Public access](https://cnpja.com/en-us/docs/api/public-access); `expand`, searches and Lookup company require the key.
11. Compare the responses for a sample of CNPJs between both integrations, track usage in [Usage](https://cnpja.com/en-us/organizations/current/usage) and then switch traffic.

## Sources for this comparison

What this page says about CNPJ.ws comes from its public documentation:

- Overview: the response structure and the data lag.
- Public API reference: the lookup and the SUFRAMA validation without a token.
- Commercial API reference: authentication, the lookup, the paginated root, the search, the SUFRAMA validation, the monthly usage, the token renewal and the per-minute limit.
- Data models: the company, partner, Simples Nacional and tax regime fields.
- Establishments: the establishment fields.
- Error messages: the errors.

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)).
