# Response format

> How to read CNPJá API responses: JSON structure, status codes and headers, missing and empty values, language, cursor pagination and file responses.

> **Tip:** Concepts on this page: [Data formats](https://cnpja.com/en-us/docs/data/format) and [Company phones and e-mails](https://cnpja.com/en-us/docs/data/contacts).

API responses are JSON, except for the operations that return files: PDF certificates and map and street view images. All of them follow the same conventions for structure, status, missing values, language and pagination, described on this page. The fields of each operation are in the [Reference](https://cnpja.com/en-us/docs/api/reference), and errors are in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors).

## Response structure

A JSON response is made of named fields with values, which can hold other fields or lists. Excerpt of a [Lookup CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d) response for CNPJ `37335118000180`, with no optional resources:

```json
{
  "updatedAt": "2026-01-27T03:00:00.000Z",
  "taxId": "37335118000180",
  "incorporationDate": "2020-06-05",
  "company": {
    "id": "37335118",
    "legalName": "CNPJA TECNOLOGIA LTDA",
    "shareCapital": 99999.99,
    "legalNature": { "code": "2062", "label": "Sociedade Empresária Limitada" },
    "size": { "code": "SMALL", "label": "Empresa de Pequeno Porte" }
  },
  "type": { "code": "HEAD", "label": "Matriz" },
  "tradeName": "Cnpja",
  "status": { "code": "ACTIVE", "label": "Ativa" },
  "address": {
    "street": "Avenida Brigadeiro Faria Lima",
    "number": "2369",
    "city": "São Paulo",
    "state": "SP",
    "postalCode": "01452922",
    "municipality": "3550308",
    "country": { "code": "BR", "label": "Brasil" }
  },
  "phones": [{ "number": "+5511971564144", "type": { "code": "MOBILE", "label": "Celular" } }],
  "primaryActivity": { "code": "6311900", "label": "Tratamento de dados, provedores de serviços de aplicação e serviços de hospedagem na internet" }
}
```

`updatedAt` is the last update from the Receita Federal, as explained in [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age). `company` holds the [company](https://cnpja.com/en-us/docs/glossary#empresa--company) data, shared by the head office and every branch. Objects with `code` and `label`, such as `status`, follow [Codes and labels](https://cnpja.com/en-us/docs/data/format#code-and-label): base your logic on `code`, because `label` is for display only and changes with the [language](#language-accept-language). The formats of dates, amounts, identifiers and addresses are in [Data formats](https://cnpja.com/en-us/docs/data/format#api).

Field names are in English, in camelCase, and do not change with the language. The documentation refers to a field by its path, separated by dots: `company.legalName` is the `legalName` inside `company`. In lists, `[]` stands for each item, as in `company.partners[].person.id`.

## Status and headers

| Status | Operations | Body |
|---|---|---|
| `200` | Lookups, searches, file operations and Update list | JSON or file |
| `201` | [Create list](https://cnpja.com/en-us/docs/api/reference#tag/lists/POST/v2/lists) | JSON with the created list |
| `204` | [Delete list](https://cnpja.com/en-us/docs/api/reference#tag/lists/DELETE/v2/lists/%7blistId%7d) | Empty |
| `206` | Lookup CNPJ, Lookup CPF and the certificate operations, when a live query fails or times out ([partial success](https://cnpja.com/en-us/docs/glossary#sucesso-parcial--partial-success), described in [Max age and partial success](https://cnpja.com/en-us/docs/api/max-age)) | Same format as a `200`. Treat it as success |
| `4xx` and `5xx` | All | JSON with `status`, `code`, `message` and `traceId`, as described in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors) |

Responses with a body carry `Content-Type`, with `application/json` or the file type. Every response carries `trace-id`, the request identifier, repeated in `traceId` in error responses. There are no usage limit headers, no `Retry-After` and no balance or cost headers, as described in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors) and [Queries and quota](https://cnpja.com/en-us/docs/billing/queries-and-quotas).

The API compresses JSON responses when the request lists the accepted encodings in `Accept-Encoding`: `zstd`, `br`, `gzip` or `deflate`. The chosen one comes in `Content-Encoding`. Very small responses, such as most error responses, are sent uncompressed, and so are [file responses](#file-responses). Many HTTP clients decompress automatically; curl requires the `--compressed` option. The rules are in [Compression](https://cnpja.com/en-us/docs/api/reference#description/compression), in the Reference.

## Missing and empty values

| Situation | Meaning | Example |
|---|---|---|
| `null` | The field exists, but no value is registered | `tradeName` of an establishment with no trade name |
| Empty list `[]` | No items were found | `phones` of an establishment with no phones |
| Missing field | The field appears only under certain conditions, or was not requested | `statusReason` of an active establishment |

| Field | Behavior |
|---|---|
| `tradeName`, `street`, `number`, `details` and `district` | `null` when they are not in the registration |
| `person.taxId` of partners | `null` for `FOREIGNER` (foreign) and `UNKNOWN` (known only by name) persons, as explained in [Partners and people in the API](https://cnpja.com/en-us/docs/api/partners) |
| `admissionDate` of partners | `null` when the admission date is not registered |
| `address.coordinates.latitude` and `longitude` | `null` when the address cannot be located |
| `nextCursor` | `null` when there are no more pages |
| `company.taxRegime.simplesNacionalStartDate`, `simeiStartDate`, `regularIbsStartDate` and `regularCbsStartDate` | Present only when they apply: `simplesNacionalStartDate` when `type.code` is `SIMPLES_NACIONAL`, `SIMPLES_NACIONAL_HYBRID` or `SIMPLES_NACIONAL_SIMEI`, `simeiStartDate` when it is `SIMPLES_NACIONAL_SIMEI`, and `regularIbsStartDate` and `regularCbsStartDate` when it is `SIMPLES_NACIONAL_HYBRID`, only in Lookup CNPJ with `company.taxRegime.view=DETAILED`. When present, `simplesNacionalStartDate` and `simeiStartDate` are `null` if the date is not known, and `regularIbsStartDate` or `regularCbsStartDate` is `null` when the company opted into the regular regime of the other tax only |
| `statusReason` | Present only when the establishment is not active |
| `specialStatus` and `specialStatusDate` | Present only when the establishment is active and falls under a specific legal regime, such as judicial recovery |
| `company.federativeEntity` | Present only when the legal nature belongs to public administration |
| `company.partners[].legalRepresentative` | Present only when the partner has a legal representative |
| `ageGroup` | Present only when the person is a natural person (`INDIVIDUAL`) |

Optional [resources](https://cnpja.com/en-us/docs/glossary#recurso--resource), such as `company.taxRegime`, `stateRegistry` and `suframa` in Lookup CNPJ, stay out of the response until they are requested in `expand`, as shown in [CNPJ lookup in the API](https://cnpja.com/en-us/docs/api/cnpj-lookup). A requested resource is present even with no data, for example with an empty `registrations`.

## Language (Accept-Language)

Labels and error messages are in Portuguese by default. To get them in English, send the `Accept-Language` header with `en-US`, as described in [Language](https://cnpja.com/en-us/docs/api/reference#description/language), in the Reference:

```http
GET /v2/establishments/37335118000180 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
Accept-Language: en-US
```

The registration status text then comes as `"label": "Active"`, and `status.code` stays `ACTIVE`.

| Aspect | Behavior |
|---|---|
| Accepted values | Only the exact tags `pt-BR` and `en-US`. Tags without a region, such as `pt` or `en`, are ignored. Send a single tag |
| Default | `pt-BR`, when the header is missing or has no recognized tag. An unrecognized tag does not cause an error |
| What changes | `label` fields and the `message` of errors, including the items in `errors`. A message with no translation comes in English |
| Public access | `Accept-Language` is a header, not a query parameter, so it also works in requests without a key, as described in [Public API access, no key](https://cnpja.com/en-us/docs/api/public-access) |

Codes, field names, dates and numbers do not change with the language, and neither does official-source data, as explained in [Label language](https://cnpja.com/en-us/docs/data/format#label-language).

## Paged responses

The four search operations return results in pages, always with the same fields:

| Field | Content |
|---|---|
| `records` | The page's records, in the order set by `sort` and `order`. The last page may hold fewer than `limit` |
| `total` | Number of records that match the search, across all pages |
| `limit` | Page size in effect, from `1` to `1000`. The default is `10` |
| `nextCursor` | Cursor for the next page, or `null` when there are no more |

Each item in `records` has the format of the matching lookup: in [Search CNPJ](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments), that of Lookup CNPJ with no optional resources except `company.taxRegime`, which comes without `regularIbsStartDate`, `regularCbsStartDate` and its history (`timeline`); in [Search people](https://cnpja.com/en-us/docs/api/reference#tag/people/GET/v2/people), that of Lookup person; in [Search CEP](https://cnpja.com/en-us/docs/api/reference#tag/postal-codes/GET/v2/postal-codes), that of Lookup CEP; and in [Search lists](https://cnpja.com/en-us/docs/api/reference#tag/lists/GET/v2/lists), that of Lookup list.

A search with no matches returns `200` with empty `records`, `total` set to `0` and `nextCursor` set to `null`, never `404`.

### Reading pages

The first request sets the filters, `sort`, `order` and `limit`. In the following ones, send each response's `nextCursor` as `cursor`, with no other parameter, until `nextCursor` is `null`:

```http
GET /v2/establishments?cursor=9ed11ce29dc14f9c78304c1a403e9f85 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY
```

| Rule | Behavior |
|---|---|
| Filters | The cursor keeps the filters, `sort`, `order` and `limit` of the first request. To change any of them, start a new search |
| Parameters | `cursor` must be the only parameter. Combined with any other, including `limit`, the request is rejected with `400` `REQUEST_VALIDATION_FAILED` |
| Validity | 15 minutes from the response that returned it, counted between one page and the next. Within that period, the cursor can be reused, for example to repeat a page after a network failure |
| Expiration | An expired or unknown cursor returns `400` `PAGE_CURSOR_INVALID` and cannot be renewed: start again from the first request |

Pagination does not freeze results. If the data changes while you read, a record may appear on two pages or on none, and `total` may vary. The number of pages is set by the first response, so a page may come with fewer records, or empty, before the end. Keep going until `nextCursor` is `null` and, if your process does not tolerate repeats, discard duplicates by identifier, such as `taxId` for establishments. The filters are in [CNPJ search and lists in the API](https://cnpja.com/en-us/docs/api/cnpj-search), and the full technical specification in [Sorting](https://cnpja.com/en-us/docs/api/reference#description/sorting) and [Pagination](https://cnpja.com/en-us/docs/api/reference#description/pagination), in the Reference.

## File responses

| Operation | `Content-Type` | Content | Guide |
|---|---|---|---|
| [Issue CNPJ dossier](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d/dossier) and [Issue CPF dossier](https://cnpja.com/en-us/docs/api/reference#tag/individuals/GET/v2/individuals/%7btaxId%7d/dossier) | `application/pdf` | A single PDF with the requested certificates, in the order given in `certificates` | [Certificates in the API](https://cnpja.com/en-us/docs/api/certificates) |
| [Render CNPJ map](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d/map) | `image/png` | 640 × 640 pixel image | [Location and maps in the API](https://cnpja.com/en-us/docs/api/location) |
| [Render CNPJ street view](https://cnpja.com/en-us/docs/api/reference#tag/establishments/GET/v2/establishments/%7btaxId%7d/street-view) | `image/jpeg` | 640 × 640 pixel image | [Location and maps in the API](https://cnpja.com/en-us/docs/api/location) |

- **Success:** a `200` carries the file itself. For certificates, a `206` also carries the PDF, with the affected certificates in their cached version or left out.
- **Error:** error responses are JSON, in the same format as other operations. Check the status, or the `Content-Type`, before saving or displaying the file.
- **Compression:** files are sent uncompressed, even with `Accept-Encoding`.

With curl, the `--fail` option avoids saving an error response as if it were the PDF:

```bash
curl --fail -o certificates.pdf -H "Authorization: YOUR_API_KEY" \
  "https://api.cnpja.com/v2/establishments/37335118000180/dossier?certificates=RFB_REGISTRATION"
```

## Best practices

- **Accept every success status.** Treat `200`, `201`, `204` and `206` as success, not only `200`.
- **Base logic on `code`.** Use `label` and `message` for display only, and plan a default handling for codes your system does not know yet.
- **Follow the format conventions.** Store identifiers and codes as text and convert time zones only when displaying instants, as explained in [Data formats](https://cnpja.com/en-us/docs/data/format#api).
- **Tell `null`, empty lists and missing fields apart**, without assuming that a conditional or optional field is always present.
- **Read searches until `nextCursor` is `null`**, reading each page within 15 minutes.
- **Request compressed responses** with `Accept-Encoding`, especially in searches with large pages.
- **Log the `trace-id`** of each response, to give it to support.

## Frequent errors

| Status | Code | Cause | Action |
|---|---|---|---|
| `400` | `PAGE_CURSOR_INVALID` | Cursor expired, after 15 minutes without reading the next page, or unknown | Start the search again from the first request, with the same parameters |
| `400` | `REQUEST_VALIDATION_FAILED` | `cursor` sent with other parameters, such as `limit`, `sort` or filters | Send only `cursor` on the following pages |
| `400` | `REQUEST_VALIDATION_FAILED` | `limit` outside the `1` to `1000` range | Send a value within the range |
| `400` | `REQUEST_VALIDATION_FAILED` | `sort` or `order` with a value the operation does not accept, such as `order=asc`, in lowercase | Send one of the values listed in the [Reference](https://cnpja.com/en-us/docs/api/reference) |

The error format and the other codes are in [Limits and errors](https://cnpja.com/en-us/docs/api/limits-and-errors).

## In the app

On the platform, the same data appears already formatted, with labels in the interface language, and can be downloaded as a spreadsheet without writing code. See [The company record](https://cnpja.com/en-us/docs/companies/record) and [Export to a spreadsheet](https://cnpja.com/en-us/docs/lists/export).

## Notes

- The full list of fields, types and values of each operation is in the [Reference](https://cnpja.com/en-us/docs/api/reference), and registry and tax terms are in the [Glossary](https://cnpja.com/en-us/docs/glossary).
- Objects with the same name have the same format in every operation where they appear, including state registrations and SUFRAMA registrations: `address`, `phones`, `emails`, `primaryActivity` and `partners` follow the same rules. Only `address.coordinates` is exclusive to Lookup CNPJ.
- The `204` of Delete list has no body: do not try to parse it as JSON.
