Topics and preferences
Let someone opt down instead of out.
A topic is a kind of mail a person can opt out of on its own: newsletters, product updates, tips. The argument for them is complaint rate, not tidiness. Given only all-or-nothing, a person who wants fewer newsletters but still wants their invoice reminders often presses spam instead, and a complaint costs the sending domain far more than an opt-out. Letting them opt down keeps them reachable.
Defining topics
POST /v1/topics takes a key (lower-case letters, digits and hyphens), a name, an optional description shown on the preference page, and default_subscribed. The default is on, which suits an existing product newsletter; default-off suits anything a person should have to ask for.
Posting an existing key updates it. name is replaced; description and default_subscribed change only when you send them, and keep their stored value otherwise, so re-posting a topic to rename it cannot switch it off for anyone. description: null clears the description.
DELETE /v1/topics/{key} removes the topic and every preference recorded against it. Anyone who had opted out loses that record, so this is more destructive than the name suggests. It is refused with 409 invalid_state while an active or paused automation, or a campaign that has not finished, is sent under the topic, and the message names them. Mail already scheduled or held under the key reaches nobody afterwards, and a saved segment filtering on it matches nobody.
Where a preference lives
A preference is stored on (workspace, email, topic), never on a contact row. It belongs to the person, not to whichever audience they happen to be in: someone on two lists has one opinion about newsletters. Deleting a contact keeps their preferences for the same reason: an opt-out has to outlive the contact record, or the next import silently puts them back.
An absent row means the person has never chosen, and the topic's default applies. Defaults are deliberately not written out as rows for everyone: doing so would freeze today's default against a topic whose default later changes, so changing it would move nobody who never chose.
Reading and setting preferences
GET /v1/topics/preferences?email= returns every topic with subscribed already resolved: the person's choice where there is one, the default where there is not. Check it before asking why someone is not getting a particular kind of email; an opt-out looks identical to a delivery failure from the outside.
POST /v1/topics/preferences with an email and a topics map of key to boolean sets several at once and returns the person's resolved preferences. Every key is checked first: an unknown one answers 422 unknown_topic and nothing is saved. Setting a topic to false also ends any automation enrolment sent under that topic, and a send already scheduled under it is checked again when it comes due. Only do this when the person has actually asked. Silently re-subscribing someone who opted out is what generates spam complaints.
POST /v1/topics/{key}/import with emails (up to 50,000) and subscribed is the migration path: an existing provider knows who opted out of which list, and that has to arrive here before the first send. It answers 201 with the number of preferences written, and 404 for a topic that does not exist. An opt-out import ends the imported addresses' enrolments in automations sent under that topic at once, as a single opt-out does.
Sending under a topic
Pass topic on POST /v1/emails, or topic_key when creating a campaign or an automation. A recipient who has opted out of that topic is skipped. When every to address has, the send returns 202 with skipped: true and a reason of unsubscribed_from_topic:<key>, recorded in the log rather than dropped silently; when only some have, they are dropped and the rest receive it. An unknown topic key is refused with 422 unknown_topic, so a typo cannot bypass every preference someone has set. Addresses in cc and bcc are checked the same way, and an opted-out one is dropped.
The topic is checked after suppression because it is the finer of the two. A marketing-wide opt-out already covers every topic; opting out of one topic must leave the others reachable.
The unsubscribe page
Marketing mail carries a one-click unsubscribe header and a footer link to /api/unsubscribe, signed per workspace and address so a link minted by one tenant cannot opt someone out of another's mail. When the message was sent under a topic the link carries it, and one click opts the person out of that kind of mail only, then shows the preference page with the rest so they can adjust. The one-click POST that mailbox providers send is honoured the same way.
"Unsubscribe from everything" on that page, or a one-click on a message with no topic, is the full opt-out: a marketing-scope suppression, every pending scheduled send cancelled, every automation enrolment ended, and every topic switched off so the page reflects reality.
Transactional mail is unaffected
The suppression written by an unsubscribe is scoped to marketing. A transactional send checks the transactional scope and goes through, and the topic check only runs when a send names a topic. Only a hard bounce or a complaint suppresses an address for everything. The preference page says so in as many words: account and security emails are always sent.