Webhooks allow clients the ability to build or configure applications which subscribe to certain events on PainChek. When a subscribed event is triggered, PainChek will send an HTTP POST payload to the webhook's configured URL.
PainChek webhooks can be used to integrate assessment data into existing patient management systems or as a way of extending the functionality of PainChek based on the client's own event-based requirements.
Multiple destination URLs can be configured for a single endpoint, and there is no limit to how many events the client can subscribe to.
When the API receives a new event, it is saved into the PainChek database. If that event happens to have a webhook subscription associated with it, it is also added to the Webhook Queue. The PainChek Webhook Service pulls down the messages from the queue and submits it to the clients configured URL. The client at the registered URL is expected to acknowledge the message receipt with an HTTP 200 status response. As soon as the acknowledgement is received, the message is removed from the queue.
Error Flow: If the client's URL is down or the service receives a 400 or 500 error (a non-2xx response), then an error alert is produced and the message is flagged for a retry. A retry job then periodically retries to submit the message to the client URL. If the client acknowledges the message during the retry period, then the message is removed from the queue. If a successful response is not received before the maximum number of retries is exhausted, the event is failed and removed from the queue.