Timesheet Webhook Example

One of the most common events that developers may want to know about from the Deputy system is when Timesheets are either added or updated in the client install. This can easily be achieved by adding a Webhook to the client install for the Timesheet events.

Below are some example POST requests that will add a Timesheet Webhook to a client install.

📘

https://webhook.site

This website is a simple tool which allows developers to see Webhook events coming through in a web interface. It's a great tool for troubleshooting any problems that may be occuring.

📘

URL for Webhooks

To add or update webhooks the URL is always the same format
https://{clientinstall}.{geo}.deputy.com/api/v1/resource/Webhook

Basic Add Timesheet Webhook event

This request will setup a Webhook that tells you every time a Timesheet is added to the install with no filtering.

{
    "Topic": "Timesheet.Insert",
    "Enabled": 1,
    "Type": "URL",
    "Address": "https://webhook.site/a90b0a6b-43e9-4755-8bf5-3518980d373a"
}

If you wanted to temporarily stop this Webhook after it has been added, you can send a POST request with Enabled: 0 to this endpoint.

Timesheet Updated Event

If you want to know when a Timesheet is updated, how your webhook should be configured is determined by whether you want to only know when a timesheet is changed, or every time a timesheet is saved even without any changes.

Every time the timesheet is saved example

{
    "Topic": "Timesheet.Save",
    "Enabled": 1,
    "Type": "URL",
    "Address": "https://webhook.site/a90b0a6b-43e9-4755-8bf5-3518980d373a"
}

Only trigger the event when a change is made to a timesheet example

{
    "Topic": "Timesheet.Update",
    "Enabled": 1,
    "Type": "URL",
    "Address": "https://webhook.site/a90b0a6b-43e9-4755-8bf5-3518980d373a"
}

Adding a filter to a Webhook setup

There may be times that you want to only know the Timesheet events for a specific date, or employee. Rather than handling this at the application side, you can set a filter so the Deputy install knows not to send particular events to your backend.

{
    "Topic": "Timesheet.Insert",
    "Enabled": 1,
    "Type": "URL",
    "Filters": {
        "isInProgress": 1
    },
    "Address": "https://webhook.site/a90b0a6b-43e9-4755-8bf5-3518980d373a"
}

This example will filter so that only those timesheets which are currently in progress (ie: the employee is currently on shift) will be triggered into the Webhook.