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,/cccand/simples) become a single operation, Lookup CNPJ. The CCC and the Simples Nacional are requested as optional resources inexpand, in the same request. - The
dayspath parameter becomes themaxAgequery parameter, with a unit:30becomes30d. Each resource can have its own limit. fallback=cacheOnErroris the default behavior: when a live query fails, the response comes with status206and the cached data.- An invalid or rejected CNPJ no longer comes with
200and astatusofERRORin the body: the HTTP status and a stablecodeidentify each error. - The key goes in the
Authorizationheader without theBearerprefix. - Fields change names and formats: classified values become
codeandlabelpairs, 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
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: 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
| ReceitaWS | CNPJá | Notes |
|---|---|---|
GET / (public API) | Lookup CNPJ without a key | No query parameters, with maxAge fixed at 45d. See Public access. |
GET / | Lookup CNPJ | days becomes maxAge. See CNPJ lookup. |
GET / | Lookup CNPJ with expand=stateRegistry | Choose the states in stateRegistry. and the age in stateRegistry.. See State registrations. |
GET / | Lookup CNPJ with expand=company. | For the history, also send company.. The age goes in company.. |
GET /, without history | Lookup company | By CNPJ root, always with taxRegime, from cached data only. |
GET / | No equivalent in the API | The organization menu, in the app, shows each quota, its use in the period and when it renews. |
GET / | No equivalent in the API | Use 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
| ReceitaWS | CNPJá | Notes |
|---|---|---|
cnpj (path) | taxId (path) | 14 characters without punctuation, with uppercase letters in alphanumeric CNPJs. |
days (path) on /cnpj | maxAge | Number 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 0 | maxAge=5m | The smallest accepted value. Data less than 5 minutes old comes from the cache. |
days above 365 | maxAge=1y | The largest accepted value. |
days (path) on /ccc | stateRegistry. | Requires stateRegistry in expand. Without this parameter, maxAge applies. |
days (path) on /simples | company. | Requires company. in expand. Without this parameter, maxAge applies. |
fallback=cacheOnError | No parameter | The default behavior, with status 206. |
fallback=noCache | No equivalent | Handle 206 in your code, as described in Partial success. |
Token in the Bearer scheme | Authorization header with the bare key | See Authentication. |
| No equivalent | expand | Chooses the optional resources: company., stateRegistry, suframa and address.. |
| No equivalent | stateRegistry. | States for state registrations: ORIGIN (default, the establishment’s state), abbreviations such as SP, or ALL. |
| No equivalent | stateRegistry., company. | Level 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
codeandlabel. Base your logic oncode;labelis for display only and changes with the language. - Identifiers and codes come as text, without punctuation.
- Missing values may come as
nullor 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 206 | Successful responses have no status field. |
ultima_ | updatedAt | Date and time of the last update from the Receita Federal. |
cnpj | taxId | 14 characters, without punctuation. |
tipo | type. | MATRIZ becomes HEAD, and FILIAL, BRANCH. |
nome | company. | |
fantasia | tradeName | May be null. |
abertura | incorporationDate | YYYY-MM-DD. |
situacao | status. and status. | Codes: ACTIVE, CLOSED, NONCOMPLIANT, SUSPENDED and VOID. |
data_ | statusDate | YYYY-MM-DD. |
motivo_ | statusReason. and statusReason. | 2-character code. Present only when the establishment is not active. |
situacao_ | specialStatus. and specialStatus. | 3-character code. Present only when the establishment is active and under a special status. |
data_ | specialStatusDate | Present under the same conditions as specialStatus. |
Address and contacts
ReceitaWS (/cnpj) | CNPJá | Notes |
|---|---|---|
logradouro | address. | May be null. |
numero | address. | May be null. |
complemento | address. | May be null. |
bairro | address. | May be null. |
cep | address. | 8 digits, without punctuation. |
municipio | address. | The 7-digit IBGE code is in address.. |
uf | address. | State abbreviation. |
telefone | phones[]. | A list, with each number in E.164, such as +5511971564144, and the type in phones[]. (LANDLINE or MOBILE). |
email | emails[]. | A list, with the type in emails[].. |
The country is in address., and the coordinates are in address., with expand=address.. See Location and maps.
Activities
ReceitaWS (/cnpj) | CNPJá | Notes |
|---|---|---|
atividade_ | primaryActivity. | An object, not a list. 7-digit CNAE, without punctuation. |
atividade_ | primaryActivity. | |
atividades_ | secondaryActivities[]. | 7-digit CNAE, without punctuation. |
atividades_ | secondaryActivities[]. |
Company and partners
ReceitaWS (/cnpj) | CNPJá | Notes |
|---|---|---|
natureza_ | company. and company. | 4-character code, such as 2062. |
porte | company. and company. | Codes: MICRO, SMALL and OTHER. |
capital_ | company. | A number, such as 99999., not text. |
efr | company. and company. | Present only for public-administration legal natures. |
qsa[]. | company. | |
qsa[]. | company. and company. | 2-character code, such as 49. |
qsa[]. | company. and .label | Alpha-2 code, such as BR, and the country name. |
qsa[]. | company. | legalRepresentative appears only when there is a legal representative. |
qsa[]. | company. and .label |
Partners gain new fields, such as the person type, the masked CPF or the CNPJ in person., the age group, and a stable person. for Lookup person. See Partners and people.
Simples Nacional and SIMEI
These require expand=company.. The /simples fields that are not in /cnpj also require company.. 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. | company. equal to SIMPLES_, SIMPLES_ or SIMPLES_ | SIMPLES_ identifies optants that also opt into the IBS or CBS regular regime, and SIMPLES_ identifies MEIs. With no annual declaration, SIMPLES_ is also adopted for newly opened sole proprietorships. The type also covers the other regimes, such as PRESUMED_. |
simples. | company. | Start of the current period. Present only when type. is SIMPLES_, SIMPLES_ or SIMPLES_, and may be null. |
simples. | company. | One value for both the Simples Nacional and SIMEI. |
simei. | company. equal to SIMPLES_ | |
simei. | company. | Start of the current period. Present only when type. is SIMPLES_, and may be null. |
simei. | company. | |
simples., simei. | company. | With company., in the SIMPLES_ and SIMEI_ items. An exclusion with a future date comes in startDate, in the SIMPLES_ and SIMEI_ items. |
simples. | company. with type. equal to SIMPLES_ | The same list holds actual, presumed and arbitrated profit periods, SIMEI periods, IBS and CBS regular regime periods, and future events. Filter by type.. |
simei. | company. with type. equal to SIMEI_ | |
periodos_ | timeline[]. | YYYY-MM-DD. |
periodos_ | timeline[]. | May be null. |
periodos_ | timeline[]. | May be null. |
The simples. and simples. fields of /simples match company. and company., the start of the current IBS and CBS regular regime periods, which company. returns when company. is SIMPLES_ 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. with type. equal to REGULAR_, REGULAR_, REGULAR_, REGULAR_, REGULAR_ or REGULAR_. The option events in simples. become REGULAR_ or REGULAR_, with data_ 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.. With SUMMARY, the age of stateRegistry. 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., each requested state has its age checked and is queried live separately.
ReceitaWS (/ccc) | CNPJá | Notes |
|---|---|---|
ultima_ | stateRegistry. | Last live CCC query, in any state. |
cnpj | taxId | |
registros[] | stateRegistry. | Only the states requested in stateRegistry.. |
registros[]. | stateRegistry. | |
registros[]. | stateRegistry. | |
registros[]. | stateRegistry. and .label | Codes such as STATE_ and NON_. |
registros[]. | stateRegistry. | Boolean: registration enabled as a taxpayer. |
registros[]. | stateRegistry. | YYYY-MM-DD. |
registros[]. | stateRegistry. | |
registros[]. | stateRegistry. | Boolean: true when the ICMS regime indicates an exceeded sublimit. Requires stateRegistry.. |
registros[]. | stateRegistry. | Boolean: true when the CNPJ has a restriction as a recipient in the state. |
CNPJá also returns the interstate blocks in stateRegistry.. With stateRegistry., each registration adds activity, address, sublimit and authorized tax documents.
Other
| ReceitaWS | CNPJá | Notes |
|---|---|---|
billing. | No equivalent | Public requests, without a key, are not charged. |
billing. | No equivalent | Responses do not report usage. Each resource has its own updatedAt. |
status and message on errors | status, code and message in the error body | See 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
maxAgehigh and use the resource’s own limit, such asstateRegistry.. That way, the registration data keeps coming from the cache.maxAge=1d
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.
| ReceitaWS | CNPJá |
|---|---|
200 with CNPJ inválido | 400 REQUEST_, not charged |
200 with CNPJ rejeitado pela Receita Federal | 404 ESTABLISHMENT_, billed as described in What is charged even without a useful result |
402 | 402, 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 API | 429 RATE_ or CONCURRENCY_ |
504 after 50 seconds | 206 when a live query runs past its time limit and cached data exists, or 504 REQUEST_ when the request itself runs past its limit, not charged |
504 on the public API, for a CNPJ not in the cache | With 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., 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_. 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: compareupdatedAtwith the requested limit in your code.daysequal to0: the smallestmaxAgeis5m.- The
billingobject in responses: each request’s usage is in Requests. GET /: quotas are in the organization menu, in the app.account/ quota GET /: the history is in Requests, and usage per key in Usage.account/ calls/ report
Step by step
- Sign up and create a key in API keys.
- Change the base URL to
https:/and send the key in/ api. cnpja. com/ v2 Authorization, withoutBearer. - Replace
/cnpj/with{cnpj}/ days/ {days} /establishments/followed by the number of days and{taxId}?maxAge= d. - Replace
/cccand/simpleswithexpand=stateRegistryandexpand=company.in the same request, withtaxRegime stateRegistry.for states other than the establishment’s and, if you need the history,states company..taxRegime. view=DETAILED - Update how you read the response using the tables in Response fields, basing your logic on
code. - Treat
206as success and handle errors by HTTP status andcode, with a client timeout above a request’s maximum duration, given in Timeout and size. - Replace calls to
/account/andquota /account/with the Usage and Requests pages.calls/ report - Validate the integration: repeat your requests with the key and compare the responses with those from ReceitaWS.
- 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,/cccand/simpleslookups, thedaysandfallbackparameters, 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).