Typestate
Sign in

Newsletter with paid tiers

Readers subscribe for free or pay monthly. Paid issues go to paying readers first, and open to everyone after 30 days.

For a writer who sends a newsletter and charges for some issues.

Stripe logo StripeResend logo Resend
Start it with your agentUses 7 of your 100 changes a month

Start the newsletter with paid tiers blueprint on Typestate

Asked you for your website's address and the address your emails come from.

Started Newsletter with paid tiers: 3 record types, 4 web endpoints.

7 actions are compiling, one change each.

Deployed to Sandbox. Try it at your Sandbox address.

What your agent does when you start this blueprint

How it runs

Who does what, in order. Each step is one action of the backend.

  1. A readersubscribes for freeSubscribe
  2. A readerupgrades to EUR 5 a month on a Stripe pageUpgrade to Paid
  3. Stripesays the subscription started, and the reader is paidStart Paid Reading
  4. Yousend an issue, paid or freeSend an Issue
  5. Your backendemails each reader their copyEmail an Issue to a Reader
  6. A readeropens an issue: a paid one is free after 30 daysRead an Issue

The rule you will want to change first

A paid issue opens to free readers 30 days after it was sent.

It lives in the action Read an Issue. Tell your agent how you want it instead: one sentence changes, and you read the change before it goes live.

What it is made of

What it keeps, what it does, and what it reaches.

What it keepsReaderperson, emailMembershipperson, subscription,change, eventIssuetitle, body, paid,sent atWhat it doesSubscribecalled by a signed-inpersonUpgrade to Paidcalled by a signed-inpersonStart Paid Readingwhen a subscriptionstartsEnd Paid Readingwhen a subscriptionendsEmail an Issue toa ReaderSend an Issuecalled by you, withyour keyRead an Issuecalled by a signed-inpersonWhat it reachesStripeTake one-off payments,deposits and...ResendSend email from yourown address: sign-in...Your website4 web endpointsWhat it keepsReaderperson, emailMembershipperson, subscription,change, eventIssuetitle, body, paid,sent atWhat it doesSubscribecalled by a signed-inpersonUpgrade to Paidcalled by a signed-inpersonStart Paid Readingwhen a subscriptionstartsEnd Paid Readingwhen a subscriptionendsEmail an Issue toa ReaderSend an Issuecalled by you, withyour keyRead an Issuecalled by a signed-inpersonWhat it reachesStripeTake one-off payments,deposits and...ResendSend email from yourown address: sign-in...Your website4 web endpoints

What it keeps

Reader

2 fields

One subscriber, with the address issues go to.

person
required
email
required, an email address, never twice

A reader sees only their own subscription.

Membership

4 fields

Each start and end of a paid subscription. Only the payment events write them.

person
required
subscription
required
change
required, one of started, ended
event
required, never twice

Only the payment events write memberships. Your key and the readers read them through the actions.

Issue

4 fields

One issue of the newsletter.

title
required, at most 150 characters
body
required, at most 100000 characters
paid
required, yes or no
sent at
required, a date and time

Only your key sends issues. Who may read one is the rule in Read an Issue.

What it does

Every action, with its full definition in plain English.

