Skip to content
Migrate from BrasilAPI
API · Migration

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 company and the address under address, and returns phones, emails and partners as lists of objects.
  • Numeric codes, such as situacao_cadastral and codigo_porte, become objects with code and label, where code is a stable text value, such as ACTIVE.
  • The Simples Nacional and MEI options and the tax regime leave the default response and are requested with expand=company.taxRegime, which needs an API key.
  • 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, and maxAge sets the maximum accepted data age.
  • Errors carry status and a stable code instead of name and type.

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 Authorization header, with no prefix: Authorization: YOUR_API_KEY. With Bearer, the request is rejected with 401 API_KEY_INVALID. See Authentication.
  • Base URL: https://api.cnpja.com/v2, instead of 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 in YYYY-MM-DD format.
  • 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 service field are gone.

Matching operations

BrasilAPICNPJáNotes
GET /cnpj/v1/{cnpj}Lookup CNPJTax regime, Simples Nacional and MEI require expand=company.taxRegime. See CNPJ lookup.
GET /cep/v1/{cep}Lookup CEPSee CEP and addresses.
GET /cep/v2/{cep}Lookup CEPNo coordinates or time zone.
GET /cep/v3/{cep}Lookup CEPNo 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

BrasilAPICNPJáNotes
cnpj in the pathtaxId in the pathBrasilAPI 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 pathcode in the pathBrasilAPI 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 equivalentmaxAgeMaximum data age in Lookup CNPJ, from 5m to 1y, default 45d. See Max age and partial success.
No equivalentexpand=company.taxRegimeNeeded for the Simples Nacional, MEI and tax regime fields.
No equivalentexpand=stateRegistry, expand=suframaState and SUFRAMA registrations. See State registrations and SUFRAMA.
No equivalentexpand=address.coordinatesLatitude 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_KEY_MISSING.

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

Identification and status

BrasilAPICNPJáNotes
cnpjtaxId
identificador_matriz_filialtype.code1 becomes HEAD and 2 becomes BRANCH.
descricao_identificador_matriz_filialtype.labelMatriz or Filial.
nome_fantasiatradeNamenull when there is no trade name.
data_inicio_atividadeincorporationDate
situacao_cadastralstatus.code1 becomes VOID, 2 becomes ACTIVE, 3 becomes SUSPENDED, 4 becomes NONCOMPLIANT and 8 becomes CLOSED.
descricao_situacao_cadastralstatus.labelSuch as Ativa.
data_situacao_cadastralstatusDate
motivo_situacao_cadastralstatusReason.codeA number in BrasilAPI, 2-character text in CNPJá. statusReason appears only when the establishment isn’t active.
descricao_motivo_situacao_cadastralstatusReason.label
situacao_especialspecialStatus.labelspecialStatus.code carries the 3-character code. Absent when there is no special status.
data_situacao_especialspecialStatusDateAbsent when there is no special status.
No equivalentupdatedAtLast update from the Receita Federal.

Address and contacts

BrasilAPICNPJáNotes
descricao_tipo_de_logradouro, logradouroaddress.streetCNPJá has no separate field for the street type. In the Reference example, street is Avenida Brigadeiro Faria Lima.
numeroaddress.number
complementoaddress.details
bairroaddress.district
municipioaddress.city
codigo_municipio_ibgeaddress.municipalityA number in BrasilAPI, 7-digit text in CNPJá.
codigo_municipioNo equivalentCNPJá identifies the municipality by its name, in address.city, and its IBGE code.
ufaddress.state
cepaddress.postalCode
codigo_paisaddress.country.codeA numeric code in BrasilAPI, a 2-letter country code in CNPJá, such as BR.
paisaddress.country.label
nome_cidade_no_exteriorNo equivalent
ddd_telefone_1, ddd_telefone_2phones[].numberArea code and number become E.164, such as +5511971564144. phones[].type.code is LANDLINE or MOBILE.
ddd_faxNo equivalent
emailemails[].addressA string in BrasilAPI, a list in CNPJá. emails[].type.code carries the email type.

Activities

BrasilAPICNPJáNotes
cnae_fiscalprimaryActivity.codeA number in BrasilAPI, 7-digit text in CNPJá.
cnae_fiscal_descricaoprimaryActivity.label
cnaes_secundarios[].codigosecondaryActivities[].code7-digit text.
cnaes_secundarios[].descricaosecondaryActivities[].label

Company and partners

BrasilAPICNPJáNotes
razao_socialcompany.legalName
capital_socialcompany.shareCapitalAn integer in BrasilAPI, a number with cents in CNPJá, such as 99999.99.
codigo_natureza_juridicacompany.legalNature.codeA number in BrasilAPI, 4-digit text in CNPJá.
natureza_juridicacompany.legalNature.label
codigo_portecompany.size.code1 becomes MICRO, 3 becomes SMALL, and 0 (size not reported) and 5 become OTHER.
portecompany.size.label
ente_federativo_responsavelcompany.federativeEntity.labelcompany.federativeEntity.code holds BR for the União, the UF abbreviation or the IBGE municipality code. Absent outside public administration.
qualificacao_do_responsavelNo equivalent
qsa[]company.partners[]See Partners and people.
qsa[].identificador_de_sociocompany.partners[].person.type.code1 becomes ESTABLISHMENT, 2 becomes INDIVIDUAL and 3 becomes FOREIGNER. CNPJá also has UNKNOWN, a partner known only by name.
qsa[].nome_sociocompany.partners[].person.legalName
qsa[].cnpj_cpf_do_sociocompany.partners[].person.taxIdMasked CPF or CNPJ. null for FOREIGNER and UNKNOWN.
qsa[].codigo_qualificacao_sociocompany.partners[].role.codeA number in BrasilAPI, 2-character text in CNPJá.
qsa[].qualificacao_sociocompany.partners[].role.label
qsa[].data_entrada_sociedadecompany.partners[].admissionDate
qsa[].codigo_faixa_etaria, qsa[].faixa_etariacompany.partners[].person.ageGroupText with no label, such as 41-50. Present for individuals only.
qsa[].codigo_paiscompany.partners[].person.domicileCountry.code2-letter country code.
qsa[].paiscompany.partners[].person.domicileCountry.label
qsa[].cpf_representante_legalcompany.partners[].legalRepresentative.person.taxIdlegalRepresentative appears only when the partner has a legal representative.
qsa[].nome_representante_legalcompany.partners[].legalRepresentative.person.legalName
qsa[].codigo_qualificacao_representante_legalcompany.partners[].legalRepresentative.role.code2-character text.
qsa[].qualificacao_representante_legalcompany.partners[].legalRepresentative.role.label
No equivalentcompany.partners[].person.idStable CNPJá person ID, used with Lookup person.

