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

Migrate from CNPJá v1 to v2

How to replace each CNPJá API v1 operation with v2, using the same key: new paths, resources in expand, certificates in one PDF and cursor pagination.

The v1 API organizes lookups by source, with one operation for the Receita Federal, another for the Simples Nacional, another for the CCC and another for SUFRAMA, plus CNPJ lookup and search. In v2, a CNPJ’s data comes from Lookup CNPJ, with optional resources requested in expand, and the certificates come from a single operation. Every v2 detail is in the Reference.

Overview

  • Paths gain the /v2 prefix and new names: /office becomes /v2/establishments, /person becomes /v2/people and /zip becomes /v2/postal-codes, on the same host and with the same API key.
  • The standalone lookups /rfb, /simples, /ccc and /suframa become resources of Lookup CNPJ, or of Lookup CPF when the document is a CPF.
  • The boolean parameters simples, suframa and geocoding and the registrations list become expand values.
  • maxAge now takes a unit, such as 45d, and strategy, maxStale and sync are gone.
  • Fields are renamed: id and text become code and label, numeric codes become fixed-length strings, and booleans such as head become codes, such as HEAD.
  • The four certificates become a single PDF from Issue CNPJ dossier, or from Issue CPF dossier for a CPF, with the documents chosen in certificates.
  • Pagination replaces token, next and count with cursor, nextCursor and total.

Effort: medium. There is no new account, key or quota; the work is rewriting the calls and the field parsing, operation by operation.

Prerequisites

  • Account and key: v1 and v2 use the same API keys, from the same organization. If you don’t have one yet, see First request.
  • Authentication: same as v1. 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. v1 answers on the same host, without the version prefix.
  • What carries over: keys, organization, plan quotas and request limits. Both versions consume the same live and cached query quotas.
  • Existing data: the list, person and company IDs from v1 are valid in v2. Lists created in v1 are the same ones Search lists returns.
  • What changes: the paths, the parameters, the response format, the codes of classified values and how you track usage.

Matching operations

CNPJá v1CNPJá v2Notes
GET /office/{taxId}Lookup CNPJSee CNPJ lookup.
GET /officeSearch CNPJFilters renamed. See CNPJ search and lists.
GET /office/{taxId}/mapRender CNPJ mapSee Location and maps.
GET /office/{taxId}/streetRender CNPJ street viewThe path ends in street-view. v1 declared PNG; v2 returns a JPEG.
GET /company/{companyId}Lookup companySame CNPJ root, 8 characters.
GET /person/{personId}Lookup personSame ID. See Partners and people.
GET /personSearch people
GET /rfbLookup CNPJNo expand. The CNPJ goes in the path, not in the taxId parameter.
GET /rfb/certificateIssue CNPJ dossiercertificates=RFB_REGISTRATION,RFB_PARTNERS. See Certificates.
GET /simplesLookup CNPJexpand=company.taxRegime. See Tax regime.
GET /simples/certificateIssue CNPJ dossiercertificates=SIMPLES_NACIONAL_OPTION.
GET /ccc with a CNPJLookup CNPJexpand=stateRegistry and stateRegistry.states.
GET /ccc with a CPFLookup CPFexpand=stateRegistry and stateRegistry.states, required.
GET /ccc/certificateIssue CNPJ dossier or Issue CPF dossiercertificates=CCC_REGISTRATIONS.
GET /suframa with a CNPJLookup CNPJexpand=suframa.
GET /suframa with a CPFLookup CPFexpand=suframa.
GET /suframa/certificateIssue CNPJ dossier or Issue CPF dossiercertificates=SUFRAMA_REGISTRATION.
GET /zip/{code}Lookup CEPSee CEP and addresses.
POST /listCreate listtype and items become required.
GET /listSearch lists
GET /list/{listId}Lookup list
PATCH /list/{listId}Update list
DELETE /list/{listId}Delete list
POST /list/{listId}/export and the export lookupsNo equivalentAlready deprecated in v1. To read the CNPJs in a list, use Search CNPJ with lists.some.
GET /creditNo equivalentUsage is shown in the app, under Usage.

Request example

The main lookup, with Simples Nacional and state registrations.

