Skip to content

Newsletters APINewsletter flows

Newsletter flows API

A newsletter flow runs emails, waits and conditions for subscribers of one audience. Publish a draft before turning the flow on. A subscriber can run each flow once.

Last updated

Endpoints

Use newsletters:read for GET and newsletters:write for writes. Flow endpoints return 404 while flows are unavailable.

EndpointBehavior
GET /v1/newsletter-flowsList flows. Filter by audience_id. Returns { data }.
POST /v1/newsletter-flowsCreate an off flow. Send audience_id, name and optional template. Returns 201 with the flow detail.
GET /v1/newsletter-flows/:idGet the flow detail with current, draft and email_updated_at.
PATCH /v1/newsletter-flows/:idSet name or status (on or off). Returns the flow.
DELETE /v1/newsletter-flows/:idDelete the flow and stop its active runs. Returns 204.
PUT /v1/newsletter-flows/:id/draftReplace the draft graph at revision. Returns the updated draft version.
POST /v1/newsletter-flows/:id/publishPublish revision with email_updated_at and optional move_runs. Returns { version, moved_runs }.
POST /v1/newsletter-flows/:id/resumeClear the health pause. Returns the flow.
POST /v1/newsletter-flows/:id/emailsCreate a flow email. Returns 201 with { newsletter_id, updated_at }.
PATCH /v1/newsletter-flows/:id/emails/:newsletterIdEdit a flow email. Returns { newsletter_id, updated_at }.
GET /v1/newsletter-flows/:id/statsGet { version_id, events, active }. Set version_id to select a published version for the event counts. Defaults to the current version.
GET /v1/newsletter-flows/:id/runsList runs as { data }. Filter by state and subscriber_id. limit defaults to 50 and accepts 1 to 100.
POST /v1/newsletter-flows/:id/runsStart runs for 1 to 100 subscriber_ids. Returns { data } with one result per input.
DELETE /v1/newsletter-flows/:id/runs/:runIdStop a run. Returns 204.

Templates are empty (the default), welcome_series and lead_magnet. Templates with emails require a configured newsletter sender.

Build the draft graph

Create a flow email before adding its ID to an email step. Supply content_markdown or blocks. Email writes also accept subject, preview_text, sender_identity_id, track_engagement, add_utm_tags and styling_mode.

{
  "revision": 1,
  "graph": {
    "trigger": {
      "kind": "api"
    },
    "first": "stp_000000000001",
    "steps": {
      "stp_000000000001": {
        "kind": "wait",
        "minutes": 60,
        "next": "stp_000000000002"
      },
      "stp_000000000002": {
        "kind": "email",
        "newsletterId": "nws_123",
        "next": null
      }
    }
  }
}
  • Trigger kinds are subscribed, api and link_clicked. A click trigger takes newsletterId (nullable) and href with match (exact or prefix) and value.
  • A condition step has yes, no and then links. Its condition can check an email above it for a click or open, check membership in a segment, or evaluate one segment rule. After a join, the emails above include those of both paths. A click or open condition whose stepId is null counts any email of the flow, including emails since removed from it.
  • A path whose last link is null continues at the then step of the nearest condition around it, or of the next one out when that is null. At the top level, the run finishes. An {"kind":"exit"} step ends the run on its path, whatever then says.
  • A wait takes from: arrival (the default) counts from when the reader reaches it, and last_email from the reader's last email of this flow, or from the start of the run before any email. When that time has passed, the reader goes on at once.
  • The graph can contain up to 100 steps and 50 emails, each email once. Every step must be reached from first at exactly one place, through next, yes, no and then, so paths cannot cycle and a then step cannot also sit on one of its condition's paths.

The OpenAPI specification lists every field and graph variant.

Publish and turn on

Send the current draft.revision and the flow detail's email_updated_at map to publish. Both draft writes and publish can return 409 draft_changed. Reload the flow and reapply your changes to the new draft.

Active runs keep their version by default. With move_runs: true, publication moves eligible runs whose path to the current step is unchanged. If legacy readers still await conversion, moving runs returns 409 conversion_in_progress. Wait for conversion or publish without moving runs. Set status to on to enable the flow.

Manage runs

Manual starts require a published flow that is on. Each result contains subscriber_id and status, in the order you supplied the subscribers.

  • started The run started.
  • already_ran The subscriber already has a run for this flow.
  • not_eligible The subscriber cannot receive this marketing email.
  • not_found The subscriber ID does not belong to the flow's audience.
  • refused_by_key The API key cannot email this subscriber.

Audience-restricted keys can see and change flows only for allowed audiences. Recipient restrictions apply to each start and stop. Flow-wide changes that affect delivery require a key that can manage the audience's newsletter sending. Run events are available through the webhooks API.