Webhooks
A guide on how to setup webhooks for Omnidesk
With webhooks, you can trigger http-request to your own backend based on events that occur in Omnidesk. Our implementation of webhooks conforms to the Standard Webhooks specification:
Webhook-endpoints consist of an
HTTPS-URL and a list of subscribed events.A
POST-request is send to this URL whenever one of the subscribed events occur within Omnidesk.Failed webhook-requests are retried up to 5 times on an exponential backoff schedule with base 2.
Each webhook-request has a signature so that webhook-consumers can verify if it was send by a legitimate source.
Creating Webhook Endpoints
First, you will need to host some HTTP-server that will function as the handler of your. The minimal requirements for a webhook endpoint are as follows:
It MUST be publicly accessible (so without authentication) by our backend servers. Also, there MUST be a valid
HTTPS-URL that points to your endpoint.It MUST respond to
OPTIONS-requests with a200or204status code. This response also MUST have anAllow-header that containsPOST. We use this on our backend to verify if your endpoint is (still) safe use.It MUST respond to valid
POST-requests within 1 second with a2xx-response (when the webhook-message is accepted) OR a5xx-response (when some internal error occurs while parsing the message). You should give an early202-response when you expect that some tasks in the webhook endpoint can take longer than 1 second.
You can create a new webhook endpoint in the Omnidesk UI after you started your webhook consumer:
Go to Admin Settings > Webhooks and click on Create.
Give the URL of your endpoint.
Choose the events to which you endpoint should subscribe.
Click on Create.
Our backend will check if your webhook-consumer satisfies (1) and (2) of the minimal requirements when creating a new endpoint. Please check your backend server if you get an error when creating a new webhook-endpoint.
Minimal example (NodeJS)
This example is a minimal implementation of a valid webhook endpoint handler written for NodeJS. The minimal requirements are satisfied by:
Handling
OPTIONS-requests that is expected by our backend.Sending a
202-response toPOST-requests as soon as it has received the body. Note that the response is send before it starts any long-running tasks.
IMPORTANT! Only use this example during development, debugging or for exploring the possibilities of our Websockets feature. It is NOT safe to use this example in production environments, because it does not check if the webhook-request comes from a legitimate source!
Example with signature verification (NodeJS)
Below, you can find a minimal example implementation of a webhook handler written for NodeJS. It uses the asymmetric (ed25519) signature to verify that the incoming webhook-requests were send from our backend.
Handles the
OPTIONSrequest to allow our backend to verify that your webhook-endpoint is safe to use.Checks if the request has all required headers to verify the incoming webhook-request.
Checks if the
webhook-timestampis close enough to the timestamp of your backend (to prevent replay-attacks).Verifies that the
webhook-signaturematches the contents of this of the webhook-request.
You can find an example on how to validate webhook requests with a shared secret (HMAC-SHA256) in the standard webhooks example repository.
Last updated