Guides
Events & automations
Tell Mailmanny when something happens in your app, like a signup, an order or a trial ending, and let an automation send the right emails at the right time.
Track an event#
POST/api/v1 /eventsPermission: events:write
await mm.events.track({ audienceId, email: "sam@example.com", name: "order.completed", properties: { total: 42.5, items: 3 },});curl -X POST https://www.mailmanny.com/api/v1/events \ -H "Authorization: Bearer $MAILMANNY_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-1042-completed" \ -d '{ "audience_id": "0199e9c1-2f3a-7b4c-8d5e-6f7a8b9c0d1e", "email": "sam@example.com", "name": "order.completed", "properties": { "total": 42.5, "items": 3 } }'{ "object": "event", "id": "01JABCDE4XKQ2V7M9N3P5R8S0T", "name": "order.completed", "contact_id": "0199f0b2-6c1e-7a3d-9f2b-3c4d5e6f7a8b", "accepted": true}NameDescription
- audience_idstringRequired
- The audience the contact belongs to.
- emailstringRequired
- The contact. They must already be in the audience.
- namestringRequired
- Up to 100 characters: letters, numbers, dots, colons, dashes and underscores, e.g. order.completed.
- propertiesobject
- Any JSON details about the event, up to 16 KB.
The response is 202 because automations run in the background. A contact that isn't in the audience gets 404 not_found: add them first with POST /contacts.
Start an automation#
- In Automations, create an automation on the same audience and pick the API event trigger.
- Enter the event name exactly as you send it, for example
order.completed. - Build the steps (wait, send email, add tag, split) and turn it on.
Every matching event then starts a run for that contact. The automation's own settings decide whether someone can enter more than once, and its filters decide who may enter at all. Unsubscribed contacts never receive its emails.
Example: post-purchase series#
// After a successful checkoutawait mm.contacts.create({ audienceId, email: order.email, firstName: order.firstName, tags: ["customer"] });await mm.events.track( { audienceId, email: order.email, name: "order.completed", properties: { total: order.total } }, { idempotencyKey: `order-${order.id}-completed` },);An automation on order.completed can wait three days, send a "How was it?" email, and tag people who click the review link. Events are a better fit than tags for things that repeat, like orders.