[PERS SDK - v2.3.26](/sdk-reference/readme) / [Exports](/sdk-reference/modules) / WebhookApi

# Class: WebhookApi

Webhook API - Low-level API client for webhook operations

Backend routes:

- Admin CRUD: /hooks (requires tenant auth)
- Proxy/Trigger: /hooks/:projectKey/:hookId (public, identified by projectKey)
- Callback: /hooks/:projectKey/executions/:executionId/callback (public)


Use WebhookService or WebhookManager for higher-level operations

## Table of contents

### Constructors

- [constructor](/sdk-reference/classes/webhookapi#constructor)


### Methods

- [listWebhooks](/sdk-reference/classes/webhookapi#listwebhooks)
- [getWebhookById](/sdk-reference/classes/webhookapi#getwebhookbyid)
- [createWebhook](/sdk-reference/classes/webhookapi#createwebhook)
- [updateWebhook](/sdk-reference/classes/webhookapi#updatewebhook)
- [deleteWebhook](/sdk-reference/classes/webhookapi#deletewebhook)
- [triggerWebhook](/sdk-reference/classes/webhookapi#triggerwebhook)
- [listExecutions](/sdk-reference/classes/webhookapi#listexecutions)
- [getExecutionById](/sdk-reference/classes/webhookapi#getexecutionbyid)
- [sendCallback](/sdk-reference/classes/webhookapi#sendcallback)


## Constructors

### constructor

• **new WebhookApi**(`apiClient`): [`WebhookApi`](/sdk-reference/classes/webhookapi)

#### Parameters

| Name | Type |
|  --- | --- |
| `apiClient` | [`PersApiClient`](/sdk-reference/classes/persapiclient) |


#### Returns

[`WebhookApi`](/sdk-reference/classes/webhookapi)

#### Defined in

[webhook/api/webhook-api.ts:30](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L30)

## Methods

### listWebhooks

▸ **listWebhooks**(`options?`): `Promise`<`PaginatedResponseDTO`<`WebhookDTO`>>

List all webhooks (Admin)
GET /hooks

#### Parameters

| Name | Type |
|  --- | --- |
| `options?` | [`WebhookQueryOptions`](/sdk-reference/interfaces/webhookqueryoptions) |


#### Returns

`Promise`<`PaginatedResponseDTO`<`WebhookDTO`>>

#### Defined in

[webhook/api/webhook-api.ts:41](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L41)

### getWebhookById

▸ **getWebhookById**(`webhookId`): `Promise`<`WebhookDTO`>

Get webhook by ID (Admin)
GET /hooks/:hookId

#### Parameters

| Name | Type |
|  --- | --- |
| `webhookId` | `string` |


#### Returns

`Promise`<`WebhookDTO`>

#### Defined in

[webhook/api/webhook-api.ts:58](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L58)

### createWebhook

▸ **createWebhook**(`webhook`): `Promise`<`WebhookDTO`>

Create a new webhook (Admin)
POST /hooks

#### Parameters

| Name | Type |
|  --- | --- |
| `webhook` | `WebhookCreateRequestDTO` |


#### Returns

`Promise`<`WebhookDTO`>

#### Defined in

[webhook/api/webhook-api.ts:66](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L66)

### updateWebhook

▸ **updateWebhook**(`webhookId`, `webhook`): `Promise`<`WebhookDTO`>

Update a webhook (Admin)
PUT /hooks/:hookId

#### Parameters

| Name | Type |
|  --- | --- |
| `webhookId` | `string` |
| `webhook` | `WebhookUpdateRequestDTO` |


#### Returns

`Promise`<`WebhookDTO`>

#### Defined in

[webhook/api/webhook-api.ts:74](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L74)

### deleteWebhook

▸ **deleteWebhook**(`webhookId`): `Promise`<{ `message`: `string` ; `hookId`: `string`  }>

Delete a webhook (Admin)
DELETE /hooks/:hookId

#### Parameters

| Name | Type |
|  --- | --- |
| `webhookId` | `string` |


#### Returns

`Promise`<{ `message`: `string` ; `hookId`: `string`  }>

#### Defined in

[webhook/api/webhook-api.ts:82](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L82)

### triggerWebhook

▸ **triggerWebhook**(`request`, `projectKey`): `Promise`<`WebhookTriggerResponseDTO`<`unknown`>>

Trigger a webhook programmatically

Uses the proxy endpoint which requires projectKey in the URL path.
The projectKey is obtained from SDK config.

ALL /hooks/:projectKey/:hookId

#### Parameters

| Name | Type |
|  --- | --- |
| `request` | [`WebhookTriggerRequest`](/sdk-reference/interfaces/webhooktriggerrequest) |
| `projectKey` | `string` |


#### Returns

`Promise`<`WebhookTriggerResponseDTO`<`unknown`>>

#### Defined in

[webhook/api/webhook-api.ts:100](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L100)

### listExecutions

▸ **listExecutions**(`options?`): `Promise`<`PaginatedResponseDTO`<`WebhookExecutionDTO`>>

List webhook executions (Admin)
GET /hooks/executions

#### Parameters

| Name | Type |
|  --- | --- |
| `options?` | [`WebhookExecutionQueryOptions`](/sdk-reference/interfaces/webhookexecutionqueryoptions) |


#### Returns

`Promise`<`PaginatedResponseDTO`<`WebhookExecutionDTO`>>

#### Defined in

[webhook/api/webhook-api.ts:139](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L139)

### getExecutionById

▸ **getExecutionById**(`executionId`): `Promise`<`WebhookExecutionDTO`>

Get execution by ID (Admin)
Note: This endpoint doesn't exist in current backend - would need to filter by ID

#### Parameters

| Name | Type |
|  --- | --- |
| `executionId` | `string` |


#### Returns

`Promise`<`WebhookExecutionDTO`>

#### Defined in

[webhook/api/webhook-api.ts:158](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L158)

### sendCallback

▸ **sendCallback**(`executionId`, `callback`, `projectKey`): `Promise`<`WebhookExecutionDTO`>

Send callback result (for testing or manual callback trigger)
This is normally called by external systems like n8n

POST /hooks/:projectKey/executions/:executionId/callback

#### Parameters

| Name | Type |
|  --- | --- |
| `executionId` | `string` |
| `callback` | `WebhookCallbackDTO` |
| `projectKey` | `string` |


#### Returns

`Promise`<`WebhookExecutionDTO`>

#### Defined in

[webhook/api/webhook-api.ts:179](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/webhook/api/webhook-api.ts#L179)