Skip to content
Migrate from CNPJá Open to v2
API · Migration

Migrate from CNPJá Open to v2

How to move CNPJá Open's Consulta CNPJ and Consulta CEP to v2, with or without an API key: new paths, renamed fields and codes as text.

CNPJá Open is the public API at open.cnpja.com, with Consulta CNPJ and Consulta CEP and no authentication. v2 keeps both lookups available without a key, through public access, and opens the rest of the API with a key.

Overview

  • Host and paths: open.cnpja.com/office/:taxId becomes api.cnpja.com/v2/establishments/:taxId, and open.cnpja.com/zip/:code becomes api.cnpja.com/v2/postal-codes/:code.
  • Still possible without a key: Lookup CNPJ and Lookup CEP accept public requests, with no query parameters and no billing.
  • Higher limits: CNPJá Open allows 5 queries per minute per IP. v2 public access limits requests per second and concurrent requests, also per IP, and, with a key, the limits belong to the organization and grow with its plan, as shown in Usage limits.
  • Renamed fields: names change, such as alias to tradeName, founded to incorporationDate and members to partners.
  • Codes as text: numeric codes, such as registration status and company size, become code and label pairs, with code as text.
  • Optional resources need a key: Simples Nacional, MEI and SUFRAMA only come back in v2 with a key and expand.

Effort: low to medium. Switching the URL is simple, and most of the work is adapting field parsing, following the mapping tables below.

Prerequisites

  • Public access: if you only use the fields v2 returns without a key, you don’t need an account. Just change the URL. See Public access.
  • Account and key: for Simples Nacional, MEI, SUFRAMA, maxAge or more volume, sign up, create a key in API keys and follow 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.
  • Base URL: https://api.cnpja.com/v2.
  • What carries over: CNPJ and CEP without punctuation, dates as YYYY-MM-DD, date-times in ISO 8601 and the partners’ masked CPF.
  • What changes: host, paths, field names, numeric codes, countries as numeric M49, limits and the error format.

Matching operations

CNPJá OpenCNPJá v2Notes
Consulta CNPJ, GET /office/:taxIdLookup CNPJAccepts public access. With a key, accepts maxAge and expand. See CNPJ lookup.
Consulta CEP, GET /zip/:codeLookup CEPAccepts public access. The response is the same with or without a key. See CEP and addresses.

Request example

CNPJá Open:

GET /office/37335118000180 HTTP/1.1
Host: open.cnpja.com

CNPJá v2, with public access:

GET /v2/establishments/37335118000180 HTTP/1.1
Host: api.cnpja.com

CNPJá v2, with a key and the resources that match simples, simei and suframa:

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

Parameters

CNPJá OpenCNPJá v2Notes
taxId (path)taxId (path)14 characters without punctuation. v2 accepts uppercase letters in alphanumeric CNPJs.
code (path)code (path)8 digits without a hyphen, keeping leading zeros.

CNPJá Open has no query parameters. In v2, the parameters below bring back parts of the Open response and require a key:

Part of the Open responsev2 parameter
company.simples, company.simeiexpand=company.taxRegime
company.simples.history, company.simei.historyexpand=company.taxRegime with company.taxRegime.view=DETAILED
suframaexpand=suframa

With a key, maxAge sets the maximum age of the data, from 5m to 1y, with a 45d default. See Max age and partial success.

Response fields

The v2 column paths are from Lookup CNPJ, except in the CEP section.

Identification and status

CNPJá OpenCNPJá v2Notes
taxIdtaxId
updatedupdatedAtLast update from the Receita Federal.
aliastradeNameCan be null.
foundedincorporationDate
headtype.codetrue becomes HEAD, false becomes BRANCH.
statusDatestatusDate
status.idstatus.codeNumber becomes a text code. See the code table.
status.textstatus.label
reason.idstatusReason.code2-character text with a leading zero: 1 becomes 01.
reason.textstatusReason.label
specialDatespecialStatusDate
special.idspecialStatus.code3-character text.
special.textspecialStatus.label

Address and contacts

CNPJá OpenCNPJá v2Notes
address.streetaddress.streetCan be null.
address.numberaddress.numberCan be null.
address.detailsaddress.detailsCan be null.
address.districtaddress.districtCan be null.
address.cityaddress.city
address.stateaddress.stateUF abbreviation.
address.zipaddress.postalCode
address.municipalityaddress.municipalityNumber becomes 7-character text: 3550308 becomes "3550308".
address.country.idaddress.country.codeNumeric M49 code becomes alpha-2: 76 becomes BR.
address.country.nameaddress.country.label
phones[].typephones[].type.codeSame LANDLINE and MOBILE codes.
phones[].area and phones[].numberphones[].numberA single E.164 field, such as +5511971564144. The area code (DDD) is the 2 digits after +55.
emails[].ownershipemails[].type.codev2 also uses ACADEMIC and GOVERNMENT, which CNPJá Open returned as CORPORATE.
emails[].addressemails[].address
emails[].domainNo equivalentTake it from the address, after the @.

