Confirm email subscriptions
Request email subscription confirmation, wait for recipient consent, and subscribe confirmed contacts to a topic.
Use double opt-in to subscribe someone to a topic only after they confirm their email address. Your server requests a confirmation email; the recipient follows its link and chooses Confirm subscription. Opening the link alone does not subscribe them.
Request confirmation
Create a topic for your audience and use a sender on your verified sending domain. Keep your Samva API key on your server. Apply your own form abuse controls before calling Samva.
import { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.subscriptions.subscribe({
email: "ada@example.com",
topicId: "unsub_1234567890abcdef",
from: { email: "newsletter@your-domain.com", name: "Your newsletter" },
consentSource: "newsletter-signup",
});
console.log(result.success, result.expiresAt);curl -X POST https://api.samva.dev/v1/subscriptions \
-H "x-api-key: $SAMVA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"ada@example.com","topicId":"unsub_1234567890abcdef","from":{"email":"newsletter@your-domain.com","name":"Your newsletter"},"consentSource":"newsletter-signup"}'A successful response accepts the confirmation request. It does not establish consent or guarantee
delivery. The response contains success: true and expiresAt; it never returns the confirmation
link. Message content and previews show a placeholder; only the recipient's email contains the
working confirmation link. See Request subscription confirmation for
request fields and errors.
consentSource records where signup happened. If you supply consentIp, derive it on your server
from the incoming request and your trusted proxy configuration. Both fields are caller-supplied
context, not proof Samva independently verified. Do not accept arbitrary browser values as trusted
consent evidence.
Wait for recipient confirmation
The confirmation link expires after seven days and can subscribe its recipient once. The email links to a hosted confirmation page in your sending brand. Treat that link as private: do not put it in analytics, logs, support tickets, or shared previews. The recipient must choose Confirm subscription to complete the request.
Confirmation links use your organization's oldest active custom tracking host, or Samva's host when none is active. The visible unsubscribe link in your email uses the same host selection. Email clients' one-click unsubscribe requests continue to use Samva's host.
After a custom host is removed, its confirmation and preference pages remain available for seven days. Keep its DNS records in place during that period. An individual confirmation link still expires at its original deadline.
The page uses your brand's logo, accent, fonts, and company name. Set footer.websiteUrl on the
brand to give recipients a return link to your HTTPS website. Brand edits also update the page for
links you have already sent. Pages show “Powered by Samva” unless your organization has the
remove_samva_branding entitlement, included in Growth and Scale.
Successful confirmation creates the contact, claims the email address as one of its identities,
records the address's email consent as opted_in
with the source double_opt_in, and subscribes the contact to the topic on the email channel. In a
namespaced topic, the contact lands in that topic's namespace. Samva then emits
contact.subscribed; use that event to start
welcome flows. Each successfully confirmed fresh link emits an event, including when the contact
is already subscribed.
Requesting confirmation stores only the pending request: the address, the topic, and the consent context you supplied. No contact exists, no consent is recorded, and nothing counts toward your active-contact limit until the recipient confirms. A request nobody confirms expires after seven days and leaves nothing behind.
Confirmation changes only the named topic. Leaving or joining another topic is independent, and delivery suppressions still apply. See Topics.
Handle failures and retries
Reopening a confirmed link shows “Already subscribed” without subscribing again or emitting another subscription event. An expired link asks the recipient to sign up again and includes your brand's return link when configured. Unknown or removed links show an unbranded unavailable page.
An invalid or expired link cannot confirm a subscription. Ask the recipient to request another email when their link expires. Each accepted request creates a fresh link; retrying the signup request can send another confirmation email, so do not automatically repeat it after an uncertain response. Apply a resend delay in your own form.
If the same confirmation email is delivered again, either delivered link can confirm the request. Confirming one makes all links for that request report “Already subscribed”.
New contacts count toward your plan's active-contact limit when they are created at confirmation. If the limit is full, the link stays unused and confirmation makes no contact, subscription, consent, or webhook changes. The hosted page asks the recipient to notify the sender and retry the same link before it expires. An address that already has a contact confirms without an additional capacity check.
If confirmation fails temporarily, the recipient can retry the same link. The contact, consent, and subscription are created together; a failed confirmation does not establish consent. Handle duplicate webhook deliveries using the webhook delivery contract.
Customize the email
The confirmation email uses the brand and footer configured for your sender and sends from the
from address you supplied. Set templateSlug to use a published template that accepts
confirmUrl as input. The rendered HTML must contain at least one link using the complete,
unchanged value as an <a href>:
<a href={confirmUrl}>Confirm subscription</a>HTML-only templates are supported. If the template includes a text part, it must also include
the complete confirmUrl. Put the complete URL on its own line or separate it from surrounding text with
whitespace. A parenthesized URL, as in Confirm (URL), is also supported. Do not append parameters
or wrap it in another URL. Do not use confirmUrl in images,
srcset, styles, other attributes, the subject, or HTML body text. Samva rejects the subscription
request with a validation error naming the template if either required link is missing or the
template uses confirmUrl in any of those places.
Keep the request's purpose clear in the subject and body so recipients know which subscription they are confirming.
A topic the recipient previously left does not block the confirmation email. This lets a recipient confirm a request to rejoin. Delivery suppressions still apply.
CLI and MCP
Request confirmation from your terminal:
samva subscriptions subscribe \
--email ada@example.com \
--topic-id unsub_1234567890abcdef \
--from newsletter@your-domain.com \
--from-name "Your newsletter" \
--consent-source newsletter-signup \
--jsonAn authenticated MCP agent can request the same email with contacts_subscribe. Both surfaces
start the request; the recipient completes confirmation on the hosted page.
Related documentation
Samva Agents (Preview)
Preview · Available to selected organizations. Create an agent in Samva Agents that answers conversations on your mailbox endpoints, then edit its draft, publish versions, and set how it is supervised.
Receive webhooks
Create an endpoint, verify each signed request, and process retried deliveries once.