Skip to content
Migrate from ReceitaWS
API · Migration

Migrate from ReceitaWS

How to replace the ReceitaWS public or commercial API with the CNPJá API: CNPJ, CCC and Simples Nacional in one request, matching fields and errors.

This guide shows how to replace calls to the ReceitaWS API, public and commercial, with calls to the CNPJá API. It covers the CNPJ lookups at the Receita Federal, the CCC and the Simples Nacional, the days and fallback parameters, the response format and the behavior differences.

Overview

  • The three ReceitaWS lookups by CNPJ (/cnpj, /ccc and /simples) become a single operation, Lookup CNPJ. The CCC and the Simples Nacional are requested as optional resources in expand, in the same request.
  • The days path parameter becomes the maxAge query parameter, with a unit: 30 becomes 30d. Each resource can have its own limit.
  • fallback=cacheOnError is the default behavior: when a live query fails, the response comes with status 206 and the cached data.
  • An invalid or rejected CNPJ no longer comes with 200 and a status of ERROR in the body: the HTTP status and a stable code identify each error.
  • The key goes in the Authorization header without the Bearer prefix.
  • Fields change names and formats: classified values become code and label pairs, phones and emails become lists, and share capital becomes a number.
  • The quota and the calls report leave the API and move to the app.

Effort: low to medium. The work is a URL and authentication change, a field mapping and a review of error handling.

Prerequisites

  • Account and key: sign up and create a key in API keys. The walkthrough is in 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: the 14-character CNPJ without punctuation, with uppercase letters in alphanumeric CNPJs, the idea of a maximum data age, and usage split between live queries and cached queries.
  • What changes: the ReceitaWS token, quotas and call history don’t carry over to CNPJá.

Matching operations

ReceitaWSCNPJáNotes
GET /cnpj/{cnpj} (public API)Lookup CNPJ without a keyNo query parameters, with maxAge fixed at 45d. See Public access.
GET /cnpj/{cnpj}/days/{days}Lookup CNPJdays becomes maxAge. See CNPJ lookup.
GET /ccc/{cnpj}/days/{days}Lookup CNPJ with expand=stateRegistryChoose the states in stateRegistry.states and the age in stateRegistry.maxAge. See State registrations.
GET /simples/{cnpj}/days/{days}Lookup CNPJ with expand=company.taxRegimeFor the history, also send company.taxRegime.view=DETAILED. The age goes in company.taxRegime.maxAge.
GET /simples/{cnpj}/days/{days}, without historyLookup companyBy CNPJ root, always with taxRegime, from cached data only.
GET /account/quotaNo equivalent in the APIThe organization menu, in the app, shows each quota, its use in the period and when it renews.
GET /account/calls/reportNo equivalent in the APIUse Requests and Usage in the app.

Request example

ReceitaWS:

GET /v1/cnpj/37335118000180/days/30 HTTP/1.1
Host: receitaws.com.br
Authorization: Bearer YOUR_TOKEN

CNPJá:

GET /v2/establishments/37335118000180?maxAge=30d HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY

CNPJá, with what used to take three requests:

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

Parameters

ReceitaWSCNPJáNotes
cnpj (path)taxId (path)14 characters without punctuation, with uppercase letters in alphanumeric CNPJs.
days (path) on /cnpjmaxAgeNumber of days with the d unit: 30 becomes 30d. Accepts 5m to 1y, and the default is 45d. m is minutes, not months.
days equal to 0maxAge=5mThe smallest accepted value. Data less than 5 minutes old comes from the cache.
days above 365maxAge=1yThe largest accepted value.
days (path) on /cccstateRegistry.maxAgeRequires stateRegistry in expand. Without this parameter, maxAge applies.
days (path) on /simplescompany.taxRegime.maxAgeRequires company.taxRegime in expand. Without this parameter, maxAge applies.
fallback=cacheOnErrorNo parameterThe default behavior, with status 206.
fallback=noCacheNo equivalentHandle 206 in your code, as described in Partial success.
Token in the Bearer schemeAuthorization header with the bare keySee Authentication.
No equivalentexpandChooses the optional resources: company.taxRegime, stateRegistry, suframa and address.coordinates.
No equivalentstateRegistry.statesStates for state registrations: ORIGIN (default, the establishment’s state), abbreviations such as SP, or ALL.
No equivalentstateRegistry.view, company.taxRegime.viewLevel of detail: SUMMARY (default) or DETAILED.

