Voaaro already handles unsubscribing for every broadcast: a footer with the link, the one-click List-Unsubscribe header and a hosted preferences page. This page shows how to do it on your side: from your server, or from a page of your application.
From your server
Same key as for subscribing: the domain's application key, sending_access allowed.
Node / Bun
const { data } = await voaaro.newsletter.unsubscribe({ email: "ada@example.org" })Python
r = voaaro.Newsletter.unsubscribe({"email": "ada@example.org"})PHP
$r = $voaaro->newsletter->unsubscribe(['email' => 'ada@example.org']);Go
sub, err := client.Newsletter.Unsubscribe(&voaaro.UnsubscribeRequest{Email: "ada@example.org"})cURL
curl https://mail.example.com/api/v1/newsletter/unsubscribe \
-H "Authorization: Bearer $VOAARO_API_KEY" -H "Content-Type: application/json" \
-d '{"email": "ada@example.org"}'{
"object": "subscription",
"email": "ada@example.org",
"contact_id": "7c1d9e42-0a3b-4f6e-8d21-5b9f0c3e7a14",
"status": "unsubscribed",
"topics": [{ "id": "7a1c…", "name": "News", "subscription": "opt_in" }]
}emailorcontact_id: required; unknown address:404.domainif the key covers several domains.- Without
topic_ids: unsubscribes from every broadcast of the domain; messages already queued for this contact are canceled. Produces thecontact.unsubscribedwebhook (source: "api"). - With
topic_ids: only these topics switch toopt_out; the contact stays subscribed to other broadcasts (status: "subscribed"), with nocontact.unsubscribed. - The change is written to the audit log (
contact.unsubscribe, actorapikey:<id>).Idempotency-Keyis accepted. - An address's state is read with
GET /newsletter/subscriptions/{email}. To resubscribe from your server, callPOST /newsletter/subscribeagain: it is an explicit request.
From the browser
Your application can have its own "Manage my emails" page. It calls the form's public routes, with its public key and the same allowed origins.
Why a token, not the address
If an address were enough, anyone could unsubscribe anyone. The public routes therefore require the signed token of the unsubscribe link, which only the message's recipient has. Put it in your broadcast's link with the {{{VOAARO_UNSUBSCRIBE_TOKEN}}} variable (or {{ unsubscribe_token }}):
<a href="https://app.example.com/unsubscribe?token={{{VOAARO_UNSUBSCRIBE_TOKEN}}}">Manage my emails</a>Your page reads token from its address and passes it to the routes below. A token from another domain than the form's responds 404 invalid_token.
| Method | Path (/api/v1/newsletter/public/{public_key}/…) | Body | Response |
|---|---|---|---|
GET | preferences?token=… | preferences | |
POST | unsubscribe | token, topic_ids (optional) | preferences |
POST | resubscribe | token | preferences |
{
"object": "preferences",
"test": false,
"email": "a***@example.org",
"unsubscribed": false,
"topics": [{ "id": "7a1c…", "name": "News", "description": "Once a month", "subscribed": true }]
}emailis masked: the page does not reveal the full address to whoever finds the link.topics: the domain's public topics, checked or not for this contact.unsubscribewithouttopic_idsunsubscribes from everything (contact.unsubscribedwebhook,source: "public_api"); with them, from these topics only.resubscribeundoes an unsubscribe.- A test send token gives
test: trueand changes nothing. GETnever changes anything: antivirus scanners and link previews that open addresses unsubscribe nobody.
<p id="prefs">Loading…</p>
<button id="stop">Unsubscribe me from everything</button>
<script type="module">
const API = "https://mail.example.com/api/v1/newsletter/public/mlk_pub_0123456789abcdef0123456789abcdef"
const token = new URLSearchParams(location.search).get("token")
const show = (p) => (document.getElementById("prefs").textContent = p.unsubscribed ? `${p.email}: unsubscribed.` : `${p.email}: subscribed.`)
fetch(`${API}/preferences?token=${encodeURIComponent(token)}`).then((r) => r.json()).then(show)
document.getElementById("stop").addEventListener("click", async () => {
const r = await fetch(`${API}/unsubscribe`, { method: "POST", headers: { "Content-Type": "text/plain" }, body: JSON.stringify({ token }) })
show(await r.json())
})
</script>The SDKs have the same calls: PublicForm with getPreferences(token), unsubscribe(token, { topicIds }), resubscribe(token) (Node; get_preferences, unsubscribe, resubscribe in Python, same names in PHP and Go).
Default preferences page
The page hosted by Voaaro ({{{unsubscribe_url}}}, {{ preferences_url }} link) is customized per domain, in the console (Newsletters › Newsletter settings, "Unsubscribe and preferences page") or with PATCH /api/v1/newsletter/settings and preferences_page:
| Field | Rule |
|---|---|
title | 150 characters |
intro | 1,000 characters; {email} inserts the masked address |
done_message | 500 characters, shown after unsubscribing |
language | fr, en, es, it, ru, zh-CN, de; absent: the browser's language |
accent_color, background_color | #rrggbb |
image_url | as for a form: https:// or embedded image, never SVG |
curl -X PATCH https://mail.example.com/api/v1/newsletter/settings \
-H "Authorization: Bearer $VOAARO_API_KEY" -H "Content-Type: application/json" \
-d '{"preferences_page": {"title": "Your Acme emails", "intro": "Choose what {email} receives.", "accent_color": "#d9480f"}}'The object replaces the previous one; {} or null restores the original page (texts translated in seven languages). It is read back in GET /api/v1/newsletter/settings. The behavior does not change: a GET changes nothing, List-Unsubscribe works in one click.
POST /api/v1/newsletter/preferences-page/preview with { preferences_page?, page: "form" | "done" } renders the page without saving anything, for a sample contact and the domain's public topics: { object: "preferences_page_preview", html }.