HR-ON Webhook (1.0.0)

License: ISC

Webhook Guide


What is a Webhook?

A webhook is a way for HR-ON Staff to notify your application about events in real-time. It allows you to receive notifications about events automatically when they occur in HR-ON Staff, without having to poll the API for updates continuously. Webhooks are useful for automating data synchronization between HR-ON Staff and your internal systems or to trigger actions in your application based on specific events that occur in HR-ON Staff.
For example, you can set up a webhook to notify your application whenever a new employee is created, or when an employee's information is updated.

Rules

  • A webhook must be verified in order to receive any events, including forced test events from the Trigger Webhook endpoint.
  • Your endpoint must be publicly accessible and reachable from the internet. It cannot be a localhost or private IP address.
  • Your endpoint must be able to handle POST requests and must respond with a 200 OK status code to received events.
  • Your endpoint must respond to events within 10 seconds.
  • If your specified URL is either unreachable or fails to respond with a 200 OK status in time, then after 10 consecutive failures, the webhook will be deactivated and must be re-verified.
  • All webhook events are sent as POST requests to the specified URL.
  • All webhook events contain your specified token in the X-HR-ON-Token header.

How to Use Webhooks


1. Create a Webhook

To create a webhook, you need to send a POST request to the Create Webhook endpoint with the following parameters:

  • endpoint: The URL where the webhook will send data.
  • eventNames: An array of events that will trigger the webhook.
  • token: A unique token that will be sent with the webhook request to verify its authenticity.

Example creation request:

POST /webhooks
Host: https://webhook.hr-on.com/v1
Content-Type: application/json

Body: {
  "endpoint": "https://your-webhook-receiver-url.com",
  "eventNames": ["EmployeeCreated", "EmployeeUpdated"],
  "token": "your_unique_token_here"
}

You can see the full list of response properties in the Create Webhook endpoint documentation, but the most important one is id, which is the unique identifier for the webhook you just created. You will need this ID to manage your webhook in the next steps.


2. Verify the Webhook

After creating the webhook, you need to verify it using the Verify Webhook endpoint.
The verification process involves your endpoint receiving a POST request with a payload containing a randomly generated 64 byte string, which your endpoint must return in the response body.

Example verification request:

POST /webhooks/{webhookId}/verify
Host: https://webhook.hr-on.com/v1
Content-Type: application/json

If everything is set up correctly, and your endpoint responded with a 200 OK status and the same 64 byte string in the response body, your webhook will be verified.


3. Testing Webhook Events (Optional)

You can test your webhook by triggering a test event using the Trigger Webhook endpoint. This will send a sample event to your webhook endpoint, allowing you to verify that it is working correctly.

Example test request:

POST /webhooks/{webhookId}/trigger
Host: https://webhook.hr-on.com/v1
Content-Type: application/json

Body: {
  "eventName": "EmployeeCreated",
}

Your endpoint will receive a POST request with a sample payload matching what you would receive in a real event. You will always receive the following properties in the payload:

  • message - A user friendly message describing the event.
  • eventName - The name of the event that was triggered.
  • sentAt - The date and time when the event was sent.

You will also receive one of the following properties, depending on the event name:

  • employeeId - The ID of the employee that was created or updated.
  • departmentId - The ID of the department that was created or updated.
  • documentId - The ID of the document that was uploaded or deleted.

Do note that any IDs from these test events are fake and will not correspond to any real data in your HR-ON Staff account.


4. Consuming Webhook Events

When your endpoint receives a webhook event, you are then able to consume it and take action based on the event. The payload will contain the same properties as the test event, but with real data. The most common use case is to update your internal systems with new data from HR-ON Staff, when an employee is updated.
Below is an example of how this simple flow could look like:

You receive a webhook event with the following payload:

{
  "message": "An employee has been updated",
  "eventName": "EmployeeUpdated",
  "sentAt": "2025-06-17T11:00:00.000Z",
  "employeeId": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
}

