Custom Events
Define custom events to trigger automations.
Custom events are used to trigger automations and can be defined with an optional schema for payload validation.
If a schema is defined, payloads are validated when the event is sent. Fields that don't match the expected type are rejected with a 422 error and the event is not delivered.
How it works
In the dashboard, the Events page shows all existing events. Click Add event, enter the event name and an optional schema to define the event payload you will send with the event, then Save.
Over the API, all existing events can be retrieved with the List Events API. To create a new event, use the Create Event API.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.events.create({
"name": "user.created",
"schema": {
"plan": "string"
}
});
console.log({ data, error });{
"object": "event",
"id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e",
"name": "user.created",
"schema": {
"plan": "string"
},
"created_at": "2026-06-23T10:00:00.000Z",
"updated_at": "2026-06-23T10:00:00.000Z"
}user.created, welcome, my-custom-event). Dot notation is a recommended convention but is not required. If multiple enabled automations use the same event name, all of them will be triggered.Sending events
Trigger your automations by sending an event with `POST /events/send`. Name the domain the event belongs to (only that domain's automations fire), identify the contact by contact_id or email, and optionally attach a payload object — its fields become available as event.* variables in templates, conditions, and other steps. See Trigger for details.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.events.send({
"event": "user.created",
"domain": "yourdomain.com",
"contact_id": "479e3145-dd38-476b-932c-529ceb705947",
"payload": {
"plan": "pro"
}
});
console.log({ data, error });Configuration
namestringrequiredThe name of the custom event to create. Used to match events to automation triggers. Cannot start with the mailblastr: prefix, which is reserved for system events.
schemaobjectoptionalAn optional schema definition for the event payload. Must be an object with flat key/type pairs. Supported types: string, number, boolean, date.
{
"schema": {
"plan": "string",
"amount": "number",
"date": "date",
"is_active": "boolean"
}
}mailblastr: prefix, which is reserved for system events. Creating a definition with a name that already exists returns a validation_error.