Marketing
Lifecycle email: drip sequences that reach the right people.
Also for this capability: API · CLI · MCP · SDKs
Lifecycle email: drip sequences that reach the right people.
| Base URL | https://api.hanzo.ai |
| Operations | 86 |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Specification
HIP-1136 · Marketing — Lifecycle Email — Draft · read the specification →
/v1/marketing is lifecycle email: drip sequences that reach the right people.
Audiences resolve from the IAM roster, promo codes record redemptions an admin
grants against, and every send passes through the per-org suppression list. It
is implemented in hanzoai/cloud at apps/marketing (HIP-0106). The two
invariants this HIP states: there is exactly one send seam, and this capability
can no longer mint money.
Motivation
A marketing surface accumulates senders — a campaign blast here, a drip step
there, a calendar hook — and every sender that bypasses the opt-out list is a
compliance violation waiting on a query. The design forces every delivery
through one function so the suppression check cannot be skipped by
construction (apps/marketing/suppress.go:26-32). The second lesson was paid
for: an earlier promo redemption deposited real spendable wallet credit on any
validated principal's say-so — plan and seat count from the request body,
nothing collecting the charge the discount was against — a self-service money
mint worth about $1.79M at the cap. The deposit is gone
(apps/marketing/promos.go:30-48).
Specification
The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are to be interpreted as in RFC 2119.
§1 The store, and the engine underneath
One encrypted SQLite file, the deployment's own marketing
(apps/marketing/store.go:42); every query filters WHERE org=?. Drip steps
are durable tasks on the embedded hanzoai/tasks engine: each enrollment's
next-run time lives in SQLite, a per-minute schedule sweeps due steps, and
every step is claimed once, so a redeploy neither loses nor duplicates a send
(apps/marketing/marketing.go:15-20).
§2 One send seam
Every marketing delivery — campaign, drip step, calendar email — calls the one
deliver function, which consults the per-org suppression list and then hands
off to the platform notify rail; marketing never constructs a provider and has
no second door out (apps/marketing/suppress.go:138-148). A suppressed
recipient is refused at the seam, and a signed public one-click unsubscribe
writes the same list. A product announcement is not a feature beside this: it
is a one-step sequence with an audience enrolled, inheriting claimed-once
delivery, the suppression gate and the unsubscribe footer
(apps/marketing/marketing.go:42-45).
§3 Audiences are honest
An audience resolves to real mailboxes through the IAM roster; one with an
event filter narrows that roster to the cohort the analytics warehouse
selected. When the roster or warehouse cannot be read the answer is honestly
empty — never a fabricated count, never a send to nobody reported as success
(apps/marketing/marketing.go:18-23).
§4 A redemption is evidence, not money
What a promo redemption produces is a ROW — the org, the server-derived plan,
the discount claimed, and when — which an admin grants against through the
admin surface and the auditable ledger. The plan is derived from the org's live
paid subscription and never accepted from the caller (the input carries no plan
and no seats, so there is no field to inflate); an unreadable plan authority
refuses, inverting the spend gate's fail-open, because failing open here would
let an outage manufacture the evidence money is granted against; the payment
instrument is required as the anti-farming key
(apps/marketing/promos.go:39-60).
§5 The address, tenancy, money, events, observability
Thirty-five operations under /v1/marketing, every one a typed op — one
registry entry projecting REST, the document, the MCP tool and the CLI
(apps/marketing/marketing.go:47-52). The tenant is the org minted from the
validated bearer (HIP-0026), carried to the typed seam by the bridge and read
back server-side — never a header, never an In field. Free (cloud.Free,
plugin/marketing/main.go); the send rail and any granted credit are other
planes' ledgers. It publishes nothing on the bus and emits nothing beyond the
request span every route gets.
§6 Stage and upstream
beta: a vertical application. It derives from no third-party upstream; the
durable engine it composes is hanzoai/tasks (HIP-1062), embedded, not
mirrored here.
Rationale
The alternative to one send seam is a suppression check in every handler, which is the same check N times until one path forgets it. The alternative to deleting the promo deposit was gating it harder — but an automatic path that creates money is not a feature to fix, it is a mechanism to remove, because a money mint left switched off is one flag away from switched on.
Security Considerations
The wrong implementation here is a spam cannon with a ledger attached. Send authority: any path around the deliver seam bypasses opt-out, so the seam is the only door and tests assert exactly which recipients reach the rail. Money: the removed deposit is the standing lesson — a redemption input that named its own plan converted open signup into self-served credit; the current shape has no field to inflate and fails closed on an unreadable authority. Tenancy: the suppression list, audiences and enrollments are all org-column scoped on the validated principal, so one tenant can neither read another's roster nor unsubscribe another's customers.
Four surfaces
| Surface | Reaches this capability as | Coverage |
|---|---|---|
| REST | marketing at its own prefix | 86 operations |
| CLI | hanzo marketing … | 86 of 86 |
| SDK | MarketingApi in every published client | 86 methods |
| MCP | tool marketing on https://api.hanzo.ai/v1/mcp | 82 operations, 7 under the document's own id — ask describe for the rest |
Quickstart
export HANZO_API_KEY=sk-... # platform.hanzo.ai/api-keysThen the first call — a read that needs nothing but the key. GET /v1/marketing/beta, operation get_marketing_beta:
hanzo marketing beta getimport { Configuration, MarketingApi } from 'hanzoai';
const api = new MarketingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getMarketingBeta();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import MarketingApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = MarketingApi(client).get_marketing_beta()cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.MarketingAPI.GetMarketingBeta(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, marketing_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = marketing_api::get_marketing_beta(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.MarketingApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new MarketingApi(client).getMarketingBeta();curl https://api.hanzo.ai/v1/marketing/beta \
-H "Authorization: Bearer $HANZO_API_KEY"Tool marketing, op get_marketing_beta — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "marketing",
"arguments": {
"op": "get_marketing_beta",
"input": {}
}
}
}'Answers 200 with object — ok.
Endpoints
| Endpoint | What it does |
|---|---|
GET /v1/marketing/audiences/{id}/preview | Evaluates the cohort LIVE — the same resolution an enrollment would run — and reports how big it is and how many real mailboxes it reaches. |
GET /v1/marketing/audiences/{id} | Returns one of the caller org's saved audiences. |
DELETE /v1/marketing/audiences/{id} | Removes one of the caller org's audiences and answers 204. |
GET /v1/marketing/audiences | Returns every audience the org can send to: its saved cohorts, most recently updated first, then its mailing lists and their saved segments, newest first, each list with its subscribed count. |
POST /v1/marketing/audiences | Saves a cohort filter for the caller's org. |
POST /v1/marketing/beta/actions | Counts one action of the signed-in caller: a star on a Hanzo repository, verified on GitHub for the login named, or a follow of a founder's link, taken on trust. |
POST /v1/marketing/beta/invites/sent | Records what the member's browser did with its reservations: the invites sent, and the ones that failed with the mailbox's reason. |
GET /v1/marketing/beta/invites | Answers the caller's invites, newest first, with how many were sent, how many joined, and how many more they may send now. |
POST /v1/marketing/beta/invites | Reserves an invite for each address the limits admit and answers the message the member's mailbox sends for each: subject, text and HTML, the unsubscribe headers, with the member's referral link for that invite and a one-click unsubscribe for that address. |
POST /v1/marketing/beta/request | Adds betas to those the signed-in caller asked for, creating the record when there is none. |
GET /v1/marketing/beta | Answers the signed-in caller's waitlist record: the application as it stands, the betas asked for, the points and the actions that earned them, and the place on the waitlist. |
PUT /v1/marketing/beta | Writes the signed-in caller's application: the program, the answers, the betas asked for and the lead it was filed under. |
POST /v1/marketing/broadcasts/{id}/cancel | Stops a scheduled or sending broadcast and answers it. |
POST /v1/marketing/broadcasts/{id}/send | Sends a draft or scheduled broadcast now, or schedules it for at, and answers 202 with it. |
GET /v1/marketing/broadcasts/{id}/stats | Returns one broadcast's numbers: audience, sent, refused, failed, and what the email plane reported (delivered, opened, clicked, bounced, complained, unsubscribed), each counted once per message, with open and click rates. |
POST /v1/marketing/broadcasts/{id}/test | Sends the broadcast as it stands to up to five addresses, its subject marked [Test], through the same rail and footer the real send takes. |
GET /v1/marketing/broadcasts/{id} | Returns one of the org's broadcasts. |
PATCH /v1/marketing/broadcasts/{id} | Changes the fields the body names on a draft or scheduled broadcast and answers it. |
DELETE /v1/marketing/broadcasts/{id} | Deletes a broadcast that is not sending, with its record of who it went to, and answers 204. |
GET /v1/marketing/broadcasts | Returns the org's broadcasts, newest first. |
POST /v1/marketing/broadcasts | Composes a broadcast to one of the org's lists, or a segment of it, and answers 201 with it. |
GET /v1/marketing/calendar/{id} | Returns one of the caller org's posts, including the exact error behind a failed publish. |
PUT /v1/marketing/calendar/{id} | Replaces a post's editable fields. |
DELETE /v1/marketing/calendar/{id} | Removes one of the caller org's posts and answers 204. |
GET /v1/marketing/calendar | Returns the org's calendar, latest scheduled first, optionally narrowed to one status. |
POST /v1/marketing/calendar | Adds a post to the content calendar. |
POST /v1/marketing/campaigns/{id}/schedule | Sets a campaign's send time and moves it to "scheduled". |
GET /v1/marketing/campaigns/{id} | Returns one of the caller org's campaigns. |
PUT /v1/marketing/campaigns/{id} | Replaces a campaign's editable fields. |
DELETE /v1/marketing/campaigns/{id} | Removes one of the caller org's campaigns and answers 204. |
GET /v1/marketing/campaigns | Returns the org's campaigns, most recently updated first, optionally narrowed to one lifecycle status. |
POST /v1/marketing/campaigns | Registers a campaign in the caller's org. |
GET /v1/marketing/click | Follows a tracked email link. |
GET /v1/marketing/fields | Returns the custom fields the org defined for its subscribers. |
PUT /v1/marketing/fields | Replaces the org's custom fields with the set the body carries and answers it. |
POST /v1/marketing/imports/{id}/cancel | Stops an import that has not finished and answers it. |
PUT /v1/marketing/imports/{id}/data | Takes a piece of an import's file at the offset the query names and answers how many bytes the import now holds. |
POST /v1/marketing/imports/{id}/start | Queues an import whose bytes have all arrived and answers 202 with it; a worker reads it from there. |
GET /v1/marketing/imports/{id} | Returns one of the org's imports: its state, how far its bytes and its reading have come, and its report so far. |
GET /v1/marketing/imports | Returns the org's imports, newest first, each with its report. |
POST /v1/marketing/imports | Creates an import into one of the org's lists and answers it. |
POST /v1/marketing/leads/esign | Takes Hanzo eSign's webhook: a SAFE was signed, countersigned, completed, declined or voided, and the investor's form in the brand's CRM moves to that status. |
POST /v1/marketing/leads/resume | Signs a form the careers page posts one resume through, into the brand org's private careers bucket, and answers the key to name on the application (resume_file). |
POST /v1/marketing/leads | Files one public form in the deployment's own CRM. |
GET /v1/marketing/lists/{id}/export | Streams a selection of one list as CSV (format=csv, the default) or as a JSON array (format=json), every subscriber with their consent evidence, engagement and custom fields. |
PUT /v1/marketing/lists/{id}/segments/{sid} | Replaces a segment's name and filter and answers it with how many subscribers it selects now. |
DELETE /v1/marketing/lists/{id}/segments/{sid} | Deletes a saved segment and answers 204. |
GET /v1/marketing/lists/{id}/segments | Returns one list's saved segments, newest first. |
POST /v1/marketing/lists/{id}/segments | Saves a filter over one list as a segment and answers 201 with it and how many subscribers it selects now. |
GET /v1/marketing/lists/{id}/stats | Returns one list's numbers for charting: subscribers by status, source and consent basis, and over a range of days, what happened each day, the net growth, the confirmation rate and the unsubscribe rate. |
GET /v1/marketing/lists/{id}/subscribers/{sid} | Returns one subscriber of one of the org's lists, with their consent evidence and engagement. |
PATCH /v1/marketing/lists/{id}/subscribers/{sid} | Changes the fields the body names on one subscriber and answers the row. |
DELETE /v1/marketing/lists/{id}/subscribers/{sid} | Removes one subscriber from one of the org's lists and answers 204. |
POST /v1/marketing/lists/{id}/subscribers/bulk | Applies one action to a selection of a list and answers how many rows it matched and changed. |
GET /v1/marketing/lists/{id}/subscribers | Returns a page of one list's subscribers, newest first unless asked otherwise. |
POST /v1/marketing/lists/{id}/subscribers | Adds an address to one of the org's lists, or updates it when it is already there, and answers 201 or 200 with the row. |
GET /v1/marketing/lists/{id} | Returns one of the org's lists, by id or slug, with its subscribers counted by status. |
PATCH /v1/marketing/lists/{id} | Changes the fields the body names on one of the org's lists and answers the list. |
DELETE /v1/marketing/lists/{id} | Deletes one of the org's lists with every subscriber, segment, import and broadcast it has, and answers 204. |
GET /v1/marketing/lists | Returns the org's lists, newest first, each with its subscribers counted by status. |
POST /v1/marketing/lists | Creates a list in the org and answers 201 with it. |
POST /v1/marketing/mail | Sends one email from the org to one person, the way a person on the org's team writes back to a lead from its record. |
GET /v1/marketing/promos/{code}/eligibility | Prices a promo against a plan and seat count. |
POST /v1/marketing/promos/{code}/redeem | Records the caller org's claim on a promo. |
GET /v1/marketing/promos/{code}/redemption | Returns the caller org's OWN redemption of a promo — an org-scoped read, so it can never surface another tenant's. |
GET /v1/marketing/promos | Returns every promo the deployment offers with its live counters: how many orgs have redeemed it and how many redemptions remain under the cap. |
GET /v1/marketing/sender | Returns the org's sender: the provider and the from, reply and footer fields every list takes when it leaves its own empty. |
PUT /v1/marketing/sender | Replaces the org's sender and answers it. |
POST /v1/marketing/sequences/{id}/enroll | Adds one contact or a whole audience to a sequence and schedules the first step for each. |
POST /v1/marketing/sequences/{id}/enrollments/{eid}/cancel | Stops one walk mid-sequence and answers 204: no further step is sent, and steps already delivered are not recalled. |
GET /v1/marketing/sequences/{id}/enrollments | Returns who is walking one sequence, most recently enrolled first, with each walk's current step and next due time. |
POST /v1/marketing/sequences/{id}/status | Flips draft/active/archived — the activation gate for sending, since only an active sequence accepts enrollments. |
GET /v1/marketing/sequences/{id}/steps | Returns one sequence's steps in send order. |
POST /v1/marketing/sequences/{id}/steps | Appends a message to the END of a sequence: the new step's idx is one past the last, so steps arrive in the order they are added. |
GET /v1/marketing/sequences/{id} | Returns one of the caller org's sequences together with its steps in send order. |
GET /v1/marketing/sequences | Returns the org's drip sequences, most recently updated first. |
POST /v1/marketing/sequences | Registers a drip sequence in the caller's org. |
POST /v1/marketing/subscribe/confirm | Subscribes the address a confirmation link names and answers 200 confirmed. |
POST /v1/marketing/subscribe | Asks for the brand's newsletter for an address and answers 202 pending. |
GET /v1/marketing/summary | Rolls up the caller org's campaigns: how many there are, how many are active, and the summed budget and spend in cents. |
GET /v1/marketing/suppressions/check | Answers whether the org's send gate refuses an address, and which list holds it, by the same check every commercial send asks. |
GET /v1/marketing/suppressions | Returns the org's opt-out list, newest first — everyone the send gate will refuse to deliver to. |
POST /v1/marketing/suppressions | Records an opt-out for the org (admin / self-service management). |
DELETE /v1/marketing/suppressions | Re-subscribes an address on one channel and answers 204. |
GET /v1/marketing/unsubscribe | The PUBLIC one-click endpoint (no principal): a recipient clicks the signed link in an email footer. |
POST /v1/marketing/unsubscribe | The one-click unsubscribe a mail client sends from the List-Unsubscribe header (RFC 8058): the same signed link the footer carries, POSTed with the form body List-Unsubscribe=One-Click. |