You then make a request to the HR-ON Staff API to get the employees data:

GET /employees/3fe2987b-ef4e-4b7c-b321-89585e2a4178
Host: https://api.hr-on.com/v1/staff
Authorization: Bearer your_access_token_here

You can then use the data from the response to update your internal systems with the new employee data.


CreateWebhook

Creates a new webhook. For it to receive events, it then has to be verified.

Authorizations:
JWT
Request Body schema: application/json
endpoint
required
string

The endpoint that should receive events. The endpoint should have either "http://" or "https://" in front of the URL

eventNames
required
Array of strings (WebhookEventName)
Items Enum: "DepartmentCreated" "DepartmentDeleted" "DepartmentUpdated" "DocumentDeleted" "DocumentUploaded" "EmployeeCreated" "EmployeeDeleted" "EmployeeUpdated"

A list of the event names to subscribe for.

token
required
string

A user-specified token used to verify that requests were sent by HR-ON. This token will be set as a header called 'X-HR-ON-Token' in every event sent to the endpoint.

Responses

Response Schema: application/json
required
object (IWebhook)

Used for generating docs with tsoa express controllers.

success
required
boolean

Whether or not the request was successful

Request samples

Content type
application/json
{
  • "endpoint": "string",
  • "token": "string",
  • "eventNames": [
    • "DepartmentCreated"
    ]
}

Response samples

Content type
application/json
{
  • "success": true,
  • "item": {
    • "id": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
    • "companyId": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
    • "endpoint": "string",
    • "token": "string",
    • "verifiedAt": "string",
    • "createdAt": "string",
    • "updatedAt": "string",
    • "failed": 0,
    • "events": [
      • {
        • "name": "string",
        • "description": "string"
        }
      ]
    }
}

DeleteWebhook

Deletes a specific webhook given its UUID.

Authorizations:
JWT
path Parameters
id
required
string

The UUID of the webhook.

Responses

Response Schema: application/json
message
required
string

A user friendly message

success
required
boolean

Whether or not the request was successful

Request samples

curl --request DELETE \
  --url https://webhook.hr-on.com//v1/webhooks/%7Bid%7D \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "string"
}

GetWebhook

Fetches a specific webhook given its UUID.

Authorizations:
JWT
path Parameters
id
required
string

The UUID of the webhook.

Responses

Response Schema: application/json
required
Array of objects (IWebhook)
required
object (PageInfo)

Request samples

curl --request GET \
  --url https://webhook.hr-on.com//v1/webhooks/%7Bid%7D \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'

Response samples

Content type
application/json
{
  • "items": [
    • {
      • "id": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
      • "companyId": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
      • "endpoint": "string",
      • "token": "string",
      • "verifiedAt": "string",
      • "createdAt": "string",
      • "updatedAt": "string",
      • "failed": 0,
      • "events": [
        • {
          • "name": "string",
          • "description": "string"
          }
        ]
      }
    ],
  • "pageInfo": {
    • "size": 0,
    • "offset": 0,
    • "total": 0
    }
}

GetWebhooks

Fetches all webhooks. Use size and offset parameters to paginate through the results.

Authorizations:
JWT
query Parameters
eventName
string
Enum: "DepartmentCreated" "DepartmentDeleted" "DepartmentUpdated" "DocumentDeleted" "DocumentUploaded" "EmployeeCreated" "EmployeeDeleted" "EmployeeUpdated"

Filters webhooks by the given event name.

offset
integer <int32>

Specifies the amount of items to skip before selection.

size
integer <int32>

Specifies the amount of items to be returned. Defaults to 20.

Responses

Response Schema: application/json
required
Array of objects (IWebhook)
required
object (PageInfo)

Request samples

curl --request GET \
  --url 'https://webhook.hr-on.com//v1/webhooks?size=SOME_INTEGER_VALUE&offset=SOME_INTEGER_VALUE&eventName=SOME_STRING_VALUE' \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'

