Migrate from BrasilAPI
How to replace BrasilAPI's CNPJ and CEP lookups with the CNPJá API: matching operations and fields, codes, errors and maximum data age.
This guide moves an integration with BrasilAPI’s CNPJ and CEP lookups to the CNPJá API. Facts about BrasilAPI come from the documentation and code it publishes; facts about CNPJá come from the Reference.
Overview
- The CNPJ and CEP lookups become Lookup CNPJ and Lookup CEP.
- Fields change name and structure: the CNPJá response uses English names, groups the company under
companyand the address underaddress, and returns phones, emails and partners as lists of objects. - Numeric codes, such as
situacao_andcadastral codigo_, become objects withporte codeandlabel, wherecodeis a stable text value, such asACTIVE. - The Simples Nacional and MEI options and the tax regime leave the default response and are requested with
expand=company., which needs an API key.taxRegime - The CNPJá API requires an API key, except for Lookup CNPJ and Lookup CEP with no query parameters at all, and is billed per query.
- Every response carries
updatedAt, andmaxAgesets the maximum accepted data age. - Errors carry
statusand a stablecodeinstead ofnameandtype.
Effort: low to medium. BrasilAPI’s lookups take no query parameters, so the work lies in replacing the layer that reads fields and converts codes.
Prerequisites
- Account and key: sign up and create a key in API keys. The walkthrough is in First request.
- Authentication: BrasilAPI’s documentation doesn’t describe authentication. In CNPJá, send the key as the entire value of the
Authorizationheader, with no prefix:Authorization: YOUR_. WithAPI_ KEY Bearer, the request is rejected with401API_. See Authentication.KEY_ INVALID - Base URL:
https:/, instead of/ api. cnpja. com/ v2 https:/./ brasilapi. com. br/ api - What carries over: the 14-character CNPJ, alphanumeric included, the 8-digit CEP, the 7-digit IBGE municipality code, the official CNAE, legal nature, partner role and status reason codes, now as text, the masked partner CPF in the same format, such as
***112108**, and dates inYYYY-MM-DDformat. - What changes: field names and the response structure, the numeric codes for registration status, company size, head office or branch, and partner type, and a CNPJ or CEP with punctuation in the URL. The CEP coordinates and time zone and the
servicefield are gone.
Matching operations
| BrasilAPI | CNPJá | Notes |
|---|---|---|
GET / | Lookup CNPJ | Tax regime, Simples Nacional and MEI require expand=company.. See CNPJ lookup. |
GET / | Lookup CEP | See CEP and addresses. |
GET / | Lookup CEP | No coordinates or time zone. |
GET / | Lookup CEP | No coordinates. To find CEPs by their first digits or by address, use search in Search CEP, with a key. |
BrasilAPI’s other services, such as banks, exchange rates, holidays, FIPE, IBGE and the CVM registries, have no CNPJá equivalent and are out of scope for this guide.
The CNPJá API also offers operations with no BrasilAPI equivalent, such as Lookup company, which lists the establishments of a CNPJ root, Search CNPJ and Issue CNPJ dossier.
Request example
BrasilAPI:
GET /api/cnpj/v1/37335118000180 HTTP/1.1
Host: brasilapi.com.br CNPJá, with the tax regime:
GET /v2/establishments/37335118000180?expand=company.taxRegime HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY Parameters
| BrasilAPI | CNPJá | Notes |
|---|---|---|
cnpj in the path | taxId in the path | BrasilAPI accepts the CNPJ with or without punctuation. CNPJá requires 14 characters without punctuation, with uppercase letters and valid check digits; any other format is rejected with 400. |
cep in the path | code in the path | BrasilAPI accepts the CEP with or without a hyphen. CNPJá validates only the length: send the 8 digits without a hyphen and with leading zeros. 01310-930 is rejected with 400. |
| No equivalent | maxAge | Maximum data age in Lookup CNPJ, from 5m to 1y, default 45d. See Max age and partial success. |
| No equivalent | expand=company. | Needed for the Simples Nacional, MEI and tax regime fields. |
| No equivalent | expand=stateRegistry, expand=suframa | State and SUFRAMA registrations. See State registrations and SUFRAMA. |
| No equivalent | expand=address. | Latitude and longitude of the establishment. See Location and maps. |
maxAge and expand require an API key: a request without a key and with any query parameter is rejected with 401 API_.
Response fields
Paths with [] mean each item of a list. For the Simples Nacional, MEI and tax regime fields, the CNPJá column applies only with expand=company..
Identification and status
| BrasilAPI | CNPJá | Notes |
|---|---|---|
cnpj | taxId | |
identificador_ | type. | 1 becomes HEAD and 2 becomes BRANCH. |
descricao_ | type. | Matriz or Filial. |
nome_ | tradeName | null when there is no trade name. |
data_ | incorporationDate | |
situacao_ | status. | 1 becomes VOID, 2 becomes ACTIVE, 3 becomes SUSPENDED, 4 becomes NONCOMPLIANT and 8 becomes CLOSED. |
descricao_ | status. | Such as Ativa. |
data_ | statusDate | |
motivo_ | statusReason. | A number in BrasilAPI, 2-character text in CNPJá. statusReason appears only when the establishment isn’t active. |
descricao_ | statusReason. | |
situacao_ | specialStatus. | specialStatus. carries the 3-character code. Absent when there is no special status. |
data_ | specialStatusDate | Absent when there is no special status. |
| No equivalent | updatedAt | Last update from the Receita Federal. |
Address and contacts
| BrasilAPI | CNPJá | Notes |
|---|---|---|
descricao_, logradouro | address. | CNPJá has no separate field for the street type. In the Reference example, street is Avenida Brigadeiro Faria Lima. |
numero | address. | |
complemento | address. | |
bairro | address. | |
municipio | address. | |
codigo_ | address. | A number in BrasilAPI, 7-digit text in CNPJá. |
codigo_ | No equivalent | CNPJá identifies the municipality by its name, in address., and its IBGE code. |
uf | address. | |
cep | address. | |
codigo_ | address. | A numeric code in BrasilAPI, a 2-letter country code in CNPJá, such as BR. |
pais | address. | |
nome_ | No equivalent | |
ddd_, ddd_ | phones[]. | Area code and number become E.164, such as +5511971564144. phones[]. is LANDLINE or MOBILE. |
ddd_ | No equivalent | |
email | emails[]. | A string in BrasilAPI, a list in CNPJá. emails[]. carries the email type. |
Activities
| BrasilAPI | CNPJá | Notes |
|---|---|---|
cnae_ | primaryActivity. | A number in BrasilAPI, 7-digit text in CNPJá. |
cnae_ | primaryActivity. | |
cnaes_ | secondaryActivities[]. | 7-digit text. |
cnaes_ | secondaryActivities[]. |
Company and partners
| BrasilAPI | CNPJá | Notes |
|---|---|---|
razao_ | company. | |
capital_ | company. | An integer in BrasilAPI, a number with cents in CNPJá, such as 99999.. |
codigo_ | company. | A number in BrasilAPI, 4-digit text in CNPJá. |
natureza_ | company. | |
codigo_ | company. | 1 becomes MICRO, 3 becomes SMALL, and 0 (size not reported) and 5 become OTHER. |
porte | company. | |
ente_ | company. | company. holds BR for the União, the UF abbreviation or the IBGE municipality code. Absent outside public administration. |
qualificacao_ | No equivalent | |
qsa[] | company. | See Partners and people. |
qsa[]. | company. | 1 becomes ESTABLISHMENT, 2 becomes INDIVIDUAL and 3 becomes FOREIGNER. CNPJá also has UNKNOWN, a partner known only by name. |
qsa[]. | company. | |
qsa[]. | company. | Masked CPF or CNPJ. null for FOREIGNER and UNKNOWN. |
qsa[]. | company. | A number in BrasilAPI, 2-character text in CNPJá. |
qsa[]. | company. | |
qsa[]. | company. | |
qsa[]., qsa[]. | company. | Text with no label, such as 41-50. Present for individuals only. |
qsa[]. | company. | 2-letter country code. |
qsa[]. | company. | |
qsa[]. | company. | legalRepresentative appears only when the partner has a legal representative. |
qsa[]. | company. | |
qsa[]. | company. | 2-character text. |
qsa[]. | company. | |
| No equivalent | company. | Stable CNPJá person ID, used with Lookup person. |
Tax regime
| BrasilAPI | CNPJá | Notes |
|---|---|---|
opcao_ | company. | true matches SIMPLES_, SIMPLES_ or SIMPLES_. CNPJá always returns a regime, never null. |
data_ | company. | Start of the current Simples Nacional period. Present only when type. is SIMPLES_, SIMPLES_ or SIMPLES_, and may be null. |
data_ | company. | With company., in items whose type. is SIMPLES_. |
opcao_ | company. | true matches SIMPLES_. |
data_ | company. | Start of the current SIMEI period. Present only when type. is SIMPLES_, and may be null. |
data_ | company. | With company., in items whose type. is SIMEI_. |
regime_ | company. | With company., the regime history returns one item per period: ACTUAL_, PRESUMED_ or ARBITRATED_ for the years declared in the ECF, SIMPLES_ and SIMEI_ for Simples Nacional and SIMEI periods, and REGULAR_ and REGULAR_ for IBS and CBS regular regime periods. The current regime is in company.: ACTUAL_, PRESUMED_, ARBITRATED_, SIMPLES_, SIMPLES_, SIMPLES_ or NOT_. See Regime history. |
regime_ | company., company. | With company.. Each year declared in the ECF becomes a period from January 1 to December 31; the year is that of startDate. |
regime_ | No equivalent | |
regime_ | No equivalent |
SIMPLES_ identifies Simples Nacional optants that also opt into the IBS or CBS regular regime. For them, company. also returns company. and company., 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.
The regime rules, including when the regime is estimated, are in Tax regime.
CEP
| BrasilAPI | CNPJá | Notes |
|---|---|---|
cep | code | |
state | state | |
city | city | |
neighborhood | district | |
street | street | |
ibge. | municipality | |
ibge. | No equivalent | CNPJá returns only the UF abbreviation. |
service | No equivalent | CNPJá uses only the Correios DNE, and updatedAt gives the last update. |
location., location. | No equivalent | Coordinates exist only for establishments, with expand=address.. |
location. | No equivalent | |
timezoneName | No equivalent | |
| No equivalent | type, status, name, number, details | CEP type and status, and recipient data. See CEP and addresses. |
Formats
- Codes become text: CNAE, legal nature, role, status reason and IBGE code arrive as fixed-length text, never as numbers.
- Classified fields carry
codeandlabel. Usecodein your logic;labelis for display only, follows the response language and may change without notice. - Values with no record come as
null, and lists with no items come empty. Resources not requested inexpandare absent. - Fields that the BrasilAPI example shows as empty text, such as
ddd_andtelefone_ 2 situacao_, become fewer list items,especial nullor an absent field in CNPJá, as shown in the tables above.
See Response format.
Behavior differences
Freshness and caching
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 CEP doesn’t accept maxAge and serves cached data only. See Max age and partial success.
Partial success
When a live query fails or runs past its time limit, 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.
Errors
BrasilAPI returns errors with name, message and type, and CEP errors may add errors, with the details of each failure, such as one item per provider queried. In CNPJá, 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.
| BrasilAPI | CNPJá |
|---|---|
400 BadRequestError on CNPJ or CepPromiseError on CEP | 400 REQUEST_ |
404 NotFoundError on CNPJ | 404 ESTABLISHMENT_ |
404 CepPromiseError on CEP | 404 POSTAL_ |
503 ServiceUnavailableError on CNPJ, when the source fails or takes over 5 seconds | 206 with the cached data, or 500 or 504 without it, as explained under partial success above |
500, with type set to internal_ | 500 UNEXPECTED_ |
CNPJá also has 401 for a missing or invalid key, 402 for a used-up quota or overage budget, 429 for exceeded limits and 504 for a request that runs past its time limit.
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. 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.
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, 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; 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. In Lookup CNPJ, the registration and company. count separately. A 404 is billed too, as detailed in What is charged even without a useful result. Responses carry no cost headers: track usage under Usage. See Queries and quota, what each operation consumes in the Metering Rules and 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.
No equivalent
- CEP coordinates, geometry type and time zone.
- The Receita Federal municipality code (
codigo_), the IBGE UF code and the city name abroad.municipio - Fax number (
ddd_).fax - Role of the responsible person (
qualificacao_).do_ responsavel - SCP CNPJ and bookkeeping count from
regime_.tributario
Step by step
- Create the account and the API key, and store the key in an environment variable.
- Change the base URL to
https:/and the paths as shown in the matching operations table./ api. cnpja. com/ v2 - Send the key in
Authorization, withoutBearer. - Strip punctuation from the CNPJ and CEP, keep leading zeros and use uppercase letters in the CNPJ.
- Add
expand=company.wherever you use Simples Nacional, MEI or tax regime data.taxRegime - Rewrite field reading with the tables above, converting numeric codes into
code. - Handle errors by
code, treat206as success and set a client timeout above a request’s maximum duration, given in Timeout and size. - Validate the integration with a key and check consumption in Requests. Lookup CNPJ and Lookup CEP also work without a key when the URL has no query parameters, as explained in Public access.
- Switch traffic and watch errors and consumption over the first few days.
Sources for this comparison
What this page says about BrasilAPI comes from its public documentation:
- BrasilAPI documentation: the CNPJ and CEP operations, the response fields and the errors.
- BrasilAPI repository: the code and the sources of each operation.
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).