Create Webhook
POST /webhooks — create a webhook to receive real-time notifications about email events.
/webhooksCreates a webhook. MailBlastr POSTs an event payload to your endpoint URL whenever one of the subscribed events occurs. The response includes a signing_secret — store it and use it to verify the signature on every incoming request. See Webhooks.
endpointstringrequiredThe HTTPS URL where webhook events will be sent.
eventsstring[]requiredArray of event types to subscribe to. See the table below.
secretstringoptionalOptional. Provide your own signing secret (e.g. to mirror a secret across providers). When omitted, MailBlastr mints a fresh whsec_… secret. Either way the plaintext is returned once in this response and never again.
email.sentenumoptionalMailBlastr accepted the email and queued it for delivery.
email.deliveredenumoptionalThe receiving server accepted the message.
email.delivery_delayedenumoptionalDelivery was temporarily deferred and MailBlastr is retrying.
email.bouncedenumoptionalThe message could not be delivered (hard rejection).
email.complainedenumoptionalThe recipient marked the message as spam.
email.openedenumoptionalThe recipient’s mail client loaded the tracking pixel (requires open tracking).
email.clickedenumoptionalThe recipient clicked a tracked link (requires click tracking).
email.failedenumoptionalThe email could not be sent (e.g. invalid recipient, quota reached).
email.scheduledenumoptionalThe email was accepted for future delivery with a scheduled_at time.
email.suppressedenumoptionalThe send was skipped because the recipient is on the account suppression list.
email.receivedenumoptionalAn inbound email arrived at one of your verified receiving domains.
email.repliedenumoptionalA reply to one of your sent emails was detected.
email.unsubscribedenumoptionalA recipient unsubscribed via an unsubscribe link or header.
contact.createdenumoptionalA contact was created in one of your audiences.
contact.updatedenumoptionalA contact was updated.
contact.deletedenumoptionalA contact was deleted.
domain.createdenumoptionalA domain was added to your account.
domain.updatedenumoptionalA domain’s settings or verification status changed.
domain.deletedenumoptionalA domain was removed from your account.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.webhooks.create({
"endpoint": "https://example.com/handler",
"events": ["email.sent", "email.delivered"]
});
console.log({ data, error });Response
{
"object": "webhook",
"id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0",
"signing_secret": "whsec_xxxxxxxxxx"
}signing_secret is only returned here, at creation. Store it securely — it cannot be retrieved again later.