CNPJá v1:

GET /office/37335118000180?simples=true&registrations=ORIGIN&maxAge=30 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY

CNPJá v2:

GET /v2/establishments/37335118000180?expand=company.taxRegime,stateRegistry&stateRegistry.states=ORIGIN&maxAge=30d HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY

Parameters

Lookup CNPJ

CNPJá v1CNPJá v2Notes
taxId (path)taxId (path)14-character CNPJ, without punctuation.
maxAgemaxAgeAn integer in days in v1, a string with a unit in v2: maxAge=45 becomes maxAge=45d. The default is still 45 days. v2 accepts 5m to 1y.
strategy=CACHE_IF_FRESH or CACHE_IF_ERRORmaxAgeThis is v2’s default behavior: cached data within maxAge, a live query beyond it, and 206 with the cached data if the live query fails.
strategy=ONLINEA small maxAgev1 itself suggested maxAge=1. In v2, the smallest value is 5m.
strategy=CACHENo equivalentLookup CNPJ always queries live the resources older than maxAge, which goes up to 1y.
maxStaleNo equivalentIn v2, the 206 response carries the cached data of the resource whose live query failed.
syncNo equivalentv2 has no cost headers.
simples=trueexpand=company.taxRegimeSimples Nacional and MEI opt-in, and the tax regime.
simplesHistory=trueexpand=company.taxRegime and company.taxRegime.view=DETAILEDThe history comes in company.taxRegime.timeline.
registrationsexpand=stateRegistry and stateRegistry.statesSame values: ORIGIN, ALL or UF abbreviations. stateRegistry.states defaults to ORIGIN.
registrationsSourceNo equivalentv2 uses the CCC only.
suframa=trueexpand=suframa
geocoding=trueexpand=address.coordinates
linksNo equivalentCall the certificate, map and street view operations directly, with a key.
No equivalentstateRegistry.view=DETAILEDActivity, address, sublimit and authorized tax documents of each registration. See State registrations.
No equivalentcompany.taxRegime.maxAge, stateRegistry.maxAge, suframa.maxAgeA separate age limit for each resource. See Max age and partial success.

Send multiple expand values comma-separated or by repeating the parameter. The rules are in Response expansion.

Standalone lookups and certificates

CNPJá v1CNPJá v2Notes
taxId (URL) in /rfb, /simples, /ccc, /suframa and the certificatestaxId (path)In v2, the document is part of the path. CNPJs go in /v2/establishments/ and CPFs in /v2/individuals/.
maxAge in /simplescompany.taxRegime.maxAgeWith a unit, such as 45d. Without it, maxAge applies.
history in /simplescompany.taxRegime.view=DETAILED
states in /cccstateRegistry.statesIn Lookup CPF, the parameter is required and accepts ALL or state abbreviations, with no ORIGIN.
maxAge in /cccstateRegistry.maxAgeWith a unit.
source in /cccNo equivalentv2 uses the CCC only.
maxAge in /suframasuframa.maxAgeWith a unit.
pages in /rfb/certificatecertificatesREGISTRATION becomes RFB_REGISTRATION and MEMBERS becomes RFB_PARTNERS. In v1 both pages were the default; in v2 certificates is required.
state in /ccc/certificateNo equivalentA CNPJ’s CCC certificate covers only the establishment’s own UF; a CPF’s covers a single UF with a known registration, which can’t be chosen.
type in /office/{taxId}/maptypeUppercase values: roadmap becomes ROADMAP, and likewise TERRAIN, SATELLITE and HYBRID.
width, height, scale, zoom and fovNo equivalentv2 images are 640 by 640 pixels, with fixed size and zoom.

Search CNPJ

