Register the URL
The owner of the organization registers the URL in Settings › Webhooks:- Enter an HTTPS URL of your system.
- Check the event
document.reading.finished. - Copy the secret that the screen shows. The screen shows the secret only once.
- pauses, resumes and removes the URL;
- rotates the secret;
- sees the last 50 deliveries of each URL, with the attempts of each one.
- a URL without HTTPS;
- a URL with a user and a password;
- an internal IP address.
The notice
QX sends aPOST to the URL, with a JSON body:
ididentifies the event. The same notice can arrive more than once with the sameid.data.reading.stateiscomplete,failedorno_reader.data.external_idis the external id of the upload, ornull.- The notice carries the ids, the state and the time of the reading, and the path of the document. For the fields, call
GET /documents/{id}with the API key. - The event tells that the reading ended. The validations of the collection can run after the notice.
- A document of a type with no automatic reading sends no notice, because its reading does not start.
POST carries these headers:
Check the signature
The signature is the HMAC-SHA256 of a text, with the secret of the URL. The text ist, a dot and the exact body of the POST. Check the signature before you read the body:
- Split
tandv1from theX-QX-Signatureheader. - Refuse the notice when
tis more than 5 minutes away from your clock. - Compute the HMAC-SHA256 of
"#{t}.#{body}"with the secret. - Compare the result with
v1in a constant-time comparison.
Answer and handle repeats
- Answer with any
2xxstatus to confirm the delivery. QX ignores the body of the answer. - QX waits 5 seconds to connect and 10 seconds for the answer. Answer at once and process the notice later.
- QX does not follow a redirect.
- The same notice can arrive more than once, and two notices can arrive out of order. Drop a repeated
idand read the current state through the API.
Retries
QX tries again when the delivery fails for one of these reasons:- a network failure, or a name that does not resolve;
- a timeout;
- an answer
408,429or5xx.
The other answers outside
2xx end the delivery with no retry: a 4xx other than 408 and 429, and a redirect. The fifth failure also ends the delivery.
QX does not send an ended delivery again. To find an end of a reading that did not arrive, call the API from time to time, for example with GET /documents?external_id=.
A paused URL keeps the deliveries in the queue. The resume puts the due deliveries in the send queue. A removed URL cancels the queued deliveries.
Rotate the secret
The new secret works at once: the next notice goes out with the new secret. During the rotation, follow this order:- Pause the URL.
- Rotate the secret.
- Update the secret in your system.
- Resume the URL. QX puts the due deliveries in the send queue, with the new secret.