Using the /webhooks set of endpoints in the product, custom callback behaviour can be configured to trigger upon specific events. The available events are:
document_text: this event triggers the sending of the document text obtained by OCR
document_split: this event triggers the sending of section information for a document
document_predict: this event triggers sending all predictions made on a document
document_evaluate: this event triggers sending the final, reviewed version of a document once feedback has been received
document_delete: this event triggers sending a document id when it is deleted
In general, the payload sent by the webhooks has the following form:
Code Block | ||
---|---|---|
| ||
{"event": "event_name", "organization": "organization_name", "data": {}} |
The expected payload in “data” for both the predict and evaluate event is the same as the default document JSON.
For the other events, the resulting output will have the following form:
document_text
Code Block | ||||
---|---|---|---|---|
| ||||
{"event": "document_text", "organization": "contractfit1", "data": {"id": "5e7a0daf255bf93741177061", "text": “example document text”}} |
document_split
Code Block | ||||
---|---|---|---|---|
| ||||
{"event": "document_split", "organization": "contractfit1", "data": {"id": "5e7a0df1800de5422a6f7776", "sections": [{"document_type": "invoice", "format": "5e20372a90d5ab65dd4a017a", "confidence": "91", "page": "0"}]}} |
document_delete
Code Block | ||
---|---|---|
| ||
{"event": "document_delete", "organization": "contractfit1", "data": {"id": "5e7a0df1800de5422a6f7776"}} |
In terms of configuring webhooks, the swagger documentation shows how to create webhooks using the POST method.
Some simple examples of configured webhooks for the “document_predict" and “document_evaluate” event (these examples are used internally to couple our UI with the API):
...
Upcoming extensions:
Authorization headers (in the “header” field)
A custom (static) authorization can be configured in the webhook, which will be sent back as header with the webhook’s POST request.Retry logic with exponential backoff. In case of the webhook receiving anything besides a succes status code (200), the webhook will re-attempt it’s delivery with an exponential backoff system (2^n seconds) for a maximum of 10 attempts.
Introduction of Inbox or Project specific webhooks. Currently, all documents processed in an organization trigger the same webhooks. The expansion would allow to specifically configure webhooks per Inbox or Project, as well as pass this information along in the payload.