Introduction
Sendwend is an MIT-licensed TypeScript SDK for customer journeys. Workflows are typed code, compiled to a versioned IR and run on your own infrastructure, with the data in your own Postgres.
Sendwend is a code-first engine for customer journeys: the lifecycle emails, pushes and Slack or Discord messages a product sends when users sign up, stall, buy or go quiet. You write each journey as TypeScript. The compiler turns it into a versioned intermediate representation (IR), and one generic runner executes every journey on the host you choose, with its state in a Postgres database you own.
That is a complete journey: send a welcome email, wait three days, then wait up to a week for the user to activate, and send a nudge if they do not. e.sign_up, u.name and email.getting_started are typed by your project, so a misspelled event, a profile field you never declared or a missing template prop fails in the editor.
Why it exists
Customer-journey tools are, almost all of them, visual canvases inside a SaaS product. That works for a marketing team and gets in the way of an engineering one:
- Slow to change. Every edit is clicks in someone else's UI. A journey that touches ten emails is ten trips through an editor.
- Impossible to review, test or version. A canvas has no diff, no pull request and no test suite. When a journey sends the wrong email, the history is whatever the audit log kept.
- Priced per profile. The bill grows with every user you store, including the ones no journey is talking to.
- Your data lives in their database. Events and profiles are copied into the vendor, and getting them back out is a project.
Meanwhile, more and more of a product's code is written with AI coding agents. Agents work in code: they read files, edit them, run the type checker and the tests. They cannot drag nodes on a canvas. A journey that is code is something an agent can write, and something a person can then review in a diff like any other change.
The design
Journeys are code
A workflow is a chain of calls on workflow(): a trigger, then steps (.email(), .push(), .slack(), .delay(), .waitUntil(), .branch(), .cohort(), .run() and more). Options carry the configuration that applies to the whole journey: reentry (whether a user may enter again), goal (the conversion that ends it) and exitWhen.
The chain builds a serializable graph, never runtime code. A branch's sub-flow callback runs exactly once, when the workflow is defined, and values that are only known at run time are always references (u.plan), not closures. That is what lets the same definition be compiled, diffed, drawn as a canvas and executed.
Here is a real example from the SDK's playground: a Customer.io checkout-recovery canvas of 12 nodes (5 exits and 3 conditional branches) ported to Sendwend.
The canvas checked "purchased? → Exit" at three separate points. Here a single goal: purchaser replaces all three: the goal is checked when the user enters and again after every step where time passes (a delay, a time window, a wait), and a match exits the journey and counts as a conversion. The two arms are named flow() fragments defined above it.
Conditions are typed like drizzle queries
Events and profile fields come from one Zod contract, shared by the service that sends events and the host that runs journeys. defineContract() returns two reference tables: e for events, u for profile fields. Conditions are plain functions over them, in the style of drizzle's query builder:
The IR is data
compileConfig() turns the whole project into a bundle of IR: JSON that describes each workflow, segment and template. Every workflow carries a content hash over its IR, so a reworded description is not a new version but a changed delay is. A journey is pinned to the version it entered on and finishes on it, however many times you deploy underneath it.
Because the IR is data, there is no per-journey deployment. One runner interprets every journey; deploying a change swaps a routing table. Before a deploy writes anything, the host checks the new bundle against the versions journeys are still running on and refuses a change that would break them, such as a template a pinned journey still sends being removed. See Versioning.
Mistakes are rejected before they ship
Two layers check every change, whoever wrote it:
- The type checker rejects a send of an unregistered template, props that do not match the template's schema, a profile field the contract does not declare, a payload field the event does not have, and a duration typo (
'3 dayz'is not aDuration). - The compiler rejects what types cannot see: a template registered twice, a segment the bundle does not include, a topic the contract does not declare, a workflow without a
reentrypolicy.
This matters more when an AI agent writes the journey. The agent gets the same errors a person would, in the same terminal, and fixes them before anyone reviews the diff.
Time can be scaled in development
runtime.development.timeScale fast-forwards every duration. At 600, one day of journey time takes 2.4 minutes, so a 7-day journey runs end to end in under 17 minutes on your machine, against real Postgres and real templates. The production entry's type only accepts 1, so a development factor pasted under the production key is a compile error.
Your data stays in your Postgres
Profiles, events, the entry ledger, every message copy, opens and clicks live in one Postgres schema (workflow by default) in a database you run. You can query it, back it up and join it with your own tables. Sendwend Studio reads the same tables to show reports.
MIT, on the host you choose
The SDK is MIT-licensed. The same config runs on three hosts:
| Host | Execution |
|---|---|
| Cloudflare | A Worker on Cloudflare Workflows, Postgres through Hyperdrive |
| AWS Lambda | One Lambda durable function behind a Function URL |
| Node + Postgres | A Node process; instances are rows, claimed by workers |
The interpreter never touches a database or a network itself: everything arrives through ports, which is also what makes a journey testable without deploying it.
What it is not
Sendwend has no visual editor. Studio draws every workflow as a canvas and previews every template, but it is read-only: you change journeys in your editor. If the people who build journeys do not write code, a SaaS tool is the better choice; the comparison says when.
Where to go next
- Installation: from
pnpm add sendwend zodto a journey running locally and deployed on Cloudflare. - Comparison: Sendwend next to Customer.io, Braze and Loops, and next to Inngest, Temporal and Cloudflare Workflows, with a cost estimate.
- Basic usage: the everyday loop, from a contract field to a deployed journey.
- Architecture: the authoring, execution and adapter planes.