Tax regime

BrasilAPICNPJáNotes
opcao_pelo_simplescompany.taxRegime.type.codetrue matches SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI. CNPJá always returns a regime, never null.
data_opcao_pelo_simplescompany.taxRegime.simplesNacionalStartDateStart 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.
data_exclusao_do_simplescompany.taxRegime.timeline[].endDateWith company.taxRegime.view=DETAILED, in items whose type.code is SIMPLES_NACIONAL_PERIOD.
opcao_pelo_meicompany.taxRegime.type.codetrue matches SIMPLES_NACIONAL_SIMEI.
data_opcao_pelo_meicompany.taxRegime.simeiStartDateStart of the current SIMEI period. Present only when type.code is SIMPLES_NACIONAL_SIMEI, and may be null.
data_exclusao_do_meicompany.taxRegime.timeline[].endDateWith company.taxRegime.view=DETAILED, in items whose type.code is SIMEI_PERIOD.
regime_tributario[].forma_de_tributacaocompany.taxRegime.timeline[].type.codeWith company.taxRegime.view=DETAILED, the regime history returns one item per period: ACTUAL_PROFIT_PERIOD, PRESUMED_PROFIT_PERIOD or ARBITRATED_PROFIT_PERIOD for the years declared in the ECF, SIMPLES_NACIONAL_PERIOD and SIMEI_PERIOD for Simples Nacional and SIMEI periods, and REGULAR_IBS_PERIOD and REGULAR_CBS_PERIOD for IBS and CBS regular regime periods. 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. See Regime history.
regime_tributario[].anocompany.taxRegime.timeline[].startDate, company.taxRegime.timeline[].endDateWith company.taxRegime.view=DETAILED. Each year declared in the ECF becomes a period from January 1 to December 31; the year is that of startDate.
regime_tributario[].cnpj_da_scpNo equivalent
regime_tributario[].quantidade_de_escrituracoesNo equivalent

SIMPLES_NACIONAL_HYBRID identifies Simples Nacional optants that also opt into the IBS or CBS regular regime. For them, 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.

The regime rules, including when the regime is estimated, are in Tax regime.

CEP

BrasilAPICNPJáNotes
cepcode
statestate
citycity
neighborhooddistrict
streetstreet
ibge.citymunicipality
ibge.stateNo equivalentCNPJá returns only the UF abbreviation.
serviceNo equivalentCNPJá uses only the Correios DNE, and updatedAt gives the last update.
location.coordinates.latitude, location.coordinates.longitudeNo equivalentCoordinates exist only for establishments, with expand=address.coordinates.
location.typeNo equivalent
timezoneNameNo equivalent
No equivalenttype, status, name, number, detailsCEP 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 code and label. Use code in your logic; label is 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 in expand are absent.
  • Fields that the BrasilAPI example shows as empty text, such as ddd_telefone_2 and situacao_especial, become fewer list items, null or 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.

BrasilAPICNPJá
400 BadRequestError on CNPJ or CepPromiseError on CEP400 REQUEST_VALIDATION_FAILED
404 NotFoundError on CNPJ404 ESTABLISHMENT_NOT_FOUND
404 CepPromiseError on CEP404 POSTAL_CODE_NOT_FOUND
503 ServiceUnavailableError on CNPJ, when the source fails or takes over 5 seconds206 with the cached data, or 500 or 504 without it, as explained under partial success above
500, with type set to internal_error500 UNEXPECTED_ERROR

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.taxRegime 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_municipio), the IBGE UF code and the city name abroad.
  • Fax number (ddd_fax).
  • Role of the responsible person (qualificacao_do_responsavel).
  • SCP CNPJ and bookkeeping count from regime_tributario.

Step by step

  1. Create the account and the API key, and store the key in an environment variable.
  2. Change the base URL to https://api.cnpja.com/v2 and the paths as shown in the matching operations table.
  3. Send the key in Authorization, without Bearer.
  4. Strip punctuation from the CNPJ and CEP, keep leading zeros and use uppercase letters in the CNPJ.
  5. Add expand=company.taxRegime wherever you use Simples Nacional, MEI or tax regime data.
  6. Rewrite field reading with the tables above, converting numeric codes into code.
  7. Handle errors by code, treat 206 as success and set a client timeout above a request’s maximum duration, given in Timeout and size.
  8. 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.
  9. 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).

Informational content that may change without notice. It is not tax, accounting or legal advice, and CNPJá's terms and policies prevail over this page.