RocketPVA

Machine translation, not yet reviewed.

Transmission flow

This guide shows a complete transmission flow for files already validated in the PVA module.

This guide shows a complete transmission flow for files already validated in the PVA module.

Overview

After a file has been validated with no errors or with warnings only, you can perform the signing and transmission process using the PVA module APIs. Some concepts are described below.

Digital certificate

The PVA module uses A1 type certificates. Before any transmission, you must upload the certificate in pfx format. Both the certificate and its password are stored securely and encrypted, and are used only in the signing and transmission process. After the upload, no user can download the certificate or view its password. This upload only needs to be done once, when you start using the certificate, and again later when it expires.

Signatories

A signatory is anyone who takes part in some way in the signing process of the bookkeeping in the PVA. For SPEDs of type ICMS_IPI (Fiscal) and CONTRIBUICOES (PIS/COFINS), there is only one signatory, identified by the CNPJ (Brazilian company tax ID) of the bookkeeping's company itself. For files of type CONTABIL (ECD), there will be more than one signatory, who may be individuals or legal entities. Each signatory must have a digital certificate. When a file is validated, the PVA module tries to find a digital certificate with the same root CNPJ or the same CPF (Brazilian individual tax ID) as the signatory. If it finds one, it is automatically associated with the signatory. Otherwise, you must use an API to associate a certificate with the signatory. In either case, you can always change a signatory's certificate at any time, as long as the transmission has not yet been performed.

Signing and transmission

When all signatories have their certificates properly associated, you can use the signing and transmission API, which starts the process. Once it has started, the bookkeeping status moves to TRANSMITTING at the beginning of the process and then to TRANSMISSION_FAILED or TRANSMISSION_SUCCEEDED, for failure or success of the process, respectively. To check the current status, just use the endpoints already used in the validation flow.

Flow

Below is a complete flow using the transmission process APIs

Preparation: upload certificates

We use the Certificate Upload endpoint to send the certificate. This is a simple multipar/form-data endpoint with 2 attributes:

Upload certificatePOST/integration/api/certificate/uploadSign in to see the host and reference
  • file: containing the bytes of the certificate file in pfx format
  • password: the certificate password

If desired, you can use the Data preview / confirmation endpoint, which accepts the same parameters as the upload, but the PVA module will only validate the provided data and return a preview of the certificate data such as CNPJ, issuer, validity, etc. This step is optional.

Preview certificatePOST/integration/api/certificate/upload/previewSign in to see the host and reference

At any time, you can use the Certificate Listing endpoint to keep track of the certificates already uploaded and/or those close to expiring.

List certificatesGET/integration/api/certificateSign in to see the host and reference

Step 1: Associate the certificates with the signatories

After validation with no errors or with warnings only, we can associate the certificates with the signatories.

We list the bookkeeping's signatories with the Signatory Listing endpoint. All returned records whose certificate attribute has the value null are pending certificate association.

List signatoriesGET/integration/api/bookkeeping/{bookkeepingId}/signatoriesSign in to see the host and reference

For each signatory without a certificate, we Associate a certificate using this endpoint, providing the signatory id and the certificate id.

Associate certificate with signatoryPATCH/integration/api/bookkeeping/{bookkeepingId}/signatories/{signatoryId}/certificate/{certificateId}Sign in to see the host and reference

Step 2: Perform the signing and transmission

We use the Sign and Transmit endpoint, providing the bookkeeping id. If any transmission criterion is not met, such as a file validated with errors or a signatory pending certificate association, an error message will be returned. Otherwise, a success status will be returned and the client application can track the TRANSMITTING, TRANSMISSION_FAILED and TRANSMISSION_SUCCEEDED statuses using the endpoint to Query the data of a bookkeeping.

Sign and transmitPATCH/integration/api/bookkeeping/{bookkeepingId}/transmitSign in to see the host and reference
Get bookkeepingGET/integration/api/bookkeeping/{bookkeepingId}Sign in to see the host and reference

On this page