# 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](https://solucoes.receita.fazenda.gov.br/Servicos/cnpjreva/), the [CCC](https://dfe-portal.svrs.rs.gov.br/Nfe/Ccc) and the [Simples Nacional](https://consopt.www8.receita.fazenda.gov.br/consultaoptantes), 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](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d). 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](https://cnpja.com/en-us/signup) and create a key in [API keys](https://cnpja.com/en-us/organizations/current/api-keys). The walkthrough is in [First request](https://cnpja.com/en-us/docs/api/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](https://cnpja.com/en-us/docs/api/reference#description/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

| ReceitaWS | CNPJá | Notes |
|---|---|---|
| `GET /cnpj/{cnpj}` (public API) | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) without a key | No query parameters, with `maxAge` fixed at `45d`. See [Public access](https://cnpja.com/en-us/docs/api/public-access). |
| `GET /cnpj/{cnpj}/days/{days}` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) | `days` becomes `maxAge`. See [CNPJ lookup](https://cnpja.com/en-us/docs/api/cnpj-lookup). |
| `GET /ccc/{cnpj}/days/{days}` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) with `expand=stateRegistry` | Choose the states in `stateRegistry.states` and the age in `stateRegistry.maxAge`. See [State registrations](https://cnpja.com/en-us/docs/api/state-registrations). |
| `GET /simples/{cnpj}/days/{days}` | [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) with `expand=company.taxRegime` | For the history, also send `company.taxRegime.view=DETAILED`. The age goes in `company.taxRegime.maxAge`. |
| `GET /simples/{cnpj}/days/{days}`, without history | [Lookup company](https://cnpja.com/en-us/docs/api/reference#tag/companies/GET/v2/companies/%7bid%7d) | By CNPJ root, always with `taxRegime`, from cached data only. |
| `GET /account/quota` | No equivalent in the API | The organization menu, in the app, shows each quota, its use in the period and when it renews. |
| `GET /account/calls/report` | No equivalent in the API | Use [Requests](https://cnpja.com/en-us/organizations/current/usage-events) and [Usage](https://cnpja.com/en-us/organizations/current/usage) in the app. |

## Request example

ReceitaWS:

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

CNPJá:

```http
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:

```http
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.maxAge` | Requires `stateRegistry` in `expand`. Without this parameter, `maxAge` applies. |
| `days` (path) on `/simples` | `company.taxRegime.maxAge` | Requires `company.taxRegime` 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](#partial-success). |
| Token in the `Bearer` scheme | `Authorization` header with the bare key | See [Authentication](https://cnpja.com/en-us/docs/api/reference#description/authentication). |
| No equivalent | `expand` | Chooses the optional resources: `company.taxRegime`, `stateRegistry`, `suframa` and `address.coordinates`. |
| No equivalent | `stateRegistry.states` | States for state registrations: `ORIGIN` (default, the establishment's state), abbreviations such as `SP`, or `ALL`. |
| No equivalent | `stateRegistry.view`, `company.taxRegime.view` | Level of detail: `SUMMARY` (default) or `DETAILED`. |

## Response fields

The paths on the right are from [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d). 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](https://cnpja.com/en-us/docs/api/responses).

### Identification and status

| ReceitaWS (`/cnpj`) | CNPJá | Notes |
|---|---|---|
| `status` (`OK`) | HTTP status `200` or `206` | Successful responses have no `status` field. |
| `ultima_atualizacao` | `updatedAt` | Date and time of the last update from the Receita Federal. |
| `cnpj` | `taxId` | 14 characters, without punctuation. |
| `tipo` | `type.code` | `MATRIZ` becomes `HEAD`, and `FILIAL`, `BRANCH`. |
| `nome` | `company.legalName` | |
| `fantasia` | `tradeName` | May be `null`. |
| `abertura` | `incorporationDate` | `YYYY-MM-DD`. |
| `situacao` | `status.code` and `status.label` | Codes: `ACTIVE`, `CLOSED`, `NONCOMPLIANT`, `SUSPENDED` and `VOID`. |
| `data_situacao` | `statusDate` | `YYYY-MM-DD`. |
| `motivo_situacao` | `statusReason.code` and `statusReason.label` | 2-character code. Present only when the establishment is not active. |
| `situacao_especial` | `specialStatus.code` and `specialStatus.label` | 3-character code. Present only when the establishment is active and under a special status. |
| `data_situacao_especial` | `specialStatusDate` | Present under the same conditions as `specialStatus`. |

### Address and contacts

| ReceitaWS (`/cnpj`) | CNPJá | Notes |
|---|---|---|
| `logradouro` | `address.street` | May be `null`. |
| `numero` | `address.number` | May be `null`. |
| `complemento` | `address.details` | May be `null`. |
| `bairro` | `address.district` | May be `null`. |
| `cep` | `address.postalCode` | 8 digits, without punctuation. |
| `municipio` | `address.city` | The 7-digit [IBGE code](https://www.ibge.gov.br/explica/codigos-dos-municipios.php) is in `address.municipality`. |
| `uf` | `address.state` | State abbreviation. |
| `telefone` | `phones[].number` | A list, with each number in E.164, such as `+5511971564144`, and the type in `phones[].type.code` (`LANDLINE` or `MOBILE`). |
| `email` | `emails[].address` | A 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](https://cnpja.com/en-us/docs/api/location).

### Activities

| ReceitaWS (`/cnpj`) | CNPJá | Notes |
|---|---|---|
| `atividade_principal[].code` | `primaryActivity.code` | An object, not a list. 7-digit [CNAE](https://concla.ibge.gov.br/busca-online-cnae.html?view=estrutura), without punctuation. |
| `atividade_principal[].text` | `primaryActivity.label` | |
| `atividades_secundarias[].code` | `secondaryActivities[].code` | 7-digit CNAE, without punctuation. |
| `atividades_secundarias[].text` | `secondaryActivities[].label` | |

### Company and partners

| ReceitaWS (`/cnpj`) | CNPJá | Notes |
|---|---|---|
| `natureza_juridica` | `company.legalNature.code` and `company.legalNature.label` | 4-character code, such as `2062`. |
| `porte` | `company.size.code` and `company.size.label` | Codes: `MICRO`, `SMALL` and `OTHER`. |
| `capital_social` | `company.shareCapital` | A number, such as `99999.99`, not text. |
| `efr` | `company.federativeEntity.code` and `company.federativeEntity.label` | Present only for public-administration [legal natures](https://concla.ibge.gov.br/estrutura/natjur-estrutura/natureza-juridica-2021). |
| `qsa[].nome` | `company.partners[].person.legalName` | |
| `qsa[].qual` | `company.partners[].role.code` and `company.partners[].role.label` | 2-character code, such as `49`. |
| `qsa[].pais_origem` | `company.partners[].person.domicileCountry.code` and `.label` | Alpha-2 code, such as `BR`, and the country name. |
| `qsa[].nome_rep_legal` | `company.partners[].legalRepresentative.person.legalName` | `legalRepresentative` appears only when there is a legal representative. |
| `qsa[].qual_rep_legal` | `company.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](https://cnpja.com/en-us/docs/api/reference#tag/people/GET/v2/people/%7bid%7d). See [Partners and people](https://cnpja.com/en-us/docs/api/partners).


### 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](https://cnpja.com/en-us/docs/api/tax-regime).

| ReceitaWS (`/cnpj` and `/simples`) | CNPJá | Notes |
|---|---|---|
| `simples.optante` | `company.taxRegime.type.code` equal to `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID` or `SIMPLES_NACIONAL_SIMEI` | `SIMPLES_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_opcao` | `company.taxRegime.simplesNacionalStartDate` | Start 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_atualizacao` | `company.taxRegime.updatedAt` | One value for both the Simples Nacional and SIMEI. |
| `simei.optante` | `company.taxRegime.type.code` equal to `SIMPLES_NACIONAL_SIMEI` | |
| `simei.data_opcao` | `company.taxRegime.simeiStartDate` | Start of the current period. Present only when `type.code` is `SIMPLES_NACIONAL_SIMEI`, and may be `null`. |
| `simei.ultima_atualizacao` | `company.taxRegime.updatedAt` | |
| `simples.data_exclusao`, `simei.data_exclusao` | `company.taxRegime.timeline[].endDate` | With `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_PERIOD` | The 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[].inicio` | `timeline[].startDate` | `YYYY-MM-DD`. |
| `periodos_anteriores[].fim` | `timeline[].endDate` | May be `null`. |
| `periodos_anteriores[].detalhamento` | `timeline[].details` | May 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_atualizacao` | `stateRegistry.updatedAt` | Last live CCC query, in any state. |
| `cnpj` | `taxId` | |
| `registros[]` | `stateRegistry.registrations[]` | Only the states requested in `stateRegistry.states`. |
| `registros[].uf` | `stateRegistry.registrations[].state` | |
| `registros[].ie` | `stateRegistry.registrations[].number` | |
| `registros[].tipo_ie` | `stateRegistry.registrations[].type.code` and `.label` | Codes such as `STATE_TAXPAYER` and `NON_TAXPAYER`. |
| `registros[].situacao_ie` | `stateRegistry.registrations[].isEnabled` | Boolean: registration enabled as a taxpayer. |
| `registros[].data_situacao` | `stateRegistry.registrations[].statusDate` | `YYYY-MM-DD`. |
| `registros[].data_atualizacao` | `stateRegistry.registrations[].updatedAt` | |
| `registros[].regime_icms` | `stateRegistry.registrations[].hasExceededSublimit` | Boolean: `true` when the ICMS regime indicates an exceeded sublimit. Requires `stateRegistry.view=DETAILED`. |
| `registros[].situacao_cnpj` | `stateRegistry.registrations[].hasRestriction` | Boolean: `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

| ReceitaWS | CNPJá | Notes |
|---|---|---|
| `billing.free` | No equivalent | Public requests, without a key, are not charged. |
| `billing.database` | 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](#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](https://cnpja.com/en-us/docs/api/max-age).

> **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](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size), 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](https://cnpja.com/en-us/docs/api/reference#description/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](https://cnpja.com/en-us/docs/api/limits-and-errors).

| ReceitaWS | CNPJá |
|---|---|
| `200` with `CNPJ inválido` | `400` `REQUEST_VALIDATION_FAILED`, not charged |
| `200` with `CNPJ rejeitado pela Receita Federal` | `404` `ESTABLISHMENT_NOT_FOUND`, billed as described in [What is charged even without a useful result](https://cnpja.com/en-us/legal/metering#charged-without-result) |
| `402` | `402`, when the month's quota or the overage budget is used up, with one of the codes in [Error codes](https://cnpja.com/en-us/docs/api/limits-and-errors#error-codes). The ways out are in [Quota used up](https://cnpja.com/en-us/docs/billing/quota-exhausted#ways-out) |
| `429` on the public API | `429` `RATE_LIMIT_EXCEEDED` or `CONCURRENCY_LIMIT_EXCEEDED` |
| `504` after 50 seconds | `206` when a live query runs past its [time limit](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size) 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 cache | With a key, no error: the request makes a live query. Without a key, see [Public access](#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](https://cnpja.com/en-us/docs/api/limits-and-errors#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](https://cnpja.com/en-us/docs/api/limits-and-errors#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](https://cnpja.com/en-us/docs/billing/packs-and-budget#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](https://cnpja.com/en-us/docs/billing/quota-exhausted#api); 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](https://cnpja.com/en-us/legal/metering#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](https://cnpja.com/en-us/legal/metering#charged-without-result). Responses carry no cost headers: track usage under [Usage](https://cnpja.com/en-us/organizations/current/usage). See [Queries and quota](https://cnpja.com/en-us/docs/billing/queries-and-quotas), what each operation consumes in the [Metering Rules](https://cnpja.com/en-us/legal/metering#api) and [Pricing](https://cnpja.com/en-us/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](https://cnpja.com/en-us/docs/api/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](https://cnpja.com/en-us/docs/api/reference#description/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](https://cnpja.com/en-us/organizations/current/usage-events).
- `GET /account/quota`: quotas are in the organization menu, in the app.
- `GET /account/calls/report`: the history is in [Requests](https://cnpja.com/en-us/organizations/current/usage-events), and usage per key in [Usage](https://cnpja.com/en-us/organizations/current/usage).

## Step by step

1. [Sign up](https://cnpja.com/en-us/signup) and create a key in [API keys](https://cnpja.com/en-us/organizations/current/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](#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](https://cnpja.com/en-us/docs/api/limits-and-errors#timeout-and-size).
7. Replace calls to `/account/quota` and `/account/calls/report` with the [Usage](https://cnpja.com/en-us/organizations/current/usage) and [Requests](https://cnpja.com/en-us/organizations/current/usage-events) 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](https://cnpja.com/en-us/legal/terms#data)).
