HireHop can send a message with data to other apps when certain events are triggered within HireHop.  This message is called a webhook which automatically pushes the relevant data to the required location.

WbhooksWhat is a webhook?

A webhook sends/pushes a message, with data attached to the message, when specific things happen in HireHop (an event).  Webhooks are sent via HTTP (calls a web address) and are a way of pushing data to other applications in real-time.  Webhooks deliver the relevant data to specific applications as it happens, meaning the receiving application gets data immediately after the event happens, which is far more efficient and faster than polling for data changes..

HireHop webhooks can be used to communicate directly with other apps or be sent to a connector like Zapier, that can be made to format the data and make any necessary API calls back to HireHop or to another application.

Setting up a webhook

In HireHop, go to „Settings“ then click the „Company settings“ tab and the „Webhooks“ button at the top of the page.  In the popup window, click on the „New“ button and add the URL where the webhook message is to be sent to and select every webhook that you want the URL to respond to.  You can add as many webhooks as you want, but should limit them to only the necessary ones that the specific URL will respond to.

A HireHop webhook will POST data to your URL endpoint as JSON, and will contain the following or similar data.

{
    "time": "2022-03-29 07:50:42",
    "user_id": 1,
    "user_name": "John Smith",
    "user_email": "john@email.com",
    "company_id": 1,
    "export_key": "22u43mrjwe7u",
    "event": "invoice.status.updated",
    "data": { ... },
    "changes": {
        "FIELD_NAME": {
            "from": "old",
            "to": "new"
        }, ...
    }
}

In the above JSON example, the following fields are:

  • time“ is the UTC time and date the webhook was sent.
  • user_id“ is the ID of the user who caused the event to be triggered.
  • user_name“ is their user’s name.
  • company_id“ field is the unique number identifier of the company the user works for.
  • export_key“ is the value of the export key in company settings which can be used as a security check.
  • event“ is the name of the webhook event that was triggered.
  • data“ is the data that appertains to the webhook event.
  • changes“ are the fields that changed, being what they were to what they got changed to.

HireHop will not wait for a response from the called URL or report an HTTP error from calling it.

Example PHP code for a URL endpoint to capture the webhook data would be:

<?php
	// Read the JSON data
	$postdata = file_get_contents('php://input');
	// Convert JSON data to an object
	$data_str = json_decode($postdata);
?>

 

Posted in API