Skip to content
CNPJ card and PDF certificates in the API
API · Features

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

OperationMethod and pathAccepted certificates
Issue CNPJ dossierGET /v2/establishments/{taxId}/dossierAll five
Issue CPF dossierGET /v2/individuals/{taxId}/dossierCCC_REGISTRATIONS and SUFRAMA_REGISTRATION

Each certificate has a code, sent in the certificates parameter. The content and source of each one are in Available certificates.

CodeCertificate
RFB_REGISTRATIONCNPJ registration and status, the cartão CNPJ
RFB_PARTNERSPartners and administrators board
SIMPLES_NACIONAL_OPTIONSimples Nacional option
CCC_REGISTRATIONSState registrations, in one state
SUFRAMA_REGISTRATIONSUFRAMA registration

Both operations take the same parameters:

ParameterLocationRequiredContent
taxIdPathYesCNPJ with 14 characters or CPF with 11 digits, with no punctuation
certificatesQueryYesCertificate codes, separated by commas, with at least one and no repeats. The order of the codes sets the order in the PDF
maxAgeQueryNoMaximum data age accepted for cached certificates, from 5m to 1y. Default: 45d
  • A code the operation does not accept, such as RFB_REGISTRATION in the CPF dossier, a repeated code or a maxAge in the wrong format are rejected with 400 REQUEST_VALIDATION_FAILED.
  • Dossiers do not accept the access without a key described in Public access: a request without a key returns 401 API_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.

  • maxAge applies to every certificate in the request. There are no per-certificate limits, like stateRegistry.maxAge in Lookup CNPJ. The syntax is in Max age and partial success.
  • 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/pdf:

  • 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 400 REQUEST_VALIDATION_FAILED.
  • A CNPJ that is not in cached data yet is queried live at the Receita Federal before the dossier is issued.
  • 404 ESTABLISHMENT_NOT_FOUND means the CNPJ is not registered with the Receita Federal.

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_REGISTRATIONS 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, with expand=stateRegistry and the states in stateRegistry.states, as described in State registrations in the API, then issue the dossier.
  • SUFRAMA_REGISTRATION queries the SUFRAMA registry even for a CPF not yet known to the API.

Important: 404 INDIVIDUAL_NOT_FOUND means the API knows no state registration of the CPF and SUFRAMA found no registration, when SUFRAMA_REGISTRATION is requested. A CPF not yet known to the API, requested only with CCC_REGISTRATIONS, returns 404 without 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 in 404: when a 404 is 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 404 ESTABLISHMENT_DOSSIER_EMPTY in Issue CNPJ dossier or 404 INDIVIDUAL_DOSSIER_EMPTY in Issue CPF dossier. That 404 consumes what each omitted certificate consumes, as in Omitted certificates.
  • When your integration already looks up the CNPJ as JSON with company.taxRegime, stateRegistry or suframa in expand, 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 200 response.
  • 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 the 404 described 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 206 as 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

StatusCodeCauseAction
400REQUEST_VALIDATION_FAILEDcertificates missing, empty, with a repeated code or a code the operation does not accept; maxAge in the wrong format; malformed CNPJ or CPF; unknown parameterFix what errors points to
401API_KEY_MISSINGRequest without an API key. Dossiers do not accept public accessSend the key in the Authorization header
402CACHED_QUERY_QUOTA_EXCEEDED, LIVE_QUERY_QUOTA_EXCEEDED or OVERAGE_BUDGET_EXCEEDEDThe organization’s quota or overage budget is used up. What each code means is in Error codesFollow one of the ways out in Quota used up
404ESTABLISHMENT_NOT_FOUNDThe CNPJ is not registered with the Receita FederalCheck the CNPJ. The 404 is also charged, under the metering rules: retry only when the registration may have changed
404INDIVIDUAL_NOT_FOUNDThe API knows no state registration of the CPF and SUFRAMA found no registration, or failed on the first request for the CPFLook up the registrations in Lookup CPF first or retry later, as described in Issue CPF dossier
404ESTABLISHMENT_DOSSIER_EMPTY or INDIVIDUAL_DOSSIER_EMPTYNone of the requested certificates is available for the CNPJ or CPF, for the reasons in Omitted certificatesRequest only the certificates that should exist. The 404 consumes what each omitted certificate consumes
504REQUEST_TIMED_OUTThe request did not finish within 60 secondsRetry 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_REGISTRATION and RFB_PARTNERS with a short maxAge and 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_NACIONAL_OPTION when applying the treatment for opted-in companies, or CCC_REGISTRATIONS when checking the state registration of an NF-e recipient.
  • Sales to the Manaus Free Trade Zone: file SUFRAMA_REGISTRATION with the invoice of incentivized sales, as described in SUFRAMA in the API.
  • Rural producers: issue CCC_REGISTRATIONS in the CPF dossier to document the state registration of producers who are natural persons.
  • 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 maxAge for 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.

Informational content that may change without notice. It is not tax, accounting or legal advice, and CNPJá's terms and policies prevail over this page.