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., 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.becomescnpja. com/ office/ :taxId api., andcnpja. com/ v2/ establishments/ :taxId open.becomescnpja. com/ zip/ :code 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
aliastotradeName,foundedtoincorporationDateandmemberstopartners. - Codes as text: numeric codes, such as registration status and company size, become
codeandlabelpairs, withcodeas 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,
maxAgeor more volume, sign up, create a key in API keys and follow First request. - Authentication: 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:/./ 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á Open | CNPJá v2 | Notes |
|---|---|---|
Consulta CNPJ, GET / | Lookup CNPJ | Accepts public access. With a key, accepts maxAge and expand. See CNPJ lookup. |
Consulta CEP, GET / | Lookup CEP | Accepts 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á Open | CNPJá v2 | Notes |
|---|---|---|
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 response | v2 parameter |
|---|---|
company., company. | expand=company. |
company., company. | expand=company. with company. |
suframa | expand=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á Open | CNPJá v2 | Notes |
|---|---|---|
taxId | taxId | |
updated | updatedAt | Last update from the Receita Federal. |
alias | tradeName | Can be null. |
founded | incorporationDate | |
head | type. | true becomes HEAD, false becomes BRANCH. |
statusDate | statusDate | |
status. | status. | Number becomes a text code. See the code table. |
status. | status. | |
reason. | statusReason. | 2-character text with a leading zero: 1 becomes 01. |
reason. | statusReason. | |
specialDate | specialStatusDate | |
special. | specialStatus. | 3-character text. |
special. | specialStatus. |
Address and contacts
| CNPJá Open | CNPJá v2 | Notes |
|---|---|---|
address. | address. | Can be null. |
address. | address. | Can be null. |
address. | address. | Can be null. |
address. | address. | Can be null. |
address. | address. | |
address. | address. | UF abbreviation. |
address. | address. | |
address. | address. | Number becomes 7-character text: 3550308 becomes "3550308". |
address. | address. | Numeric M49 code becomes alpha-2: 76 becomes BR. |
address. | address. | |
phones[]. | phones[]. | Same LANDLINE and MOBILE codes. |
phones[]. and phones[]. | phones[]. | A single E.164 field, such as +5511971564144. The area code (DDD) is the 2 digits after +55. |
emails[]. | emails[]. | v2 also uses ACADEMIC and GOVERNMENT, which CNPJá Open returned as CORPORATE. |
emails[]. | emails[]. | |
emails[]. | No equivalent | Take it from the address, after the @. |
Activities
| CNPJá Open | CNPJá v2 | Notes |
|---|---|---|
mainActivity. | primaryActivity. | Number becomes 7-character text with leading zeros. |
mainActivity. | primaryActivity. | |
sideActivities[]. | secondaryActivities[]. | Same rule as primaryActivity.. |
sideActivities[]. | secondaryActivities[]. |
Company and partners
| CNPJá Open | CNPJá v2 | Notes |
|---|---|---|
company. | company. | |
company. | company. | |
company. | company. | |
company. | company. | company. holds BR for the União, the UF abbreviation, or the municipality’s IBGE code. |
company. | company. | Number becomes 4-character text: 2062 becomes "2062". |
company. | company. | |
company. | company. | See the code table. |
company. | No equivalent | Derive it from company.. |
company. | company. | |
company. | company. | Always present. |
company. | company. | Can be null. |
company. | company. | 2-character text: 49 becomes "49". |
company. | company. | |
company. | company. | UUID, 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_, look up the CNPJ again to get the current one. |
company. | company. | See the code table. |
company. | company. | |
company. | company. | Masked CPF, such as ***650245**, or CNPJ. null for FOREIGNER and UNKNOWN. |
company. | company. | Same ranges, such as 31-40. |
company. | company. | Numeric M49 becomes alpha-2. On CNPJá Open, country comes only for FOREIGN. In v2, the country comes for every person type. |
company. | company. | |
company. | company. | Same shape as person. |
company. | company. | id 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á Open | CNPJá v2 | Notes |
|---|---|---|
company. | company. | Optant when the code is SIMPLES_, SIMPLES_ or SIMPLES_. Requires expand=company.. |
company. | company. | Start of the current period. Present only for Simples Nacional optants, with the code SIMPLES_, SIMPLES_ or SIMPLES_. Can be null. |
company. | company. with type. SIMPLES_ | Requires company.. |
company. | company. | Optant when the code is SIMPLES_. |
company. | company. | Start of the current period. Present only with the code SIMPLES_. Can be null. |
company. | company. with type. SIMEI_ | Requires company.. |
history[]. | timeline[]. | |
history[]. | timeline[]. | Can be null. |
history[]. | timeline[]. | Can be null. |
suframa[] | suframa. | Requires expand=suframa. |
suframa[]. | suframa. | |
suframa[]. | suframa. | |
suframa[]. | suframa. | |
suframa[]. | suframa. | Can be null. |
suframa[]. | suframa. | See the code table. |
suframa[]. | suframa. | |
suframa[]. | Official Mapa dos Incentivos Fiscais spreadsheet | SUFRAMA 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_. With company., company. and company. 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..
CEP
The v2 column paths are from Lookup CEP.
| CNPJá Open | CNPJá v2 | Notes |
|---|---|---|
updated | updatedAt | Last update from Correios (DNE). |
code | code | |
street | street | Can be null. |
number | number | Can be null. |
district | district | Can be null. |
city | city | |
state | state | |
municipality | municipality | Number 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 field | Open value | v2 code |
|---|---|---|
status. | 1 Nula | VOID |
status. | 2 Ativa | ACTIVE |
status. | 3 Suspensa | SUSPENDED |
status. | 4 Inapta | NONCOMPLIANT |
status. | 8 Baixada | CLOSED |
company. | 1 ME | MICRO |
company. | 3 EPP | SMALL |
company. | 5 Demais | OTHER |
person. | LEGAL | ESTABLISHMENT |
person. | NATURAL | INDIVIDUAL |
person. | FOREIGN | FOREIGNER |
person. | UNKNOWN | UNKNOWN |
suframa[]. | 1 Ativa | ACTIVE |
suframa[]. | 2 Inativa | INACTIVE |
suframa[]. | 3 Bloqueada | BLOCKED |
suframa[]. | 4 Cancelada | CANCELLED |
suframa[]. | 5 Cancelada Ag. Rec. | No equivalent |
Important: v2 codes are text and can have leading zeros, such as
01instatusReason.andcode 0111301in 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_ or 404 POSTAL_. 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_, returnssource=site 401API_.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. 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.: derive it fromsize. acronym company..size. code emails[].: take it from the email address.domain - A separate
phones[].: the area code is insidearea phones[]., in E.164.number - Numeric M49 country codes in
address.andcountry. id person.: v2 uses alpha-2.country. id - SUFRAMA status
5Cancelada Ag. Rec.: v2 has onlyACTIVE,INACTIVE,BLOCKEDandCANCELLED.
Step by step
- List the places in your system that call
open.and the fields each one reads.cnpja. com - 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. - If you use a key, sign up, create the key in API keys and send it in
Authorization, with no prefix. - Change the host to
api.and the paths tocnpja. com /v2/andestablishments/ :taxId /v2/. Without a key, send no query parameters.postal-codes/ :code - Adapt field parsing following the tables above, including text codes, E.164 phones and alpha-2 countries.
- Treat
206as success, handle errors bycode, and retry429,500and504after a wait. - Test with a few CNPJs and CEPs, with or without a key, and compare the results with CNPJá Open.
- 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.