CNPJá v1CNPJá v2Notes
tokencursorSent alone, with no other parameter.
limitlimit1 to 1000, default 10.
names.in, names.ninnames.some, names.noneLegal name or trade name.
company.name.in, company.name.nincompany.legalName.some, company.legalName.none
alias.in, alias.nintradeName.some, tradeName.none
company.equity.gte, company.equity.ltecompany.shareCapital.gte, company.shareCapital.lte
company.nature.id.in, company.nature.id.nincompany.legalNature.code.in, company.legalNature.code.nin4-character codes.
company.size.id.incompany.size.code.in1 becomes MICRO, 3 becomes SMALL and 5 becomes OTHER.
company.simples.optant.eq=truecompany.taxRegime.type.code.in=SIMPLES_NACIONAL,SIMPLES_NACIONAL_HYBRID,SIMPLES_NACIONAL_SIMEI
company.simples.optant.eq=falsecompany.taxRegime.type.code.in with the other regimesACTUAL_PROFIT, PRESUMED_PROFIT, ARBITRATED_PROFIT and NOT_APPLICABLE.
company.simples.since.gte, company.simples.since.ltecompany.taxRegime.simplesNacionalStartDate.gte, company.taxRegime.simplesNacionalStartDate.lte
company.simei.optant.eq=truecompany.taxRegime.type.code.in=SIMPLES_NACIONAL_SIMEI
company.simei.optant.eq=falsecompany.taxRegime.type.code.in with the other regimesACTUAL_PROFIT, PRESUMED_PROFIT, ARBITRATED_PROFIT, SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID and NOT_APPLICABLE.
company.simei.since.gte, company.simei.since.ltecompany.taxRegime.simeiStartDate.gte, company.taxRegime.simeiStartDate.lte
No equivalentcompany.taxRegime.regularIbsStartDate.gte, company.taxRegime.regularIbsStartDate.lte, company.taxRegime.regularCbsStartDate.gte, company.taxRegime.regularCbsStartDate.lteStart of the current period in the IBS and CBS regular regime.
taxId.ninlists.noneList IDs. v2 also has lists.some, which restricts the search to the CNPJs in the lists.
founded.gte, founded.lteincorporationDate.gte, incorporationDate.lte
head.eq=truetype.code.in=HEAD
head.eq=falsetype.code.in=BRANCH
statusDate.gte, statusDate.ltestatusDate.gte, statusDate.lte
status.id.instatus.code.in1 becomes VOID, 2 becomes ACTIVE, 3 becomes SUSPENDED, 4 becomes NONCOMPLIANT and 8 becomes CLOSED.
reason.id.instatusReason.code.in2-character string: 1 becomes 01.
specialDate.gte, specialDate.ltespecialStatusDate.gte, specialStatusDate.lte
special.id.inspecialStatus.code.in3-character string.
address.street.in, address.street.ninaddress.street.in, address.street.nin
address.number.in, address.number.ninaddress.number.in, address.number.nin
address.details.in, address.details.ninaddress.details.in, address.details.nin
address.district.in, address.district.ninaddress.district.in, address.district.nin
address.municipality.in, address.municipality.ninaddress.municipality.in, address.municipality.nin7-digit IBGE code.
address.state.inaddress.state.in
address.zip.in, address.zip.gte, address.zip.lteaddress.postalCode.in, address.postalCode.gte, address.postalCode.lte8-digit CEP.
address.country.id.in, address.country.id.ninaddress.country.code.in, address.country.code.ninNumeric M49 code in v1, 2-letter code in v2: 76 becomes BR.
phones.ex=truephones.gte=1
phones.ex=falsephones.lte=0
phones.type.inphones.type.code.someLANDLINE or MOBILE.
phones.area.in, phones.area.ninphones.area.some, phones.area.none2-digit area code (DDD).
phones.area.gte, phones.area.lteNo equivalentList the area codes in phones.area.some.
phones.number.in, phones.number.ninphones.number.some, phones.number.noneNumber without the area code in v1, E.164 in v2, such as +5511971564144.
emails.ex=trueemails.gte=1
emails.ex=falseemails.lte=0
emails.ownership.inemails.type.code.someACCOUNTING and CORPORATE stay, and PERSONAL becomes CONSUMER. In v1, CORPORATE included the emails v2 classifies as ACADEMIC and GOVERNMENT; send CORPORATE,ACADEMIC,GOVERNMENT to keep the same results.
emails.address.in, emails.address.ninemails.address.some, emails.address.none
emails.domain.in, emails.domain.ninemails.domain.some, emails.domain.none
activities.id.in, activities.id.nineconomicActivities.code.some, economicActivities.code.none7-digit CNAE: 111301 becomes 0111301.
mainActivity.id.in, mainActivity.id.ninprimaryActivity.code.in, primaryActivity.code.nin
sideActivities.id.in, sideActivities.id.ninsecondaryActivities.code.some, secondaryActivities.code.none
No equivalentsearchFree text across CNPJ, names, phones, emails and address.
No equivalentsort, orderrelevance, taxId, incorporationDate, company.shareCapital or company.legalName, in ASC or DESC order. Without them, the order is the same as in v1. See Sorting.