Response samples

Content type
application/json
{
  • "items": [
    • {
      • "id": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
      • "companyId": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
      • "endpoint": "string",
      • "token": "string",
      • "verifiedAt": "string",
      • "createdAt": "string",
      • "updatedAt": "string",
      • "failed": 0,
      • "events": [
        • {
          • "name": "string",
          • "description": "string"
          }
        ]
      }
    ],
  • "pageInfo": {
    • "size": 0,
    • "offset": 0,
    • "total": 0
    }
}

TriggerWebhookEvent

Triggers an event for the given webhook subscription. Response body will contain properties based on the event, and holds the same properties as a real webhook event of the same type would. For example, if the event is 'EmployeeCreated', the response body will contain the employeeId. In order for your endpoint to receive events, it first needs to be verified. Use for testing if your endpoint correctly receives events from the webhook subscription

Authorizations:
JWT
path Parameters
id
required
string

The UUID of the webhook

Request Body schema: application/json
eventName
string (WebhookEventName)
Enum: "DepartmentCreated" "DepartmentDeleted" "DepartmentUpdated" "DocumentDeleted" "DocumentUploaded" "EmployeeCreated" "EmployeeDeleted" "EmployeeUpdated"

Responses

Response Schema: application/json
eventName
required
string (WebhookEventName)
Enum: "DepartmentCreated" "DepartmentDeleted" "DepartmentUpdated" "DocumentDeleted" "DocumentUploaded" "EmployeeCreated" "EmployeeDeleted" "EmployeeUpdated"
message
required
string
sentAt
required
string
departmentId
string
documentId
string
employeeId
string

Request samples

Content type
application/json
{ }

Response samples

Content type
application/json
{
  • "message": "string",
  • "eventName": "DepartmentCreated",
  • "sentAt": "string",
  • "employeeId": "string",
  • "departmentId": "string",
  • "documentId": "string"
}

UpdateWebhook

Updates the webhook based on the given UUID. After it is updated, it needs to be verified again, in order to receive events.

Authorizations:
JWT
path Parameters
id
required
string

The UUID of the webhook.

Request Body schema: application/json
endpoint
string

The endpoint that should receive events.

eventNames
Array of strings (WebhookEventName)
Items Enum: "DepartmentCreated" "DepartmentDeleted" "DepartmentUpdated" "DocumentDeleted" "DocumentUploaded" "EmployeeCreated" "EmployeeDeleted" "EmployeeUpdated"

A list of the event names to subscribe for.

token
string

A user-specified token used to verify that requests were sent by HR-ON. This token will be set as a header called 'X-HR-ON-Token' in every event sent to the endpoint.

Responses

Response Schema: application/json
required
object (IWebhook)

Used for generating docs with tsoa express controllers.

success
required
boolean

Whether or not the request was successful

Request samples

Content type
application/json
{ }

Response samples

Content type
application/json
{
  • "success": true,
  • "item": {
    • "id": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
    • "companyId": "3fe2987b-ef4e-4b7c-b321-89585e2a4178",
    • "endpoint": "string",
    • "token": "string",
    • "verifiedAt": "string",
    • "createdAt": "string",
    • "updatedAt": "string",
    • "failed": 0,
    • "events": [
      • {
        • "name": "string",
        • "description": "string"
        }
      ]
    }
}

VerifyWebhook

Verifies a webhook. A payload containing a randomly generated 64 byte string will be sent in the body of a POST request to your endpoint. Return the payload in its entirety in your response body to verify the webhook.

Authorizations:
JWT
path Parameters
id
required
string

The UUID of the webhook

Responses

Response Schema: application/json
message
required
string

A user friendly message

success
required
boolean

Whether or not the request was successful

Request samples

curl --request POST \
  --url https://webhook.hr-on.com//v1/webhooks/%7Bid%7D/verify \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "string"
}