Activities

CNPJá OpenCNPJá v2Notes
mainActivity.idprimaryActivity.codeNumber becomes 7-character text with leading zeros.
mainActivity.textprimaryActivity.label
sideActivities[].idsecondaryActivities[].codeSame rule as primaryActivity.code.
sideActivities[].textsecondaryActivities[].label

Company and partners

CNPJá OpenCNPJá v2Notes
company.idcompany.id
company.namecompany.legalName
company.equitycompany.shareCapital
company.jurisdictioncompany.federativeEntity.labelcompany.federativeEntity.code holds BR for the União, the UF abbreviation, or the municipality’s IBGE code.
company.nature.idcompany.legalNature.codeNumber becomes 4-character text: 2062 becomes "2062".
company.nature.textcompany.legalNature.label
company.size.idcompany.size.codeSee the code table.
company.size.acronymNo equivalentDerive it from company.size.code.
company.size.textcompany.size.label
company.members[]company.partners[]Always present.
company.members[].sincecompany.partners[].admissionDateCan be null.
company.members[].role.idcompany.partners[].role.code2-character text: 49 becomes "49".
company.members[].role.textcompany.partners[].role.label
company.members[].person.idcompany.partners[].person.idUUID, the same value as in v2. Use it with Lookup person, with a key. If an id stored a while ago gets a 404 PERSON_NOT_FOUND, look up the CNPJ again to get the current one.
company.members[].person.typecompany.partners[].person.type.codeSee the code table.
company.members[].person.namecompany.partners[].person.legalName
company.members[].person.taxIdcompany.partners[].person.taxIdMasked CPF, such as ***650245**, or CNPJ. null for FOREIGNER and UNKNOWN.
company.members[].person.agecompany.partners[].person.ageGroupSame ranges, such as 31-40.
company.members[].person.country.idcompany.partners[].person.domicileCountry.codeNumeric M49 becomes alpha-2. On CNPJá Open, country comes only for FOREIGN. In v2, the country comes for every person type.
company.members[].person.country.namecompany.partners[].person.domicileCountry.label
company.members[].agent.personcompany.partners[].legalRepresentative.personSame shape as person.
company.members[].agent.rolecompany.partners[].legalRepresentative.roleid and text become code and label.

More on partners in Partners and people.

Tax regime and SUFRAMA

These fields require a key and expand. See Tax regime and SUFRAMA.

CNPJá OpenCNPJá v2Notes
company.simples.optantcompany.taxRegime.type.codeOptant when the code is SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI. Requires expand=company.taxRegime.
company.simples.sincecompany.taxRegime.simplesNacionalStartDateStart of the current period. Present only for Simples Nacional optants, with the code SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI. Can be null.
company.simples.history[]company.taxRegime.timeline[] with type.code SIMPLES_NACIONAL_PERIODRequires company.taxRegime.view=DETAILED.
company.simei.optantcompany.taxRegime.type.codeOptant when the code is SIMPLES_NACIONAL_SIMEI.
company.simei.sincecompany.taxRegime.simeiStartDateStart of the current period. Present only with the code SIMPLES_NACIONAL_SIMEI. Can be null.
company.simei.history[]company.taxRegime.timeline[] with type.code SIMEI_PERIODRequires company.taxRegime.view=DETAILED.
history[].fromtimeline[].startDate
history[].untiltimeline[].endDateCan be null.
history[].texttimeline[].detailsCan be null.
suframa[]suframa.registrations[]Requires expand=suframa.
suframa[].numbersuframa.registrations[].number
suframa[].sincesuframa.registrations[].registrationDate
suframa[].approvedsuframa.registrations[].hasApprovedProject
suframa[].approvalDatesuframa.registrations[].approvalDateCan be null.
suframa[].status.idsuframa.registrations[].status.codeSee the code table.
suframa[].status.textsuframa.registrations[].status.label
suframa[].incentives[]Official Mapa dos Incentivos Fiscais spreadsheetSUFRAMA no longer publishes the incentives in its registry lookup and directs users to this spreadsheet, so the API does not return them. The criteria it applied are in Estimate incentives.