To combine company.simples.optant.eq and company.simei.optant.eq, send a single company.taxRegime.type.code.in with only the codes in both lists, such as SIMPLES_NACIONAL,SIMPLES_NACIONAL_HYBRID for Simples Nacional optants that aren’t MEIs.

All filters are in Search filters.

Search people

CNPJá v1CNPJá v2Notes
tokencursor
limitlimit
type.intype.code.inLEGAL becomes ESTABLISHMENT, NATURAL becomes INDIVIDUAL, FOREIGN becomes FOREIGNER. UNKNOWN is never returned by the search.
name.insearch or legalName.inA full name goes in legalName.in, which compares the whole name; search requires every word.
name.ninlegalName.nin
taxId.intaxId.inA CPF is still matched on its 4th to 9th digits.
age.inageGroup.inSame values, such as 31-40.
country.id.in, country.id.nindomicileCountry.code.in, domicileCountry.code.ninM49 code in v1, 2-letter code in v2.
No equivalentparticipations.gte, participations.lteNumber of participations in companies. v1 returned only people with at least one participation; send participations.gte=1 to keep that.
No equivalentsort, orderrelevance, legalName or participations. Without them, the order is the same as in v1.

Lists

CNPJá v1CNPJá v2Notes
titlename
descriptionNo equivalent
items in Create listitemsRequired in v2, along with type=ESTABLISHMENT.
query and limit in Create listNo equivalentv2 doesn’t create lists from filters. Search with Search CNPJ and send the CNPJs in items.
items in Update listitems with operation=REPLACEIn v1, items replaced the list’s CNPJs. v2 also accepts ADD and REMOVE.
token, limit and search in Search listscursor, limit and searchIn v2, search looks at the name only.
No equivalentsort and order in Search listscreatedAt, updatedAt, name or size. Without them, the order is the same as in v1.

Response fields

Paths with [] refer to each item of a list. The company.taxRegime, stateRegistry, suframa and address.coordinates fields appear only when the resource is requested in expand.

Identification and status

CNPJá v1CNPJá v2Notes
taxIdtaxId
updatedupdatedAtLast update from the Receita Federal.
aliastradeName
foundedincorporationDate
headtype.codetrue becomes HEAD and false becomes BRANCH.
statusDatestatusDate
status.idstatus.code1 becomes VOID, 2 becomes ACTIVE, 3 becomes SUSPENDED, 4 becomes NONCOMPLIANT and 8 becomes CLOSED.
status.textstatus.label
reason.idstatusReason.codeA number in v1, a 2-character string in v2, such as 01.
reason.textstatusReason.label
specialDatespecialStatusDate
special.idspecialStatus.code3-character string.
special.textspecialStatus.label

Address and contacts

CNPJá v1CNPJá v2Notes
address.streetaddress.street
address.numberaddress.number
address.detailsaddress.details
address.districtaddress.district
address.cityaddress.city
address.stateaddress.state
address.zipaddress.postalCode
address.municipalityaddress.municipalityA number in v1, a 7-digit string in v2.
address.country.idaddress.country.codeM49 code in v1, 2-letter code in v2: 76 becomes BR.
address.country.nameaddress.country.label
address.latitude, address.longitudeaddress.coordinates.latitude, address.coordinates.longitudeWith expand=address.coordinates. null when the address can’t be located.
phones[].typephones[].type.code
phones[].area, phones[].numberphones[].numberArea code and number become a single E.164 string: 11 and 971564144 become +5511971564144.
emails[].addressemails[].address
emails[].ownershipemails[].type.codev2 also distinguishes ACADEMIC and GOVERNMENT, which v1 returned as CORPORATE.
emails[].domainNo equivalentExtract the domain from emails[].address.

