Recipes
The three messaging modes Hogsend gives you — transactional, lifecycle, and marketing — plus the two data primitives that drive them. Real, copy-pasteable how-tos.
Hogsend sends mail in three modes — transactional, lifecycle, and marketing — and each one is a first-class primitive you reach for directly in code. The logic lives in your repo as TypeScript, not behind a builder UI. These recipes are real, copy-pasteable how-tos: the exact Hogsend call for each job, plus the data primitives that feed all three.
The three messaging modes
| Mode | What it is | Hogsend primitive |
|---|---|---|
| Transactional | One-off, system-triggered mail to a single person — verify your email, reset your password, a receipt | hs.emails.send() → POST /v1/emails |
| Lifecycle | Multi-step, behaviour-driven sequences — onboarding, trial nudges, win-back | defineJourney() — durable TypeScript |
| Marketing | A one-time broadcast of one template to an audience | hs.campaigns.send() → POST /v1/campaigns |
Underneath all three, two more primitives carry the data that drives everything:
hs.contacts.upsert()— the durable contact record: who someone is.hs.events.send()— the behaviour stream that triggers journeys: what they just did.
Which primitive do I reach for?
Sending one email to one person because the system did something?
→ hs.emails.send() (transactional) recipes/transactional-emails
Reacting to behaviour over time, with delays and branches?
→ defineJourney() (lifecycle) recipes/lifecycle-journeys
Blasting one template to a whole audience, once?
→ hs.campaigns.send() (marketing) recipes/marketing-campaigns
Recording who someone is, or what they just did?
→ hs.contacts.upsert() / hs.events.send() recipes/events-and-contactsHow the pieces fit
A single signup touches every primitive: you upsert a contact (who they are), events.send a user.signed_up event (what they did, which triggers the onboarding journey), and emails.send a transactional verify-email. From there the journey takes over, buckets re-segment as contact properties change, and you can broadcast a campaign to anyone subscribed to a list.
// 1. who they are
await hs.contacts.upsert({ email, userId, properties: { plan: "free" } });
// 2. what they did — triggers the onboarding journey
await hs.events.send({ name: "user.signed_up", userId, eventProperties: { source: "web" } });
// 3. a one-off transactional email
await hs.emails.send({ to: email, template: "transactional/verify-email", props: { verifyUrl } });What you get across all three modes
Three guarantees that hold for every send Hogsend makes, and that show up throughout these recipes:
- Typed templates.
templateandpropsare type-checked against your own React Email registry — a renamed or missing prop is a build failure, not a broken email in production. - Automatic tracking. Every send — including one-off transactional — flows through the same tracked mailer, so opens and clicks are recorded and loop back into the engine as events that can trigger journeys or move bucket membership.
- The property split.
contactProperties(who they are) andeventProperties(what happened) are separate bags — see Events & contacts.
The recipes
All four use the typed @hogsend/client SDK. The underlying HTTP endpoints are documented in the Data API reference; journeys are documented in the Journeys guide.
Segment
Receive Segment identify and track events at /v1/webhooks/segment, HMAC-hex signed, and turn them into Hogsend contacts and events.
Transactional emails
Send a transactional email with hs.emails.send({ to, template, props }). Verify-email, password-reset, magic-link, and receipt — with typed props, automatic tracking, and unsubscribe handling.