Webhooks module ​
Receive notifications of your email events via webhooks.
Enroll method ​
Enrolls the user to receive event notifications via webhooks.
Usage ​
ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { Webhooks } from '@yizack/mailchannels/modules'
const mailchannels = new MailChannelsClient('your-api-key')
const webhooks = new Webhooks(mailchannels)
await webhooks.enroll("https://example.com/api/webhooks/mailchannels");
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')
await mailchannel.webhooks.enroll("https://example.com/api/webhooks/mailchannels");
Params ​
endpoint
: The URL to receive the webhook notifications.
List method ​
Lists all the webhook endpoints that are enrolled to receive event notifications.
Usage ​
ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { Webhooks } from '@yizack/mailchannels/modules'
const mailchannels = new MailChannelsClient('your-api-key')
const webhooks = new Webhooks(mailchannels)
const { webhooks: webhooksList } = await webhooks.list();
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')
const { webhooks } = await mailchannels.webhooks.list();
Delete method ​
Deletes all registered webhook endpoints for the user.
Usage ​
ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { Webhooks } from '@yizack/mailchannels/modules'
const mailchannels = new MailChannelsClient('your-api-key')
const webhooks = new Webhooks(mailchannels)
await webhooks.delete();
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')
await mailchannels.webhooks.delete();
Signing Key method ​
Retrieves the public key used to verify signatures on incoming webhook payloads.
Usage ​
ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { Webhooks } from '@yizack/mailchannels/emails'
const mailchannels = new MailChannelsClient('your-api-key')
const webhooks = new Webhooks(mailchannels)
const { key } = await webhooks.getSigningKey('key-id');
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')
const { key } = await mailchannels.webhooks.getSigningKey('key-id');
Params ​
keyId
: The ID name of the signing key.TIP
The
keyId
can be found in thesignature-input
request header of the webhook notification.
Type declarations ​
ts
class Webhooks {
constructor (protected mailchannels: MailChannelsClient) {}
async enroll (endpoint: string): Promise<void>;
async list (): Promise<WebhooksListResponse>;
async delete (): Promise<void>;
async getSigningKey (id: string): Promise<WebhooksSigningKeyResponse>;
}
All type declarations
List type declarations
ts
interface WebhooksListResponse {
webhooks: string[];
}
Signing Key type declarations
ts
interface WebhooksSigningKeyResponse {
id: string;
key: string;
}