Activities

CNPJá v1CNPJá v2Notes
mainActivity.idprimaryActivity.codeA number in v1, a 7-digit string in v2.
mainActivity.textprimaryActivity.label
sideActivities[].idsecondaryActivities[].code7-digit string.
sideActivities[].textsecondaryActivities[].label

Company and partners

CNPJá v1CNPJá v2Notes
company.idcompany.idCNPJ root, 8 characters.
company.namecompany.legalName
company.equitycompany.shareCapital
company.nature.idcompany.legalNature.codeA number in v1, a 4-digit string in v2.
company.nature.textcompany.legalNature.label
company.size.idcompany.size.code1 becomes MICRO, 3 becomes SMALL and 5 becomes OTHER.
company.size.acronymNo equivalentDerive it from company.size.code.
company.size.textcompany.size.label
company.jurisdictioncompany.federativeEntity.labelcompany.federativeEntity.code holds BR for the União, the UF abbreviation or the municipality’s IBGE code.
company.members[]company.partners[]See Partners and people.
company.members[].sincecompany.partners[].admissionDate
company.members[].role.idcompany.partners[].role.code2-character string, such as 49.
company.members[].role.textcompany.partners[].role.label
company.members[].person.idcompany.partners[].person.idSame ID, used in Lookup person.
company.members[].person.typecompany.partners[].person.type.codeLEGAL becomes ESTABLISHMENT, NATURAL becomes INDIVIDUAL, FOREIGN becomes FOREIGNER and UNKNOWN stays.
company.members[].person.namecompany.partners[].person.legalName
company.members[].person.taxIdcompany.partners[].person.taxIdMasked CPF or CNPJ. Absent in v1, null in v2 for FOREIGNER and UNKNOWN.
company.members[].person.agecompany.partners[].person.ageGroupSame values, such as 31-40.
company.members[].person.countrycompany.partners[].person.domicileCountry2-letter code and the country name in label. Only for FOREIGN in v1; always present in v2.
company.members[].agent.personcompany.partners[].legalRepresentative.personSame shape as person.
company.members[].agent.rolecompany.partners[].legalRepresentative.rolecode and label.

Tax data

With expand=company.taxRegime:

CNPJá v1CNPJá v2Notes
company.simples.optantcompany.taxRegime.type.codetrue matches SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI. The other values are ACTUAL_PROFIT, PRESUMED_PROFIT, ARBITRATED_PROFIT and NOT_APPLICABLE.
company.simples.sincecompany.taxRegime.simplesNacionalStartDatePresent only when type.code is SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI; v1 returned null in the other cases.
company.simei.optantcompany.taxRegime.type.codetrue matches SIMPLES_NACIONAL_SIMEI.
company.simei.sincecompany.taxRegime.simeiStartDatePresent only when type.code is SIMPLES_NACIONAL_SIMEI; v1 returned null in the other cases.
No equivalentcompany.taxRegime.regularIbsStartDate, company.taxRegime.regularCbsStartDateStart of the current period in the IBS and CBS regular regime. Present only with company.taxRegime.view=DETAILED and when type.code is SIMPLES_NACIONAL_HYBRID, which marks Simples Nacional optants that also opted into the IBS or CBS regular regime. Either can be null.
company.simples.history[]company.taxRegime.timeline[] with type.code equal to SIMPLES_NACIONAL_PERIODWith company.taxRegime.view=DETAILED.
company.simei.history[]company.taxRegime.timeline[] with type.code equal to SIMEI_PERIODWith company.taxRegime.view=DETAILED. The timeline also holds future events and periods under other regimes.
history[].fromtimeline[].startDate
history[].untiltimeline[].endDate
history[].texttimeline[].details

With expand=stateRegistry:

CNPJá v1CNPJá v2Notes
registrations[]stateRegistry.registrations[]
registrations[].numberstateRegistry.registrations[].number
registrations[].statestateRegistry.registrations[].state
registrations[].statusDatestateRegistry.registrations[].statusDate
registrations[].enabledstateRegistry.registrations[].isEnabled
registrations[].status.idstateRegistry.registrations[].hasRestriction1, no restriction, becomes false; 2, blocked as recipient in the UF, becomes true. Interstate blocks are in stateRegistry.taxRestrictions[].
registrations[].type.idstateRegistry.registrations[].type.code1 becomes STATE_TAXPAYER, 2 becomes TAX_SUBSTITUTION, 3 becomes NON_TAXPAYER, 4 becomes INTERSTATE_TAXPAYER and 5 becomes RURAL_PRODUCER.
registrations[].type.textstateRegistry.registrations[].type.label

With expand=suframa:

CNPJá v1CNPJá v2Notes
suframa[]suframa.registrations[]
suframa[].numbersuframa.registrations[].number
suframa[].sincesuframa.registrations[].registrationDate
suframa[].approvedsuframa.registrations[].hasApprovedProject
suframa[].approvalDatesuframa.registrations[].approvalDate
suframa[].status.idsuframa.registrations[].status.code1 becomes ACTIVE, 2 becomes INACTIVE, 3 becomes BLOCKED and 4 becomes CANCELLED.
suframa[].status.textsuframa.registrations[].status.label
suframa[].incentives[]Mapa dos Incentivos FiscaisSUFRAMA stopped publishing each registration’s incentives in its public registry lookup and now points to this official spreadsheet, so v2 doesn’t return them. The criteria SUFRAMA applied are in Estimate incentives.

Standalone lookups

The /rfb, /simples, /ccc and /suframa responses use the fields above in a different layout. In v2, everything is in the Lookup CNPJ or Lookup CPF response:

CNPJá v1CNPJá v2Notes
/rfb: name, equity, nature, size, jurisdictioncompany.legalName, company.shareCapital, company.legalNature, company.size, company.federativeEntityThe other /rfb fields follow the tables above.
/rfb: members[]company.partners[]
/simples: updatedcompany.taxRegime.updatedAt
/simples: simples, simeicompany.taxRegimeAs in the tax data table.
/ccc: updatedstateRegistry.updatedAt
/ccc: namecompany.legalName or, in Lookup CPF, legalName
/ccc: originStateaddress.stateLookup CNPJ only.
/suframa: updatedsuframa.registrations[].updatedAtv1 returned one registration; v2 returns all of them.
/suframa: number, since, approved, approvalDate, statussuframa.registrations[]As in the expand=suframa table.
/suframa: incentivesMapa dos Incentivos FiscaisLike suframa[].incentives[] in the expand=suframa table.
/suframa: namecompany.legalName or, in Lookup CPF, legalName
/suframa: headtype.codeLookup CNPJ only.
/suframa: naturecompany.legalNatureLookup CNPJ only.
/suframa: address, phones, emailssuframa.registrations[].address, suframa.registrations[].phones, suframa.registrations[].emailsSame v2 address, phone and email formats.
/suframa: mainActivity, sideActivitiessuframa.registrations[].primaryActivity, suframa.registrations[].secondaryActivities
/suframa: mainActivity.performed, sideActivities[].performedNo equivalentAlways true in the source.

Company, person and CEP

CNPJá v1CNPJá v2Notes
/company: simples, simeitaxRegimeAlways present in Lookup company, without regularIbsStartDate, regularCbsStartDate and timeline.
/company: members[]partners[]
/company: offices[]establishments[]Same identification and status fields, renamed as in the tables above. v2 also brings address and updatedAt.
/company: offices[].mainActivityestablishments[].primaryActivity
/person: type, name, age, countrytype.code, legalName, ageGroup, domicileCountrySame codes as partners.
/person: membership[]participations[]
/person: membership[].sinceparticipations[].admissionDate
/person: membership[].role, membership[].agentparticipations[].role, participations[].legalRepresentative
/person: membership[].companyparticipations[].companyname becomes legalName, equity becomes shareCapital, nature becomes legalNature, size.id becomes size.code and jurisdiction becomes federativeEntity.
/zip: updatedupdatedAt
/zip: code, street, number, district, city, statecode, street, number, district, city, state
/zip: municipalitymunicipalityA number in v1, a 7-digit string in v2.
No equivalenttype, status, name, detailsCEP type and status, and recipient data. See CEP and addresses.