Simples Nacional optants that also opted into the IBS or CBS regular regime have the code SIMPLES_NACIONAL_HYBRID. With company.taxRegime.view=DETAILED, company.taxRegime.regularIbsStartDate and company.taxRegime.regularCbsStartDate hold the start of their current period in each regular regime, and either can be null. The v2 timeline also holds future events and periods of other regimes, so filter by type.code.

CEP

The v2 column paths are from Lookup CEP.

CNPJá OpenCNPJá v2Notes
updatedupdatedAtLast update from Correios (DNE).
codecode
streetstreetCan be null.
numbernumberCan be null.
districtdistrictCan be null.
citycity
statestate
municipalitymunicipalityNumber becomes 7-character text.

v2 also returns type, status, name and details. The CEP type defines which fields are filled: for a locality CEP, only city, state and municipality. See CEP and addresses.

Code table

Open fieldOpen valuev2 code
status.id1 NulaVOID
status.id2 AtivaACTIVE
status.id3 SuspensaSUSPENDED
status.id4 InaptaNONCOMPLIANT
status.id8 BaixadaCLOSED
company.size.id1 MEMICRO
company.size.id3 EPPSMALL
company.size.id5 DemaisOTHER
person.typeLEGALESTABLISHMENT
person.typeNATURALINDIVIDUAL
person.typeFOREIGNFOREIGNER
person.typeUNKNOWNUNKNOWN
suframa[].status.id1 AtivaACTIVE
suframa[].status.id2 InativaINACTIVE
suframa[].status.id3 BloqueadaBLOCKED
suframa[].status.id4 CanceladaCANCELLED
suframa[].status.id5 Cancelada Ag. Rec.No equivalent

Important: v2 codes are text and can have leading zeros, such as 01 in statusReason.code and 0111301 in a CNAE. Compare them as text, without converting to numbers.

Behavior differences

Freshness and caching

CNPJá Open states CNPJ data is updated within 45 days for active establishments. In v2, 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. Public access always uses the 45d default and does not run a live query for a CNPJ that is not cached yet, as explained in Public access; with a key, you choose maxAge. See Max age and partial success.

Partial success

Lookup CNPJ can return 206 on public access too. 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.

CEP

CNPJá Open states global CEP updates every 15 days. In v2, Lookup CEP serves cached data only and doesn’t accept maxAge, and updatedAt shows the last update from Correios.

Errors

The CNPJá Open spec documents only the 200 response. A CNPJ or CEP that doesn’t exist, for example, now returns 404 ESTABLISHMENT_NOT_FOUND or 404 POSTAL_CODE_NOT_FOUND. In v2, 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.

Limits

CNPJá Open allows 5 queries per minute per IP. 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 and with no Retry-After header. Each request has a maximum duration, and the client timeout must stay above it, as shown in Timeout and size.

Important: a request is public only when the URL has no query parameters at all. Any parameter, including ?utm_source=site, returns 401 API_KEY_MISSING.

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. With a key, in Lookup CNPJ, the registration, company.taxRegime and suframa count separately, and a CNPJ or CEP that doesn’t exist, with 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

  • company.size.acronym: derive it from company.size.code.
  • emails[].domain: take it from the email address.
  • A separate phones[].area: the area code is inside phones[].number, in E.164.
  • Numeric M49 country codes in address.country.id and person.country.id: v2 uses alpha-2.
  • SUFRAMA status 5 Cancelada Ag. Rec.: v2 has only ACTIVE, INACTIVE, BLOCKED and CANCELLED.

Step by step

  1. List the places in your system that call open.cnpja.com and the fields each one reads.
  2. Choose between public access and a key. Use a key if you need Simples Nacional, MEI, SUFRAMA, maxAge, limits that grow with the plan or other operations.
  3. If you use a key, sign up, create the key in API keys and send it in Authorization, with no prefix.
  4. Change the host to api.cnpja.com and the paths to /v2/establishments/:taxId and /v2/postal-codes/:code. Without a key, send no query parameters.
  5. Adapt field parsing following the tables above, including text codes, E.164 phones and alpha-2 countries.
  6. Treat 206 as success, handle errors by code, and retry 429, 500 and 504 after a wait.
  7. Test with a few CNPJs and CEPs, with or without a key, and compare the results with CNPJá Open.
  8. Switch traffic to v2. With a key, track consumption in Usage.

Tip: public access is a free courtesy, limited and revocable at any time, with no service level, as explained in Public access. Move to a key when a rejection by a limit isn’t acceptable.

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.