Response fields

The paths on the right are from Lookup CNPJ. Format differences that apply to all fields:

  • Dates come as YYYY-MM-DD, and date-times in ISO 8601 UTC.
  • Classified values, such as status and size, come as code and label. Base your logic on code; label is for display only and changes with the language.
  • Identifiers and codes come as text, without punctuation.
  • Missing values may come as null or be left out of the response, depending on the field. See Response format.

Identification and status

ReceitaWS (/cnpj)CNPJáNotes
status (OK)HTTP status 200 or 206Successful responses have no status field.
ultima_atualizacaoupdatedAtDate and time of the last update from the Receita Federal.
cnpjtaxId14 characters, without punctuation.
tipotype.codeMATRIZ becomes HEAD, and FILIAL, BRANCH.
nomecompany.legalName
fantasiatradeNameMay be null.
aberturaincorporationDateYYYY-MM-DD.
situacaostatus.code and status.labelCodes: ACTIVE, CLOSED, NONCOMPLIANT, SUSPENDED and VOID.
data_situacaostatusDateYYYY-MM-DD.
motivo_situacaostatusReason.code and statusReason.label2-character code. Present only when the establishment is not active.
situacao_especialspecialStatus.code and specialStatus.label3-character code. Present only when the establishment is active and under a special status.
data_situacao_especialspecialStatusDatePresent under the same conditions as specialStatus.

Address and contacts

ReceitaWS (/cnpj)CNPJáNotes
logradouroaddress.streetMay be null.
numeroaddress.numberMay be null.
complementoaddress.detailsMay be null.
bairroaddress.districtMay be null.
cepaddress.postalCode8 digits, without punctuation.
municipioaddress.cityThe 7-digit IBGE code is in address.municipality.
ufaddress.stateState abbreviation.
telefonephones[].numberA list, with each number in E.164, such as +5511971564144, and the type in phones[].type.code (LANDLINE or MOBILE).
emailemails[].addressA list, with the type in emails[].type.code.

The country is in address.country, and the coordinates are in address.coordinates, with expand=address.coordinates. See Location and maps.

Activities

ReceitaWS (/cnpj)CNPJáNotes
atividade_principal[].codeprimaryActivity.codeAn object, not a list. 7-digit CNAE, without punctuation.
atividade_principal[].textprimaryActivity.label
atividades_secundarias[].codesecondaryActivities[].code7-digit CNAE, without punctuation.
atividades_secundarias[].textsecondaryActivities[].label

Company and partners

ReceitaWS (/cnpj)CNPJáNotes
natureza_juridicacompany.legalNature.code and company.legalNature.label4-character code, such as 2062.
portecompany.size.code and company.size.labelCodes: MICRO, SMALL and OTHER.
capital_socialcompany.shareCapitalA number, such as 99999.99, not text.
efrcompany.federativeEntity.code and company.federativeEntity.labelPresent only for public-administration legal natures.
qsa[].nomecompany.partners[].person.legalName
qsa[].qualcompany.partners[].role.code and company.partners[].role.label2-character code, such as 49.
qsa[].pais_origemcompany.partners[].person.domicileCountry.code and .labelAlpha-2 code, such as BR, and the country name.
qsa[].nome_rep_legalcompany.partners[].legalRepresentative.person.legalNamelegalRepresentative appears only when there is a legal representative.
qsa[].qual_rep_legalcompany.partners[].legalRepresentative.role.code and .label

Partners gain new fields, such as the person type, the masked CPF or the CNPJ in person.taxId, the age group, and a stable person.id for Lookup person. See Partners and people.

Simples Nacional and SIMEI

These require expand=company.taxRegime. The /simples fields that are not in /cnpj also require company.taxRegime.view=DETAILED. With DETAILED, the age counts only from the last live query at the Simples Nacional, which can require a live query where SUMMARY would come from the cache. See Tax regime.