SubscribeA signed-in reader subscribes for free.
The signed-in person subscribes for free with their email address. 1. If the person already has a subscription, answer it and change nothing. 2. Save the person as a free reader with their email address, and the signed-in person as its person_id. 3. Email them: subject "You are subscribed", saying the next issue comes to this address.
Upgrade to PaidA reader pays monthly on a Stripe page.
The signed-in reader upgrades to the paid tier. 1. If the person has no subscription, refuse with "Subscribe first". 2. If the person's latest membership change is started, refuse with "You already pay. Thank you". 3. Open a payment page for the Monthly product, with the signed-in person's id as the reference, and answer its address.
Start Paid ReadingWhen a subscription starts, the reader is paid from that moment.
A subscription started. It reads the event's id, the subscription and the person who pays, and it runs as that person, who is the signed-in person. Save a membership change: started, with the person who pays as its person_id, with the subscription's id and the event's id. The event id never repeats, so the same event told twice is saved once. Then email the signed-in person at their own email address: subject "Thank you for your support".
End Paid ReadingWhen a subscription ends, the reader goes back to the free issues.
A subscription ended. It reads the event's id, the subscription and the person who paid. Save a membership change: ended, with the person who paid as its person_id, with the subscription's id and the event's id. The event id never repeats, so the same event told twice is saved once. The reader stays subscribed to the free issues.
Email an Issue to a ReaderOne reader's copy of an issue, sent as its own piece of background work.
Given an issue's title and body and a reader's email address, email the issue to that address: the title as the subject and the body as the text.
Send an IssueYou send an issue, with your key. Paid issues go to paying readers only.
The writer sends an issue, given a title, a body and whether it is paid. 1. Save the issue as sent now. 2. A reader is paid when their latest membership change is started. 3. If the issue is paid, take every paid reader. Otherwise take every reader. 4. For each of them, run the Email an Issue to a Reader flow in the background with the issue's title, its body and the reader's email address. 5. Answer how many readers it goes to.
Read an IssueA reader opens an issue on your site. A paid issue opens to free readers after 30 days.
The signed-in person reads an issue, given its id. 1. If there is no such issue, refuse with "No such issue". 2. If the issue is not paid, answer it. 3. If the person's latest membership change is started, answer it. 4. If the issue was sent more than 30 days ago, answer it. 5. Otherwise refuse with "This issue is for paying readers for its first 30 days".

Who signs in

People sign up and sign in with an email address and a password, or with a provider you add, such as Google.

  • Reader: A reader sees only their own subscription.
  • Membership: Only the payment events write memberships. Your key and the readers read them through the actions.
  • Issue: Only your key sends issues. Who may read one is the rule in Read an Issue.

Money

  • Monthly, EUR 5.00, every month. The paid tier: EUR 5 every month. Paid on a Stripe page, on your own Stripe account.
  • When a subscription starts, Start Paid Reading runs.
  • When a subscription ends, End Paid Reading runs.

Web endpoints

What it doesWho may callAddress
A signed-in reader subscribes.a signed-in personPOST /subscribe
A reader upgrades to paid.a signed-in personPOST /upgrade
You send an issue, with your key.you, with your keyPOST /issues
A signed-in reader opens an issue.a signed-in personGET /issues/:id

What it cannot do yet

  • No comments on issues.
  • Each reader's email is its own background task, so a large list takes a while to go out.

Build the pages with your tool

Typestate is the backend. Paste this brief into Lovable, v0, Claude Code or the tool that builds your pages.

Show the brief
Build the pages for "Newsletter with paid tiers". The backend runs on Typestate and answers these web endpoints: POST /subscribe: A signed-in reader subscribes. Who may call: a signed-in person. POST /upgrade: A reader upgrades to paid. Who may call: a signed-in person. POST /issues: You send an issue, with your key. Who may call: you, with your key. GET /issues/:id: A signed-in reader opens an issue. Who may call: a signed-in person. People sign up at POST /auth/signup and sign in at POST /auth/login, which answers a token. Send it as Authorization: Bearer <token>. A refused call answers a sentence that can be shown to the person as it is.

Start it

  1. Tell your agent the sentence on the right.
  2. It asks you for the https address of the newsletter's website, such as https://letters.example.com. Payments come back to it.
  3. It asks you for the address emails come from, on a domain you verified at Resend, such as "Riverside Physio <hello@riverside.example>".
  4. It tells you what only you can do, such as pasting your Stripe key. A key never goes through the agent.
  5. Open your Sandbox address and try it yourself.

Uses 7 of the 100 changes a month on the Free plan, which runs it on Sandbox. Taking real money on Live needs a paid plan.

Start the newsletter with paid tiers blueprint on TypestateOpen an account

Related blueprints