Lists and pagination

CNPJá v1CNPJá v2Notes
ididSame ID.
titlename
created, updatedcreatedAt, updatedAt
sizesize
description, query, limitNo equivalent
items in Lookup listNo equivalentLookup list doesn’t return the CNPJs. Use Search CNPJ with lists.some.
No equivalenttypeAlways ESTABLISHMENT.
nextnextCursornull on the last page.
counttotal
limit, recordslimit, records

Formats

  • Codes become strings: CNAE, legal nature, partner role, status reason, special status and IBGE code come as fixed-length strings with leading zeros, never as numbers.
  • id and text become code and label. Use code in your logic; label is for display only, follows the response language and may change without notice.
  • Countries drop the numeric M49 code and use the 2-letter code.
  • Phones become a single E.164 string.
  • A resource requested in expand is always present, even when empty, and a resource you don’t request is absent. null, an empty list and a missing field mean different things.

See Response format.

Behavior differences

Freshness and caching

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. Optional resources accept a limit of their own, such as stateRegistry.maxAge. v1 certificates used data up to 1 day old; in Issue CNPJ dossier and Issue CPF dossier the default is 45d, so send maxAge=1d to keep that behavior. 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.

Resources with no record

In v1, /suframa answered 404 when the document had no SUFRAMA registration. In v2, in Lookup CNPJ, expand=suframa returns an empty suframa.registrations, and expand=stateRegistry with no registrations returns an empty stateRegistry.registrations. In Lookup CPF, a CPF with no registration in the queried sources returns 404 INDIVIDUAL_NOT_FOUND, as explained in SUFRAMA.

Errors

The v1 Reference doesn’t document the error format. 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.

Important: remove the v1 parameters that have no equivalent, such as strategy, maxStale, sync, links and registrationsSource. In v2, an unknown parameter is rejected with 400 in operations that take query parameters.

Limits

Limits are the same in both versions. 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

v1 described usage in credits, with the balance at /credit and the cost in the cnpja-request-cost header. 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. Responses carry no cost headers: track usage under Usage. See Queries and quota, what each operation consumes in the Metering Rules and Pricing.

Pagination

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; once expired, the response is 400 PAGE_CURSOR_INVALID, and the client must send the first request again to get a new cursor. See Pagination.

Search terms

In v1, words separated by spaces had to appear together in the same establishment or person, and comma-separated terms were alternatives. In v2, some and none treat each word separately, and search requires every word, in any order. See CNPJ search and lists.

Public access

As in v1, Lookup CNPJ and Lookup CEP accept requests without a key, as long as the URL has no query parameters at all; any parameter results in 401 API_KEY_MISSING. These requests use the default values, such as maxAge=45d with no expand, are not billed and follow limits of their own, counted per source IP. See Public access.

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

  • The credit balance (/credit) and the cnpja-request-cost header.
  • List exports (/list/{listId}/export), already deprecated in v1.
  • Public file links (links).
  • strategy=CACHE, maxStale, sync, registrationsSource and source.
  • Image size, scale, zoom and field of view.
  • The company size acronym (size.acronym) and the email domain (emails[].domain).
  • State registration statuses 3 and 10 and type 9, and SUFRAMA status 5.
  • List description, creation filters (query) and limit (limit), and reading the CNPJs in Lookup list.
  • Area code ranges (phones.area.gte and phones.area.lte) in the CNPJ search.

Step by step

  1. List your integration’s v1 calls and find each one’s equivalent in the matching operations table.
  2. Keep the key and the Authorization header; switch the path to https://api.cnpja.com/v2 and the new names.
  3. Merge the standalone lookups made for the same CNPJ into a single Lookup CNPJ call, requesting the resources in expand.
  4. Rewrite the parameters: add the unit to maxAge, replace the booleans with expand and remove the parameters with no equivalent.
  5. Rewrite the field parsing with the tables above, converting numeric codes into code and phones into E.164.
  6. Switch pagination to cursor and nextCursor, and error handling to code, with 206 treated as success.
  7. Validate: with a key, compare both versions’ responses for a few CNPJs and check usage under Requests.
  8. Switch traffic and watch errors and usage over the first few days.

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.