ReceitaWS (/cnpj and /simples)CNPJáNotes
simples.optantecompany.taxRegime.type.code equal to SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEISIMPLES_NACIONAL_HYBRID identifies optants that also opt into the IBS or CBS regular regime, and SIMPLES_NACIONAL_SIMEI identifies MEIs. With no annual declaration, SIMPLES_NACIONAL_SIMEI is also adopted for newly opened sole proprietorships. The type also covers the other regimes, such as PRESUMED_PROFIT.
simples.data_opcaocompany.taxRegime.simplesNacionalStartDateStart of the current period. Present only when type.code is SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI, and may be null.
simples.ultima_atualizacaocompany.taxRegime.updatedAtOne value for both the Simples Nacional and SIMEI.
simei.optantecompany.taxRegime.type.code equal to SIMPLES_NACIONAL_SIMEI
simei.data_opcaocompany.taxRegime.simeiStartDateStart of the current period. Present only when type.code is SIMPLES_NACIONAL_SIMEI, and may be null.
simei.ultima_atualizacaocompany.taxRegime.updatedAt
simples.data_exclusao, simei.data_exclusaocompany.taxRegime.timeline[].endDateWith company.taxRegime.view=DETAILED, in the SIMPLES_NACIONAL_PERIOD and SIMEI_PERIOD items. An exclusion with a future date comes in startDate, in the SIMPLES_NACIONAL_EXCLUSION and SIMEI_EXCLUSION items.
simples.historico.periodos_anteriores[]company.taxRegime.timeline[] with type.code equal to SIMPLES_NACIONAL_PERIODThe same list holds actual, presumed and arbitrated profit periods, SIMEI periods, IBS and CBS regular regime periods, and future events. Filter by type.code.
simei.historico.periodos_anteriores[]company.taxRegime.timeline[] with type.code equal to SIMEI_PERIOD
periodos_anteriores[].iniciotimeline[].startDateYYYY-MM-DD.
periodos_anteriores[].fimtimeline[].endDateMay be null.
periodos_anteriores[].detalhamentotimeline[].detailsMay be null.

The simples.ibs.data_opcao and simples.cbs.data_opcao fields of /simples match company.taxRegime.regularIbsStartDate and company.taxRegime.regularCbsStartDate, the start of the current IBS and CBS regular regime periods, which company.taxRegime.view=DETAILED returns when company.taxRegime.type.code is SIMPLES_NACIONAL_HYBRID and 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 previous periods and the events of these regimes come in company.taxRegime.timeline[] with type.code equal to REGULAR_IBS_PERIOD, REGULAR_IBS_OPTION, REGULAR_IBS_OPTION_CANCELLATION, REGULAR_CBS_PERIOD, REGULAR_CBS_OPTION or REGULAR_CBS_OPTION_CANCELLATION. The option events in simples.eventos_futuros[] become REGULAR_IBS_OPTION or REGULAR_CBS_OPTION, with data_efeito in startDate and descricao in details.

State registrations (CCC)

These require expand=stateRegistry. The fields below come at the SUMMARY level, the default, except hasExceededSublimit, which requires stateRegistry.view=DETAILED. With SUMMARY, the age of stateRegistry.updatedAt applies and only the establishment’s state is queried live; the registrations in the other states are refreshed in that query when the CNPJ has a registration in the establishment’s state and, otherwise, come from the cache only. With stateRegistry.view=DETAILED, each requested state has its age checked and is queried live separately.

ReceitaWS (/ccc)CNPJáNotes
ultima_atualizacaostateRegistry.updatedAtLast live CCC query, in any state.
cnpjtaxId
registros[]stateRegistry.registrations[]Only the states requested in stateRegistry.states.
registros[].ufstateRegistry.registrations[].state
registros[].iestateRegistry.registrations[].number
registros[].tipo_iestateRegistry.registrations[].type.code and .labelCodes such as STATE_TAXPAYER and NON_TAXPAYER.
registros[].situacao_iestateRegistry.registrations[].isEnabledBoolean: registration enabled as a taxpayer.
registros[].data_situacaostateRegistry.registrations[].statusDateYYYY-MM-DD.
registros[].data_atualizacaostateRegistry.registrations[].updatedAt
registros[].regime_icmsstateRegistry.registrations[].hasExceededSublimitBoolean: true when the ICMS regime indicates an exceeded sublimit. Requires stateRegistry.view=DETAILED.
registros[].situacao_cnpjstateRegistry.registrations[].hasRestrictionBoolean: true when the CNPJ has a restriction as a recipient in the state.

