developer docs

Integrate the newsletter agent anywhere.

Use the app directly, connect through MCP, or hand a generated prompt and API key to Lovable, v0, Cursor, Claude Code, or any agent that can edit your site.

Email artifacts

Drafts render through React Email so previews and sent HTML share one source.

Vibe surfaces

Generate opt-ins, landing pages, thank-yous, and embed snippets from author context.

MCP tools

External agents can read context, add sources, draft, add subscribers, and send.

API keys

Use server-side bearer keys for websites and third-party coding agents.

quick start

Use newsletter.app from another builder

Give another coding platform a narrow prompt and a server-side API key. It can wire newsletter.app into your existing website without forcing your site to look like newsletter.app.

You are integrating newsletter.app into my website.

Goal:
- Add an embedded opt-in form.
- Send subscribers to newsletter.app.
- Keep the page visually native to my site.

Use:
- API base: https://newsletter.app
- Auth: Authorization: Bearer <NEWSLETTER_APP_API_KEY>
- Subscribe endpoint: POST /api/subscribe
- MCP endpoint for agent tools: POST /api/v1/mcp

Build:
1. A clean email capture form.
2. Loading, success, and error states.
3. A privacy line and unsubscribe expectation.
4. Optional thank-you page redirect.
5. Server-side API call if the framework supports it. Never expose the API key in browser code.

First read https://newsletter.app/docs, then implement the integration in the existing app style.

subscribe api

Capture subscribers from any site

01

Create an API key

Open Settings > Integrations and create a newsletter.app key. Keep it server-side. Do not paste it into public browser code.

02

Call from your backend

Use a server action, API route, edge function, or backend endpoint. Never call this with a secret key from browser JavaScript.

03

Pass source and tags

Source and tags make reporting, segmentation, and agent follow-up easier later.

POST https://newsletter.app/api/subscribe
Authorization: Bearer <NEWSLETTER_APP_API_KEY>
Content-Type: application/json

{
  "email": "reader@example.com",
  "name": "Reader Name",
  "source": "homepage-optin",
  "tags": ["website", "launch"]
}

agent protocol

MCP for local and hosted agents

MCP is the best interface when an external agent needs to inspect author context, generate drafts, or manage subscribers as tools.

GET  https://newsletter.app/.well-known/mcp.json
POST https://newsletter.app/api/v1/mcp

tools:
- get_author_context
- add_source
- generate_drafts
- list_subscribers
- add_subscriber
- send_draft

email rendering

React Email output

Newsletter drafts are stored as structured plain text and rendered through `lib/email/newsletter-email.tsx`. The agent opens them as HTML artifacts before send, and Resend uses the same renderer for delivery.

import { renderNewsletterEmail } from "@/lib/email/newsletter-email"

const html = await renderNewsletterEmail({
  authorName,
  newsletterName,
  draft: { subject, preheader, body }
})

vibe coding

Forms, landing pages, and thank-you pages

Ask the agent to design an opt-in, landing page, or thank-you flow. It uses author context and the configured OpenAI, Anthropic, OpenRouter, xAI, or Perplexity keys where available, then opens a right-side artifact preview.

Try in the agent:
"Design a minimal embedded opt-in form for my homepage."
"Vibe-code a landing page for founders who want LinkedIn growth."
"Create a thank-you page that asks subscribers to reply with their biggest bottleneck."
"Give me a Lovable prompt that integrates newsletter.app into my site."

configuration

Provider and automation keys

The app can use workspace keys saved in the UI or environment keys in deployment. Secrets should never be printed, committed, or exposed to generated client code.

AI providers:
OPENAI_API_KEY
ANTHROPIC_API_KEY
OPENROUTER_API_KEY
PERPLEXITY_API_KEY
XAI_API_KEY

Sending and scraping:
RESEND_API_KEY
APIFY_TOKEN
APIFY_PROFILE_ACTOR_ID
APIFY_ACTOR_ID
APIFY_AUTHOR_POSTS_ACTOR_ID

Data:
NEXT_PUBLIC_CONVEX_URL
CONVEX_DEPLOY_KEY