TypeScript SDK: Webhooks

The methods of the TypeScript client under Webhooks. The inbox webhook, account endpoints, their signed deliveries and the delivery log.

client.inboxes.webhook.get

TypeScript

client.inboxes.webhook.get(inboxId: string): Promise<InboxWebhook>

Sends inboxes.webhook.get: GET /v1/inboxes/{inboxId}/webhook

The inbox's webhook URL and its masked secret; both null when the inbox has none.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. App tokens are refused.

client.inboxes.webhook.set

TypeScript

client.inboxes.webhook.set(inboxId: string, body: SetInboxWebhook): Promise<InboxWebhookSecret>

Sends inboxes.webhook.set: PUT /v1/inboxes/{inboxId}/webhook

One URL per inbox. Setting it again replaces the URL and mints a new secret, returned once.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. App tokens are refused.

client.inboxes.webhook.rotateSecret

TypeScript

client.inboxes.webhook.rotateSecret(inboxId: string): Promise<InboxWebhookSecret>

Sends inboxes.webhook.rotateSecret: POST /v1/inboxes/{inboxId}/webhook/rotate-secret

A new signing secret, returned once. Update the receiver first.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. App tokens are refused.

client.inboxes.webhook.delete

TypeScript

client.inboxes.webhook.delete(inboxId: string): Promise<void>

Sends inboxes.webhook.delete: DELETE /v1/inboxes/{inboxId}/webhook

The inbox stops receiving deliveries; its delivery log stays.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. App tokens are refused.

client.inboxes.webhook.deliveries

TypeScript

client.inboxes.webhook.deliveries(inboxId: string, params: CursorParams = {}): Promise<DeliveryPage>

Sends inboxes.webhook.deliveries: GET /v1/inboxes/{inboxId}/webhook/deliveries

The inbox webhook's delivery log, newest first.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. App tokens are refused.

client.inboxes.webhook.iterateDeliveries

TypeScript

client.inboxes.webhook.iterateDeliveries(inboxId: string, params: CursorParams = {}): AsyncGenerator<Delivery, void, undefined>

Every delivery of the inbox webhook's log, newest first, page by page.

client.webhooks.list

TypeScript

client.webhooks.list(): Promise<EndpointList>

Sends webhooks.list: GET /v1/webhooks

The account's endpoints, oldest first.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.create

TypeScript

client.webhooks.create(body: CreateEndpoint): Promise<CreatedEndpoint>

Sends webhooks.create: POST /v1/webhooks

An endpoint for the account's events. The signing secret is returned once.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.get

TypeScript

client.webhooks.get(endpointId: string): Promise<Endpoint>

Sends webhooks.get: GET /v1/webhooks/{endpointId}

One endpoint with its newest delivery.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.update

TypeScript

client.webhooks.update(endpointId: string, body: UpdateEndpoint): Promise<Endpoint>

Sends webhooks.update: PATCH /v1/webhooks/{endpointId}

Any of the fields; the ones left out stay as they are.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.delete

TypeScript

client.webhooks.delete(endpointId: string): Promise<void>

Sends webhooks.delete: DELETE /v1/webhooks/{endpointId}

Removes the endpoint; its delivery log stays with the events.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.rotateSecret

TypeScript

client.webhooks.rotateSecret(endpointId: string): Promise<EndpointSecret>

Sends webhooks.rotateSecret: POST /v1/webhooks/{endpointId}/rotate-secret

A new signing secret, returned once. Update the receiver first.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.test

TypeScript

client.webhooks.test(endpointId: string): Promise<EndpointTestResult>

Sends webhooks.test: POST /v1/webhooks/{endpointId}/test

One signed message.received sample with test: true, posted whether or not the endpoint is enabled.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.deliveries

TypeScript

client.webhooks.deliveries(endpointId: string, params: CursorParams = {}): Promise<DeliveryPage>

Sends webhooks.deliveries: GET /v1/webhooks/{endpointId}/deliveries

The endpoint's delivery log, newest first.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

client.webhooks.iterateDeliveries

TypeScript

client.webhooks.iterateDeliveries(endpointId: string, params: CursorParams = {}): AsyncGenerator<Delivery, void, undefined>

Every delivery of the endpoint's log, newest first, page by page.

client.deliveries.retry

TypeScript

client.deliveries.retry(deliveryId: string): Promise<Delivery>

Sends deliveries.retry: POST /v1/deliveries/{deliveryId}/retry

Puts a delivered or failed delivery back in the queue; answers the delivery, now pending.

Access account: an account-scoped key or a console session; an inbox-scoped key gets 403 forbidden. An app token needs webhooks:manage and events:read and mail:read.

Up Down to move, Enter to open, Esc to close