CNPJ card and PDF certificates in the API
Issue the CNPJ card, the QSA and the Simples Nacional, CCC and SUFRAMA certificates as a single PDF via the API, with codes, max age and errors.
Tip: Concepts on this page: CNPJ card and other certificates, Omitted certificates and Data freshness.
The API issues the certificates of a CNPJ, in Issue CNPJ dossier, or of a CPF, in Issue CPF dossier, and bundles them into a single PDF file, the dossier. Each certificate carries the registration at the source on the date of the query: the original PDF is worth what the source gives it, the reproduction generated by CNPJá carries no public faith, and neither replaces checking the source when the law requires it, as explained in What a certificate is. Both operations always require an API key.
Request
| Operation | Method and path | Accepted certificates |
|---|---|---|
| Issue CNPJ dossier | GET / | All five |
| Issue CPF dossier | GET / | CCC_ and SUFRAMA_ |
Each certificate has a code, sent in the certificates parameter. The content and source of each one are in Available certificates.
| Code | Certificate |
|---|---|
RFB_ | CNPJ registration and status, the cartão CNPJ |
RFB_ | Partners and administrators board |
SIMPLES_ | Simples Nacional option |
CCC_ | State registrations, in one state |
SUFRAMA_ | SUFRAMA registration |
Both operations take the same parameters:
| Parameter | Location | Required | Content |
|---|---|---|---|
taxId | Path | Yes | CNPJ with 14 characters or CPF with 11 digits, with no punctuation |
certificates | Query | Yes | Certificate codes, separated by commas, with at least one and no repeats. The order of the codes sets the order in the PDF |
maxAge | Query | No | Maximum data age accepted for cached certificates, from 5m to 1y. Default: 45d |
- A code the operation does not accept, such as
RFB_in the CPF dossier, a repeated code or aREGISTRATION maxAgein the wrong format are rejected with400REQUEST_.VALIDATION_ FAILED - Dossiers do not accept the access without a key described in Public access: a request without a key returns
401API_.KEY_ MISSING
GET /v2/establishments/37335118000180/dossier?certificates=RFB_REGISTRATION,RFB_PARTNERS HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY Max age
Each requested certificate is compared with maxAge independently. Within the limit, it comes from cached data; if it is older, or was never issued, it is issued live at the source during the request. Outdated certificates are issued in parallel, so the response time follows the slowest issue.
maxAgeapplies to every certificate in the request. There are no per-certificate limits, likestateRegistry.in Lookup CNPJ. The syntax is in Max age and partial success.maxAge - To require one recent certificate without forcing the issue of the others, request it in a separate request.
For a recent certificate, such as when approving a new customer, send a smaller maxAge:
GET /v2/establishments/37335118000180/dossier?certificates=RFB_REGISTRATION&maxAge=1d HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY Response
A 200 or 206 response is the PDF file itself, with Content-Type: application/:
- Order: certificates appear in the order of the codes in
certificates, each with all of its pages. - Omissions: an unavailable certificate is left out of the file, with no notice page, as described in Omitted certificates.
- Date: certificates have no
updatedAt, and the response does not state the date of each one. When the source prints the issue date, it is in the document itself. - Errors: an error response comes as JSON, in the format described in Limits and errors.
- Compression: the PDF is never compressed, even with
Accept-Encoding. - Individual files: the API does not split the dossier into separate files. To keep each certificate in its own PDF, send one request per certificate, with a single code in
certificates. Each certificate is still charged separately, as in a dossier with several.
To save the dossier with curl and see the status at the end:
curl "https://api.cnpja.com/v2/establishments/37335118000180/dossier?certificates=RFB_REGISTRATION,RFB_PARTNERS" \
-H "Authorization: YOUR_API_KEY" \
-o dossier.pdf -w "%{http_code}\n" With 200 or 206, the file is the PDF. With any other status, it holds the error JSON. Check the status before filing the file as a certificate.
CNPJ and CPF
Issue CNPJ dossier
- The CNPJ has 14 characters, with no punctuation, uppercase letters in an alphanumeric CNPJ and valid check digits. Other formats are rejected with
400REQUEST_.VALIDATION_ FAILED - A CNPJ that is not in cached data yet is queried live at the Receita Federal before the dossier is issued.
404ESTABLISHMENT_means the CNPJ is not registered with the Receita Federal.NOT_ FOUND
Issue CPF dossier
Issue CPF dossier serves an individual, a natural person with a state registration in the CCC or a SUFRAMA registration, and does not issue certificates of the CPF registry at the Receita Federal, as explained in CNPJ or CPF.
GET /v2/individuals/CPF_NUMBER/dossier?certificates=CCC_REGISTRATIONS,SUFRAMA_REGISTRATION HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY - The CPF has 11 digits, with no punctuation. The masked CPF of partners, such as
***456789**, does not work with this operation. See Partners and people in the API. CCC_is only issued when the CPF has a known state registration. Without one, this operation does not query the CCC: fetch the registrations first in Lookup CPF, withREGISTRATIONS expand=stateRegistryand the states instateRegistry., as described in State registrations in the API, then issue the dossier.states SUFRAMA_queries the SUFRAMA registry even for a CPF not yet known to the API.REGISTRATION
Important:
404INDIVIDUAL_means the API knows no state registration of the CPF and SUFRAMA found no registration, whenNOT_ FOUND SUFRAMA_is requested. A CPF not yet known to the API, requested only withREGISTRATION CCC_, returnsREGISTRATIONS 404without querying any source. On the first request for a CPF there is no cached data to fall back on, and a SUFRAMA failure also results in404: when a404is unexpected, retry the request later.
Omitted certificates
The dossier holds only the certificates that are available. The cases in which a certificate is left out, and what each one consumes, are in Omitted certificates. In the response:
- The PDF has no notice page in place of an omitted certificate, and the response does not say which ones were left out.
- When none of the requested certificates is available, there is no PDF: the response is
404ESTABLISHMENT_in Issue CNPJ dossier orDOSSIER_ EMPTY 404INDIVIDUAL_in Issue CPF dossier. ThatDOSSIER_ EMPTY 404consumes what each omitted certificate consumes, as in Omitted certificates. - When your integration already looks up the CNPJ as JSON with
company.,taxRegime stateRegistryorsuframainexpand, use the result to request only the certificates that should exist. - To tell each omission apart, request one certificate per request, as described in Response.
Partial success
Each live query has up to 30 seconds. If issuing a certificate fails or takes longer, the request goes on and the response comes with 206, a partial success:
- The body is a PDF, just like in a
200response. - The affected certificate comes in its cached version, which can be older than the requested
maxAge, or is left out when none exists. If no certificate is left, the response is the404described in Omitted certificates. - The affected certificate is not charged, even when its cached version is included, under the metering rules. The others are charged normally.
- The response does not say which certificate failed.
Partial success needs cached data to fall back on. If the live query of a CNPJ that is not in cache yet fails, the request fails instead of returning 206. In that case, retry later, as explained in A CNPJ’s first lookup.
Important: treat
206as success, but do not file the document as an up-to-date record when the decision requires a recent certificate. Retry the request later to get the updated version.
Billing
Each requested certificate is charged separately, as live when it is issued during the request and as cached when it comes from cache, including the two Receita Federal certificates, which come from a single query at the source. The consumption of each case, including 404 responses, is in the metering rules, under Issue certificates.
Important: a certificate left out because the source has no record is still charged, as the metering rules set, even when no certificate is left and the response is a
404. Request only the certificates that should exist.
Frequent errors
| Status | Code | Cause | Action |
|---|---|---|---|
400 | REQUEST_ | certificates missing, empty, with a repeated code or a code the operation does not accept; maxAge in the wrong format; malformed CNPJ or CPF; unknown parameter | Fix what errors points to |
401 | API_ | Request without an API key. Dossiers do not accept public access | Send the key in the Authorization header |
402 | CACHED_, LIVE_ or OVERAGE_ | The organization’s quota or overage budget is used up. What each code means is in Error codes | Follow one of the ways out in Quota used up |
404 | ESTABLISHMENT_ | The CNPJ is not registered with the Receita Federal | Check the CNPJ. The 404 is also charged, under the metering rules: retry only when the registration may have changed |
404 | INDIVIDUAL_ | The API knows no state registration of the CPF and SUFRAMA found no registration, or failed on the first request for the CPF | Look up the registrations in Lookup CPF first or retry later, as described in Issue CPF dossier |
404 | ESTABLISHMENT_ or INDIVIDUAL_ | None of the requested certificates is available for the CNPJ or CPF, for the reasons in Omitted certificates | Request only the certificates that should exist. The 404 consumes what each omitted certificate consumes |
504 | REQUEST_ | The request did not finish within 60 seconds | Retry with increasing intervals. The response is not charged |
Other errors are in Limits and errors.
Use cases
- Customer onboarding: when approving a customer, issue
RFB_andREGISTRATION RFB_with a shortPARTNERS maxAgeand file the PDF with the customer record, as a record of the registration status and the partners on the date of the query. - Supplier qualification: bundle the cartão CNPJ, QSA, Simples Nacional and CCC certificates into a single dossier and renew it periodically with the default
maxAge. - Tax documentation: as support for checking a tax rule, file the certificate you queried, such as
SIMPLES_when applying the treatment for opted-in companies, orNACIONAL_ OPTION CCC_when checking the state registration of an NF-e recipient.REGISTRATIONS - Sales to the Manaus Free Trade Zone: file
SUFRAMA_with the invoice of incentivized sales, as described in SUFRAMA in the API.REGISTRATION - Rural producers: issue
CCC_in the CPF dossier to document the state registration of producers who are natural persons.REGISTRATIONS - Audit: keep the dossier of the counterparties of relevant contracts and transactions with the documentation of each transaction.
In the app
On the platform, the Certificates button on the record page issues the same certificates for a CNPJ, as a single PDF or one file per certificate, with the maximum age chosen in the dialog, as explained in Issue certificates as PDF. Certificates for a CPF exist in the API only.
Notes
- A live issue can take a few seconds. Set your HTTP client timeout above 60 seconds, as Limits and errors explains.
- Keep the PDF you receive: every request is charged, even when the certificates come from cache.
- Keep the default
maxAgefor archiving and periodic reviews, shorten it only when the decision requires a recent certificate, and request both Receita Federal certificates together only when you need both. - Responses carry no cost headers. The consumption of each request appears in Requests.
- All parameters are in Issue CNPJ dossier and Issue CPF dossier.