Skip to content

Latest commit

 

History

History
163 lines (95 loc) · 3.81 KB

WebhooksResource.md

File metadata and controls

163 lines (95 loc) · 3.81 KB

akahu - v1.15.3 / WebhooksResource

Class: WebhooksResource

Utilities for managing, retrieving, and validating webhooks.

https://developers.akahu.nz/docs/reference-webhooks

Hierarchy

  • BaseResource

    WebhooksResource

Table of contents

Methods

Methods

list

list(token): Promise<Webhook[]>

Gets active webhooks for the user associated with the specified token.

https://developers.akahu.nz/reference/get_webhooks

Parameters

Name Type
token string

Returns

Promise<Webhook[]>


subscribe

subscribe(token, webhook, requestOptions?): Promise<string>

Subscribe to a webhook.

Parameters

Name Type
token string
webhook WebhookCreateParams
requestOptions? PostRequestOptions

Returns

Promise<string>

The newly created webhook id.

https://developers.akahu.nz/reference/post_webhooks


unsubscribe

unsubscribe(token, webhookId): Promise<void>

Unsubscribe from a previously created webhook.

https://developers.akahu.nz/reference/delete_webhooks-id

Parameters

Name Type
token string
webhookId string

Returns

Promise<void>


listEvents

listEvents(query): Promise<WebhookEvent[]>

List all webhook events with the specified status in the specified date range (defaults to last 30 days).

https://developers.akahu.nz/reference/get_webhook-events

Parameters

Name Type
query WebhookEventQueryParams

Returns

Promise<WebhookEvent[]>


getPublicKey

getPublicKey(keyId): Promise<string>

Get a webhook signing public-key by id.

https://developers.akahu.nz/reference/get_keys-id

Parameters

Name Type
keyId string | number

Returns

Promise<string>


validateWebhook

validateWebhook(keyId, signature, webhookRequestBody, cacheConfig?): Promise<WebhookPayload>

Helper to validate a webhook request payload.

See the project README for example usage.

throws AkahuWebhookValidationError if validation of the webhook fails due to invalid signature or expired signing key.

throws AkahuErrorResponse if the client fails to fetch the specified signing key from the Akahu API.

https://developers.akahu.nz/docs/reference-webhooks

Parameters

Name Type
keyId string | number
signature string
webhookRequestBody string
cacheConfig Partial<WebhookCacheConfig>

Returns

Promise<WebhookPayload>

The deserialized webhook payload after successful validation