> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nmbr.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Receiving webhooks based on events

## Registering Webhooks

Before receiving webhook calls a webhook URL must be registered using the Webhook API Endpoint.

## Webhook Structure

Webhooks across the Nmbr API follow a consistent JSON structure that includes:

* the event
* the resource
  * type
  * identifier
  * external reference (`external_ref`), if the resource type supports setting an external reference
  * company identifier, if the resource type is scoped to a company

The webhook call made when a business entity is created would have the following properties:

```json theme={null}
{
  "event": "resource_created",
  "resource": {
    "type": "business_entity",
    "id": "<id>",
    "external_ref": "<ref>",
    "company_id": "<id>"
  }
}
```

The webhook call made when a company is created would have similar properties:

```json theme={null}
{
  "event": "resource_created",
  "resource": {
    "type": "company",
    "id": "<id>",
    "external_ref": "<ref>"
  }
}
```

Note that the call doesn't include the `company_id` property because the resource is the company itself and so its identifier is in the `id` property.

The webhook structure does not contain additional entity data. It is recommended the receiving system performs a GET request for the specific entity to retrieve the most up-to-date resource.

## Webhook Security

Nmbr will automatically generate a `key` for each webhook created. Any outgoing webhook calls will include a `Webhook-Signature` header with an HMAC SHA256 hash of the payload using the webhook `key`. Consumers may calculate their own signature using the known `key` and payload to compare to the request header. If the resulting signatures match the developer can be confident the request came from Nmbr.

## Webhook Events

Most resources support 3 standard events:

* `resource_created`
* `resource_updated`
* `resource_deleted`

Some resources have additional events that can be used to determine the state of the resource:

* `payroll_approved`

The following table outlines each resource and the corresponding supported events.

| Resource                      | Type                            | Supported Events                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Accounting Code               | `accounting_code`               | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Accounting Code Rule          | `accounting_code_rule`          | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Adjustment                    | `adjustment`                    | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Allowance                     | `allowance`                     | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Async Task                    | `async_task`                    | <ul><li>`async_task_completed`</li></ul>                                                                                                                                                                                                                                                                                                                                 |
| Bank Account                  | `bank_account`                  | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Business Entity               | `business_entity`               | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li><li>`integration_authentication_success`</li><li>`integration_authentication_failure`</li><li>`integration_sync_account_codes_complete`</li><li>`integration_sync_account_codes_failure`</li><li>`integration_sync_tags_complete`</li><li>`integration_sync_tags_failure`</li></ul> |
| Business Preset               | `business_preset`               | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Company                       | `company`                       | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Contractor                    | `contractor`                    | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Deduction                     | `deduction`                     | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Earning                       | `earning`                       | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Employee                      | `employee`                      | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Employee Benefit              | `employee_benefit`              | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Employer Benefit              | `employer_benefit`              | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Form Batch                    | `form_batch`                    | <ul><li>`form_batch_completed`</li></ul>                                                                                                                                                                                                                                                                                                                                 |
| Overtime Rate                 | `overtime_rate`                 | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Pay Rate                      | `pay_rate`                      | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Pay Schedule                  | `pay_schedule`                  | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Pay Split                     | `pay_split`                     | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Pay Stub                      | `pay_stub`                      | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li><li>`pay_stub_available`</li></ul>                                                                                                                                                                                                                                                  |
| Payroll                       | `payroll`                       | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li><li>`payroll_approved`</li><li>`payroll_unapproved`</li><li>`payroll_paid`</li><li>`payroll_deadline_upcoming`</li><li>`integration_sync_journal_entries_complete`</li><li>`integration_sync_journal_entries_failure`</li></ul>                                                     |
| Reimbursement                 | `reimbursement`                 | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Remittance Account            | `remittance_account`            | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Remittance Account Enrollment | `remittance_account_enrollment` | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Tag                           | `tag`                           | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Tag Group                     | `tag_group`                     | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Vacation Pay Setting          | `vacation_pay_setting`          | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
| Work Assignment               | `work_assignment`               | <ul><li>`resource_created`</li><li>`resource_updated`</li><li>`resource_deleted`</li></ul>                                                                                                                                                                                                                                                                               |
