Skip to content

Reader sign-in

Digize doesn’t host your newsletter’s website, so your own site signs readers in through the API. A reader signs in with their email; they get a link back to your site; your site turns it into a reader token that unlocks paid posts while their tier lasts.

  1. On your site, the reader types their email. Your site’s server calls POST /api/v1/newsletter/readers/sign-in with the email, the returnUrl to come back to, and the visitor’s ip.
  2. Digize emails them a Sign in link from your newsletter’s sending address: returnUrl with ?nl_token=…. The answer is { sent: true } whether or not the email reads your newsletter, so nobody learns who does.
  3. The link comes back to your site. Your server calls POST /api/v1/newsletter/readers/verify with that nl_token, and gets a reader token and the reader: contactId, email, name, tierId, tierName, tier (free or paid) and expiresAt.
  4. Keep the reader token in a cookie (HttpOnly, Secure, 30 days) and pass it as reader to GET /api/v1/newsletter/published and GET /api/v1/newsletter/published/{slug}. A paid reader’s posts come whole; a free reader’s stop at the paywall, with the upgrade link in it.
import { createApiClient } from "@digize/sdk/api";
const api = createApiClient({ apiKey: env.DIGIZE_API_KEY });
// The sign-in form's handler.
await api.newsletter.readers.signIn({
email: form.get("email"),
returnUrl: "https://example.com/account/signed-in",
ip: request.headers.get("cf-connecting-ip") ?? undefined,
});
// /account/signed-in?nl_token=…
const { token, reader } = await api.newsletter.readers.verify({
token: url.searchParams.get("nl_token"),
});
// Set-Cookie: reader=<token>; HttpOnly; Secure; SameSite=Lax; Max-Age=2592000
// A post's page.
const post = await api.newsletter.posts.bySlug({
slug,
reader: cookies.get("reader"),
});
  • Only your sites. returnUrl must be https (or http on localhost) on a host Newsletter › Settings › Paid allows: the post URL pattern’s site, the address readers land on after paying, and any you list there.
  • A link works once, for 30 minutes. A few links an hour per email at most, and a limit per visitor when you pass ip.
  • The tier is read again on every use. The token says who the reader is; whether they’re paid is checked each time, so a reader who cancels loses paid posts at once, and one who upgrades gets them without signing in again.
  • A reader token works for 30 days, for its own workspace only. POST /api/v1/newsletter/readers/me says who a token is for now, or null once it has expired.

A free reader’s paywall carries the upgrade link to the upgrade page. A site with its own upgrade page can start Checkout itself with POST /api/v1/newsletter/tiers/{id}/checkout (the reader token or an email, the tier and month or year), and a gift with POST /api/v1/newsletter/gifts/checkout.