Hogsend
Recipes

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

ModeWhat it isHogsend primitive
TransactionalOne-off, system-triggered mail to a single person — verify your email, reset your password, a receipths.emails.send()POST /v1/emails
LifecycleMulti-step, behaviour-driven sequences — onboarding, trial nudges, win-backdefineJourney() — durable TypeScript
MarketingA one-time broadcast of one template to an audiencehs.campaigns.send()POST /v1/campaigns

Underneath all three, two more primitives carry the data that drives everything:

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-contacts

How 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. template and props are 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) and eventProperties (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.

On this page