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 and Company phones and e-mails.
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, and errors are in 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 response for CNPJ 37335118000180, with no optional resources:
{
"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. company holds the company data, shared by the head office and every branch. Objects with code and label, such as status, follow Codes and labels: base your logic on code, because label is for display only and changes with the language. The formats of dates, amounts, identifiers and addresses are in Data formats.
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. is the legalName inside company. In lists, [] stands for each item, as in company..
Status and headers
| Status | Operations | Body |
|---|---|---|
200 | Lookups, searches, file operations and Update list | JSON or file |
201 | Create list | JSON with the created list |
204 | Delete list | Empty |
206 | Lookup CNPJ, Lookup CPF and the certificate operations, when a live query fails or times out (partial success, described in Max age and partial success) | 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 |
Responses with a body carry Content-Type, with application/ 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 and Queries and quota.
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. Many HTTP clients decompress automatically; curl requires the --compressed option. The rules are in 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. of partners | null for FOREIGNER (foreign) and UNKNOWN (known only by name) persons, as explained in Partners and people in the API |
admissionDate of partners | null when the admission date is not registered |
address. and longitude | null when the address cannot be located |
nextCursor | null when there are no more pages |
company., simeiStartDate, regularIbsStartDate and regularCbsStartDate | Present only when they apply: simplesNacionalStartDate when type. is SIMPLES_, SIMPLES_ or SIMPLES_, simeiStartDate when it is SIMPLES_, and regularIbsStartDate and regularCbsStartDate when it is SIMPLES_, only in Lookup CNPJ with company.. 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. | Present only when the legal nature belongs to public administration |
company. | Present only when the partner has a legal representative |
ageGroup | Present only when the person is a natural person (INDIVIDUAL) |
Optional resources, such as company., 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. 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, in the Reference:
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. 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 |
Codes, field names, dates and numbers do not change with the language, and neither does official-source data, as explained in 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, that of Lookup CNPJ with no optional resources except company., which comes without regularIbsStartDate, regularCbsStartDate and its history (timeline); in Search people, that of Lookup person; in Search CEP, that of Lookup CEP; and in Search 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:
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_ |
| 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_ 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, and the full technical specification in Sorting and Pagination, in the Reference.
File responses
| Operation | Content-Type | Content | Guide |
|---|---|---|---|
| Issue CNPJ dossier and Issue CPF dossier | application/ | A single PDF with the requested certificates, in the order given in certificates | Certificates in the API |
| Render CNPJ map | image/ | 640 × 640 pixel image | Location and maps in the API |
| Render CNPJ street view | image/ | 640 × 640 pixel image | Location and maps in the API |
- Success: a
200carries the file itself. For certificates, a206also 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:
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,204and206as success, not only200. - Base logic on
code. Uselabelandmessagefor 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.
- Tell
null, empty lists and missing fields apart, without assuming that a conditional or optional field is always present. - Read searches until
nextCursorisnull, reading each page within 15 minutes. - Request compressed responses with
Accept-Encoding, especially in searches with large pages. - Log the
trace-idof each response, to give it to support.
Frequent errors
| Status | Code | Cause | Action |
|---|---|---|---|
400 | PAGE_ | 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_ | cursor sent with other parameters, such as limit, sort or filters | Send only cursor on the following pages |
400 | REQUEST_ | limit outside the 1 to 1000 range | Send a value within the range |
400 | REQUEST_ | 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 |
The error format and the other codes are in 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 and Export to a spreadsheet.
Notes
- The full list of fields, types and values of each operation is in the Reference, and registry and tax terms are in the 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,primaryActivityandpartnersfollow the same rules. Onlyaddress.is exclusive to Lookup CNPJ.coordinates - The
204of Delete list has no body: do not try to parse it as JSON.