Webhook is a user-friendly callback over http/https. You can use Deputy webhooks to notify your app or syncing service when particular events have taken place in Deputy. As opposed to constant polling, data is delivered proactively by Deputy to you! To learn more about webhooks, check out :

Registration

Hooks themselves are saved as Resource inside Deputy. So you can use all the regular Resource actions to save and update a hook. You can also do it via UI. Go to yourinstall.region.deputy.com/exec/devapp/webhooks

image

Or call via API

$.post("/api/v1/resource/Webhook",
JSON.stringify({
Topic: "Timesheet.Insert",
Enabled: 1,
Type: "URL",
Address: "https://requestb.in/XXXXXXX",   // Your URL
Filters: "IsInProgress:1\nEmployee:1",
Headers: "Authorization: Bearer XXXXXX"
}),
function(x){ console.log(x);}
);

Properties of Webhook Registration

Topic

The Topic (or Event) for which you want notification. Deputy supports various topics for webhook:

URL/Address

The destination address. Must be a fully qualified URL with http or https

Type

URL or SQS.

Headers

key value pairs each separated by newline

Filters

If you want to filter the hook to be fired only for a certain filter. Eg. Only fire a Timesheet hook if employee starts shift would be Timesheet.Insert with filter IsInProgress : 1

Enabled

0 or 1. You can turn off a hook temporarily

Headers

You can add additional headers that will be sent to the Destination. These can be authorization or specific driver you may have for your script. E.g. add Authorization : XXXXXX

Each of the headers must be of format KEY: VALUE and separated by newlines. E.g.

Authorization: Bearer XXXXXXX
X-My-Speacial-Header: YYYYYYYYYY

Filters

Filters are handy if you only want only certain information. E.g. Only send timesheets that are approved (Add filter PayRuleApproved: 1)

Timeout and Retries

Webhooks are pushed with a 10 second timeout. So you must consume the data ASAP and close the request. Deputy expects a 200 (or 2XX) http code return. If not, we will retry posting 5 times with 1 minute break between each before abandoning the request completely.

Payload of webhook

Deputy will post the webhook in JSON format. The JSON will be an object which has a topic and data property: [topic => topic_name , data => OBJECT or [OBJECT]]

Deputy will also add following three headers

  • X-Deputy-Secret : Checksum of the data payload which is sha256 hmac of the body, salted with a secret key (Check Enterprise->Security Settings->Private Key for API Signing)
  • X-Deputy-Webhook-Callback : The resource URL of the webhook that generated this hook call
  • X-Deputy-Generation-Time : Unixtimestamp of when this was sent!

Testing Webhooks

To see what Webhook generates as payload, try using web services like

Win $10,000 by telling people about Deputy!