1. Inicio
  2. Documentos
  3. NS BPe (English)
  4. BPe Issue Contingency API...
  5. Issuance/Check Issue Process Status

Issuance/Check Issue Process Status

The BP-e offline contingency issuance service developed by NS Tecnologia is responsible for validating the sent BP-e data, and managing the sending of the generated XML to sefaz.
This service has a sending queue for sefaz and notifies the returns securely through a webHook provided by the partner. It will not change anything in the existing issuance format, XML and PDF will be released in contingency to complete the sale, and the contingency service will be responsible for carrying out all attempts to authorize the document.

The figure below shows a summarized flowchart of how this management is done.

What changes in contingency issuance?
The emission process is the same as a normal emission in the BPe API, the only thing that will change is the return of the processing status query method.

Step 1:
Send the JSON or XML to the BP-e API, you can follow the official issuance documentation:

Step 2:
In the Processing Status query you will get the return of the document in the same default pattern that already exists, but with a new message in the cStat and xMotivo tags.

xMotivo:“Document Sent to Offline Contingency Queue”

This return above indicates that the BP-e was sent to our contingency queue, that is, it was not possible to issue it in normal mode, due to some problem or instability in the sefaz, so the document will be authorized at another time.
Note: the issue code in contingency will return cStat:-100, stay tuned to apply your business rule in programming following this return code.

Examples of return issued in offline contingency

    "status": 200,
    "motivo": "Consulta realizada com sucesso",
    "chBPe": "11111111111111111111111111111111111111111111",
    "cStat": "-100",
    "xMotivo": "Documento Enviado para Fila de Contingência Offline",
    "nProt": ""

Our Contingency Queue makes the first attempt to send it to each other every 5 minutes, after this time, if it is not able to authorize the document, it will wait 30 minutes for a new attempt to issue it. As soon as we receive a return from sefaz, the return will be sent to the partner at the URL configured in the administrative panel, through a web call via HTTP POST, from our webhook.
Note: The URL provided by the partner must have the https protocol enabled.

After obtaining the cStat:-100 and contingency generated BPe key, the download request can now be requested.

How do I configure my system to receive Contingency WebHook returns?

After issuing and downloading the BPe in contingency, it is necessary to wait for the return to know if the document was authorized at sefaz or rejected for some invalid data. Click the button below and stay in the loop.


* BPe’s with structure errors given in JSON or XML , will not be redirected to the API contingency queue.
* Errors of unsuccessful issuance attempt at sefaz, the BPe will be redirected to be issued in contingency.
* Digital certificate expired less than 24 hours, the BPe will be redirected to the contingency queue, it is important to be aware of the returns sent by the webHook to update the new digital certificate in the NS administrative panel.

Como podemos ajudar?