CNPJá also returns the interstate blocks in stateRegistry.taxRestrictions[]. With stateRegistry.view=DETAILED, each registration adds activity, address, sublimit and authorized tax documents.

Other

ReceitaWSCNPJáNotes
billing.freeNo equivalentPublic requests, without a key, are not charged.
billing.databaseNo equivalentResponses do not report usage. Each resource has its own updatedAt.
status and message on errorsstatus, code and message in the error bodySee Errors.

Behavior differences

Freshness and caching

As with ReceitaWS days, maxAge sets the accepted data age, but the decision is made per resource. 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. See Max age and partial success.

Tip: to refresh only the state registrations or the Simples Nacional, keep maxAge high and use the resource’s own limit, such as stateRegistry.maxAge=1d. That way, the registration data keeps coming from the cache.

Partial success

As with fallback=cacheOnError, cached data is used when the live query fails. There is no option to refuse the cache: to reproduce noCache, discard the resources whose updatedAt is older than the limit you asked for. 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

For an invalid or rejected CNPJ, ReceitaWS responds 200 with a status of ERROR and a message. 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.

ReceitaWSCNPJá
200 with CNPJ inválido400 REQUEST_VALIDATION_FAILED, not charged
200 with CNPJ rejeitado pela Receita Federal404 ESTABLISHMENT_NOT_FOUND, billed as described in What is charged even without a useful result
402402, when the month’s quota or the overage budget is used up, with one of the codes in Error codes. The ways out are in Quota used up
429 on the public API429 RATE_LIMIT_EXCEEDED or CONCURRENCY_LIMIT_EXCEEDED
504 after 50 seconds206 when a live query runs past its time limit and cached data exists, or 504 REQUEST_TIMED_OUT when the request itself runs past its limit, not charged
504 on the public API, for a CNPJ not in the cacheWith a key, no error: the request makes a live query. Without a key, see Public access

Limits

The ReceitaWS public API allows 3 lookups per minute. 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 responses carry no rate-limit headers. Each request has a maximum duration, and the client timeout must stay above it, as shown in Timeout and size.

Billing

ReceitaWS quotas split real-time lookups and database lookups, and CNPJá splits live queries and cached queries the same way. 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. One request with expand can consume both units, and registration data is always billed, even when you only need the state registrations or the Simples Nacional. A 404 and, with stateRegistry.view=DETAILED, each requested state with no registration are 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.

Public access

The ReceitaWS public API only returns CNPJs that are already cached. In CNPJá, the equivalent is public access: a request without a key to Lookup CNPJ makes a live query when the registration is older than 45 days. 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. Public access serves low-volume or low-criticality integrations; use a key when volume grows, when a limit rejection is not acceptable or when you need other parameters. See Public access, which also explains the behavior for CNPJs not in cached data.

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

  • fallback=noCache: compare updatedAt with the requested limit in your code.
  • days equal to 0: the smallest maxAge is 5m.
  • The billing object in responses: each request’s usage is in Requests.
  • GET /account/quota: quotas are in the organization menu, in the app.
  • GET /account/calls/report: the history is in Requests, and usage per key in Usage.

Step by step

  1. Sign up and create a key in API keys.
  2. Change the base URL to https://api.cnpja.com/v2 and send the key in Authorization, without Bearer.
  3. Replace /cnpj/{cnpj}/days/{days} with /establishments/{taxId}?maxAge= followed by the number of days and d.
  4. Replace /ccc and /simples with expand=stateRegistry and expand=company.taxRegime in the same request, with stateRegistry.states for states other than the establishment’s and, if you need the history, company.taxRegime.view=DETAILED.
  5. Update how you read the response using the tables in Response fields, basing your logic on code.
  6. Treat 206 as success and handle errors by HTTP status and code, with a client timeout above a request’s maximum duration, given in Timeout and size.
  7. Replace calls to /account/quota and /account/calls/report with the Usage and Requests pages.
  8. Validate the integration: repeat your requests with the key and compare the responses with those from ReceitaWS.
  9. Switch traffic to CNPJá and watch usage during the first weeks.

Sources for this comparison

What this page says about ReceitaWS comes from its public documentation:

  • ReceitaWS API documentation: the /cnpj, /ccc and /simples lookups, the days and fallback parameters, the response fields, the errors, the Public API limit and the account quota and calls endpoints.

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.