Since the scanning is performed in the background after upload, you might be interested in knowing when it is done. Once way of doing this is by our optional callback functionality, where we will call an URL of your choice for each voucher.

When using this functionality it will trigger several callbacks telling you how far the voucher is in the flow and what features are now available on that specific voucher.

The first callback is triggered when the various thumbnails have been generated on the voucher. Paperflow always generates a thumbnail of the following sizes: 128px, 256px, 512px, 768px 1024px. For PDF’s this will only be the first page.

GET <callback_url>?voucher_id=<voucher_id>&event=thumbnailed

The next callback is only triggered if validation is activated, this is to tell you that our basic AI scan has now been finished and can be read from the voucher BUT the validated data is not yet done.

GET <callback_url>?voucher_id=<voucher_id>&event=scanned

The last callback will be called when the voucher is done.

GET <callback_url>?voucher_id=<voucher_id>&event=success

In the case where your callback URL already has query parameters, we will include these, and add the above parameters at the end.

In order to use this, you need to supply the callback URL when uploading a voucher, which means you must send a JSON payload instead of the raw binary data of the voucher when uploading the voucher.


HTTP headers:
  Accept: application/json
  Authorization: Bearer <token>
  Content-Type: application/json

HTTP body:
  "voucher_data": "<base64 of the voucher data>",
  "callback_url": "",

Note that voucher_data is the base64 encoding of the voucher, instead of the raw data. Also note that you need to supply correct content type in the header.
For this example, Bilagscan will ping the URL GET<voucher_id>&event=success once the data is ready. If the callback URL does not return status 200, Bilagscan will try again after 10 minutes, up to three times in total.