Developer reference

Enroll a project, configure its domain in maywe.yml and send mail through MCP, the API or the Python SDK.

01 / Get sending

Quickstart & agentic enrollment

POST/v1/enrollments

Enroll once to get a project, its credentials, and the next action. Use POST /v1/enrollments with an account bearer token, or call MCP enroll_project (alias enroll_site) from your signed-in agent.

A website or a workload

For a website, include its public HTTPS origin. For a backend service, Kubernetes workload, or scheduled job, omit it. An origin-less project has its own sender and management key; it needs no website and has no public signup embed.

  • purpose: "alerts" starts with self-alerts to account members using <slug>@send.maywe.email, with no DNS setup.
  • purpose: "transactional" prepares direct delivery to application users. Supply from_email on your custom domain and publish the returned DNS records.
  • purpose: "newsletter" needs both a website origin and an active custom sending domain for signups and campaigns.

Read readiness, then continue

ready_for reports self_alerts, transactional, newsletter_signup, and campaigns separately. Follow next_action; registration alone does not make every capability ready.

Enrollment is resumable: it reuses the matching website, or the account's origin-less project with that name or slug. Existing sender settings and management keys survive retries. Store a returned management_key in your workload's secret store. A later enrollment answers management_key: null with management_key_status: "existing", and the stored key keeps working.

Keep the key, or rotate it

  • mint_management_key: true (maywe enroll --mint-key) mints a key only when the project has none. It keeps an existing key, so it is safe on every retry.
  • rotate_management_key: true (maywe enroll --rotate-key) replaces the existing key and revokes it (management_key_status: "rotated"). Install the new key in the same step.

Either flag needs an account token with credentials:write. Without a flag, such a token still gets a project's first key ("minted"). A token without that scope gets none ("not_minted", explained in not_applied).

If enrollment returns billing_required, follow the checkout link. Resume enrollment after payment succeeds.

Enroll a backend · HTTP
curl -X POST "https://api.maywe.email/v1/enrollments" \
  -H "Authorization: Bearer $MAYWE_ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Cluster ops",
    "purpose": "alerts"
  }'
Ready for self-alerts · response excerpt
{
  "state": "ready",
  "origin": null,
  "slug": "cluster-ops",
  "from_email": "[email protected]",
  "ready_for": {
    "self_alerts": true,
    "transactional": false,
    "newsletter_signup": false,
    "campaigns": false
  }
}
Website enrollment · MCP arguments
{
  "name": "Example newsletter",
  "origin": "https://example.com",
  "purpose": "newsletter",
  "from_email": "[email protected]",
  "reply_to": "[email protected]"
}

02 / Get sending

Direct messages, alerts & sign-in codes

POST/v1/manage/messages

Send one message immediately with a site's sk_ management key, or use MCP send_message. POST /v1/messages is the same send under a shorter name. Account tokens use POST /v1/sites/{site_id}/messages. Direct messages do not require a subscriber list.

Start with your own inbox

The shared <slug>@send.maywe.email sender delivers to members of your MayWe account. It is ready for internal alerts without DNS changes. Use the actual sender and slug returned by enrollment.

Once your custom domain is active, every kind can reach arbitrary external application recipients. Bounce and complaint suppression still applies. An unsubscribed address can receive signin and transactional, but cannot receive message or alert.

Retry without a second email

Set an idempotency_key for each logical send. Repeating the same key and payload returns the original outcome; changing the payload with that key returns 409 idempotency_conflict. HTTP also accepts Idempotency-Key; if both forms are present they must match.

Defaults are 300/hr per site and 5/hr per external recipient on that site, across message kinds and attempted outcomes. Account members share the site allowance without the external-recipient cap. A 429 response includes Retry-After; MayWe's shared sending window also applies.

For sign-in mail, your application generates and validates the code or link and enforces its expiry. MayWe delivers it; expires_in_minutes supplies the expiry wording. Codes and sign-in URLs are redacted from stored message content.

Send an alert · HTTP
curl -X POST "https://api.maywe.email/v1/manage/messages" \
  -H "Authorization: Bearer $MAYWE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "kind": "alert",
    "severity": "warning",
    "title": "Deployment needs attention",
    "summary": "One replica is unavailable.",
    "details": {"cluster": "production", "service": "api"},
    "idempotency_key": "deploy-42-replica-warning"
  }'
KindPayload
alerttitle, severity (info, warning, error, critical), optional summary, details, and paired cta_label / cta_url. Custom HTML is optional; a title is required without it.
messageRequired subject and html; optional plain text. HTML is sanitized.
signinRequired code or signin_url; optional expires_in_minutes, summary, and subject.
transactionalRequired template (a named template, below), its variables, and idempotency_key; optional template_revision. The subject, markup, and button are the template's.
Sign-in code · JSON
{
  "to": "[email protected]",
  "kind": "signin",
  "code": "482913",
  "expires_in_minutes": 10,
  "idempotency_key": "signin-attempt-782"
}
PUT/v1/manage/templates/transactional/{name}

Named transactional templates

A receipt your product owes a user, such as application_received or partner_approved, is a named template. Store it once with PUT /v1/manage/templates/transactional/{name}, then send it by name. A changed template becomes its next revision; sending the same one again changes nothing. GET reads it back and DELETE retires it.

  • subject, heading, and body are required. cta_label and cta_url go together.
  • variables declares every {{name}} the template places, as text, https_url, or usd_amount. {{site_name}} and {{email}} need no declaration.
  • {"type": "https_url", "sensitive": true} is a join or reset link. It is sent, never stored, and never placed in the subject. A cta_url is a literal https address or exactly one https_url variable.

Send it with a key you can retry

POST /v1/messages with kind: "transactional" names the template and gives its variables. idempotency_key is mandatory: a retry under the same key answers the first send with deduplicated: true, and nothing is sent twice. It reaches an address that left the newsletter; a bounce or a complaint still suppresses it.

An https_url value must point at the site's origin or its destination's host. An origin-less backend project has no origin, so set destination_url (enrollment, PUT /v1/manage/site, or site.destination.url in maywe.yml) to the host its links open, such as https://app.example.com/.

Store a named template · HTTP
curl -X PUT "https://api.maywe.email/v1/manage/templates/transactional/partner_approved" \
  -H "Authorization: Bearer $MAYWE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "{{workspace_name}} is approved",
    "heading": "You are in",
    "body": "Your workspace {{workspace_name}} is ready. The button opens it.",
    "cta_label": "Open your workspace",
    "cta_url": "{{join_url}}",
    "variables": {
      "workspace_name": {"type": "text"},
      "join_url": {"type": "https_url", "sensitive": true}
    }
  }'
Send it · HTTP
curl -X POST "https://api.maywe.email/v1/messages" \
  -H "Authorization: Bearer $MAYWE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "kind": "transactional",
    "template": "partner_approved",
    "variables": {
      "workspace_name": "Acme",
      "join_url": "https://app.example.com/join/7f3a"
    },
    "idempotency_key": "partner-approved-acme"
  }'
PUT/v1/manage/messages/reply-routing

Reply routing for the whole site

One call sets where everything that comes back goes. reply_to is the Reply-To on the site's mail. reply_webhook_url receives the events named in events. Omit a field to leave it alone; null clears reply_to or reply_webhook_url.

EventSent when
message.replyA recipient answers a message, or taps one of its reply links. A site sends this alone until you name others.
email.receivedMail reaches the site's forwarding address without answering a message.
subscriber.confirmedA signup confirms its address.
subscriber.unsubscribedA subscriber leaves.
mailbox.receivedA hosted mailbox (mailboxes, below) receives mail, with a reply capability for its thread.

The first URL mints a whsec_ signing secret, answered once as webhook_secret: store it as MAYWE_WEBHOOK_SECRET. GET on the same path reads the routing back without it. Account tokens use /v1/sites/{site_id}/messages/reply-routing; in maywe.yml the same fields are the inbound section.

Route replies and events · HTTP
curl -X PUT "https://api.maywe.email/v1/manage/messages/reply-routing" \
  -H "Authorization: Bearer $MAYWE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reply_to": "[email protected]",
    "reply_webhook_url": "https://app.example.com/webhooks/maywe",
    "events": ["message.reply", "subscriber.confirmed", "mailbox.received"]
  }'

03 / Get sending

Sender & custom domains

MayWe sends external transactional mail and newsletters from your domain. Choose a From address, a sender name, and a reply-to address that reaches a person. The From address itself needs no mailbox.

Use your main domain or a sending subdomain such as news.example.com. Add it on the site page, during enrollment, or with MCP add_sending_domain. The service returns the exact five records and their values.

Publish the returned records

The DKIM records and the MAIL FROM pair live on their own DNS names. Your existing root MX, SPF, and website remain in place. If bounce. is already used by another provider, resolve that conflict or choose a sending subdomain before changing it. On Cloudflare, use DNS only for the CNAMEs.

Verification runs automatically

Domain verification checks for the records for up to 72 hours. MayWe enables the sender once both DKIM and MAIL FROM are verified. You can close the page after publishing; Check now or MCP check_sending_domain requests a fresh check. Fix a failed record and check again to restart that part.

Change the sender's local part, display name, or reply-to address in place without new DNS records. To change domains, remove the current domain and add the replacement.

RecordType & purpose
DKIM1CNAME · first signing record on <token>._domainkey.
DKIM2CNAME · second signing record.
DKIM3CNAME · third signing record.
MAIL_FROM_MXMX · routes bounces on bounce. your domain to MayWe's delivery service. Keep the returned priority separate from its value.
MAIL_FROM_SPFTXT · authorizes sending for that MAIL FROM subdomain.

Recommended, separate from verification

MayWe first reads your DNS. It recommends monitoring DMARC (v=DMARC1; p=none) only if no applicable policy exists on the domain or its parents, and an A record only when the domain has no address record.

Existing policies stay intact. Neither recommendation is required for verification; a stricter DMARC policy is a separate decision.

04 / Build your newsletter

Website embed & CSP

Website enrollment returns a complete signup embed. Install all four pieces; the browser script enables the form and derives its API endpoint from its own src.

  1. Form: use the site's pk_ publishable key, an email input, the hidden honeypot, and a submit button. Give each placement a distinct data-newsletter-source label.
  2. Script: put the deferred embed.js tag before </body>. Keep the email field and button disabled until it loads.
  3. Styles: add .visually-hidden to your stylesheet for the honeypot. Keep this rule out of inline attributes.
  4. Policy: merge the returned script and connection sources into your existing CSP.

Recover the embed without rotation

GET /v1/sites/{id}/embed returns publishable_key, the four-part embed, and embed_html. Recoverable keys can be read again; legacy hash-only keys return a placeholder and need one rotation to become recoverable.

The key authorizes signup on the registered origin; it grants no management access. Origin-less projects have no public embed. If your site has an anti-abuse check configured, also use the returned challenge markup, script, and CSP sources.

Signup form · HTML
<form data-newsletter-key="pk_YOUR_PUBLISHABLE_KEY"
      data-newsletter-source="footer">
  <label for="newsletter-email">Email</label>
  <input id="newsletter-email" name="email" type="email"
         autocomplete="email" required disabled>
  <div class="visually-hidden" aria-hidden="true">
    <label>Website
      <input name="website" type="text"
             tabindex="-1" autocomplete="off">
    </label>
  </div>
  <button type="submit" disabled>Join the list</button>
</form>
<script src="https://api.maywe.email/embed.js" defer></script>
Honeypot · CSS
.visually-hidden {
  position: absolute;
  left: -9999px;
}
Merge into your CSP
script-src 'self' https://api.maywe.email;
connect-src 'self' https://api.maywe.email;

05 / Build your newsletter

The eleven design tokens

Confirmation mail, welcome mail, lifecycle pages, and the campaign shell share one semantic vocabulary. Put your brand's values in newsletter/tokens.json; omitted tokens fall back to neutral defaults.

Templates use {{tokens.ink}} and the other token names. The sync Action resolves them in your pipeline. Runtime values such as {{confirm_url}} and {{unsubscribe_url}} remain for the service to fill when it sends.

Use accent as a fill with accent_ink on top. Reserve the monospace stack for IDs, paths, and numbers so ordinary mail remains easy to read.

tokens.json · partial example
{
  "paper": "#ffffff",
  "ink": "#18251e",
  "accent": "#d9f279",
  "accent_ink": "#18251e"
}
TokenRole
paperMain background
paper_2Quiet bands and footers
inkPrimary text, borders, solid fills
ink_2Secondary text
ink_3Labels and captions
lineHairline separation
line_2Container borders
accentAccent fill, never text
accent_inkText on the accent fill
fontFont stack, with system fallbacks
monoIDs, paths, and numerals

06 / Build your newsletter

Declarative maywe.yml & the sync Action

PUT/v1/manage/site

Declare a site in one file at the root of your repository, maywe.yml: who it is, who it sends as, its double opt-in mail, its design tokens and where replies go. Review it like code, and push it from CI.

  • PUT /v1/manage/site with the site's sk_ management key reconciles an existing site to the file. The answer lists what changed.
  • POST /v1/enrollments with an account's ak_ token creates the site from the same file, or resumes it. It answers a management_key once: store it as MAYWE_MANAGEMENT_KEY.
SectionDeclares
sitename, origin, reply_to, destination (url, label) and archive_enabled
senderfrom_email and display_name, the name in the From header
lifecycleThe confirm and welcome mail: an HTML file, or subject, preheader, heading, body and, for welcome, a cta_label with its cta_url, rendered into the site's shell
templatesAny other kind, such as the campaign shell
transactional_templatesNamed templates sent with kind: "transactional": subject, heading, body, an optional cta_label with its cta_url, and variables
inboundReply routing: webhook_url, the webhook events, forwarding and allowed_senders (reply_to may sit here or in site)
mailboxesHosted mailboxes on the sender's domain: boxes, each with an address, up to ten aliases (postmaster and abuse are added for you) and an agent_policy, by default draft_or_approved_threads
tokensYour values for the eleven design tokens

Templates with frontmatter

A template or campaign file may open with YAML frontmatter between --- lines. Its fields join the entry that names the file in maywe.yml. A field set differently in both places fails the build, so each one lives in one place.

A confirm file without {{confirm_url}} (a welcome file without {{unsubscribe_url}}) and without a <table> of its own is the body of the site's shell, which adds the button, the links and the preheader. One that places them itself is the whole mail, so it takes no preheader field.

Keys and secrets never go in maywe.yml. The SDK refuses a value that looks like one (sk_, ak_, whsec_) and reads them from the environment instead.

maywe.yml
version: 1
site:
  name: Example
  origin: https://example.com
  reply_to: [email protected]
  destination: { url: https://example.com/, label: Read the latest }
sender:
  from_email: [email protected]
  display_name: Example
lifecycle:
  confirm: templates/confirm.html
  welcome:
    subject: You're on the list
    heading: Welcome aboard
    body: We'll write when there's something worth reading.
    cta_label: Read the latest
    cta_url: https://example.com/
transactional_templates:
  partner_approved:
    subject: "{{workspace_name}} is approved"
    heading: You are in
    body: Your workspace {{workspace_name}} is ready. The button opens it.
    cta_label: Open your workspace
    cta_url: "{{join_url}}"
    variables:
      workspace_name: { type: text }
      join_url: { type: https_url, sensitive: true }
inbound:
  forwarding: true
  allowed_senders: [example.com]
  webhook_url: https://example.com/webhooks/maywe
  events: [message.reply, email.received, subscriber.confirmed, mailbox.received]
mailboxes:
  boxes:
    - address: [email protected]
      aliases: [[email protected]]
      agent_policy: draft_or_approved_threads
tokens:
  ink: "#18251e"
  accent: "#d9f279"
  accent_ink: "#18251e"
templates/confirm.html · frontmatter
---
subject: Confirm your subscription
preheader: One click, and you're on the list.
heading: One click to go
---
<p>Confirm your address, and the next issue is yours.</p>
Push from CI · shell
export MAYWE_BASE_URL=https://api.maywe.email
python -m maywe validate     # read maywe.yml and its files
python -m maywe enroll       # POST /v1/enrollments, MAYWE_ACCOUNT_TOKEN: creates or resumes the site
python -m maywe sync         # PUT /v1/manage/site, MAYWE_MANAGEMENT_KEY

The same calls over HTTP, from any language

The CLI is a thin client; installing it is optional (07 · Python SDK). maywe sync sends the parsed maywe.yml as JSON to PUT /v1/manage/site, with each file it names sent as that file's text. The API takes that nested form, or the flat field names enrollment uses.

maywe enroll flattens the same declaration into POST /v1/enrollments. There inbound takes the reply-routing names (reply_webhook_url, events, reply_to), and mailboxes keeps its shape. Add mint_management_key: true or rotate_management_key: true as 01 · Enrollment describes.

Both calls are declarative and safe to repeat, unless rotate_management_key is set. A field you leave out is left alone, and a named template you leave out is kept, never retired.

maywe sync, without the SDK · HTTP
curl -X PUT "https://api.maywe.email/v1/manage/site" \
  -H "Authorization: Bearer $MAYWE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "version": 1,
    "site": {"name": "Example", "reply_to": "[email protected]"},
    "sender": {"from_email": "[email protected]", "display_name": "Example"},
    "inbound": {
      "webhook_url": "https://example.com/webhooks/maywe",
      "events": ["message.reply", "mailbox.received"]
    },
    "mailboxes": {
      "boxes": [{"address": "[email protected]",
                 "aliases": ["[email protected]"],
                 "agent_policy": "draft_or_approved_threads"}]
    }
  }'
maywe enroll, without the SDK · HTTP
curl -X POST "https://api.maywe.email/v1/enrollments" \
  -H "Authorization: Bearer $MAYWE_ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example backend",
    "purpose": "transactional",
    "from_email": "[email protected]",
    "destination_url": "https://app.example.com/",
    "inbound": {
      "reply_to": "[email protected]",
      "reply_webhook_url": "https://app.example.com/webhooks/maywe",
      "events": ["message.reply", "subscriber.confirmed", "mailbox.received"]
    },
    "mailboxes": {
      "boxes": [{"address": "[email protected]",
                 "aliases": ["[email protected]"],
                 "agent_policy": "draft_or_approved_threads"}]
    },
    "mint_management_key": true
  }'

Templates from a design system: the newsletter/ directory

A team whose mail follows a design system can keep a newsletter/ directory instead. The sync Action renders {{tokens.*}} from tokens.json and uploads each template with the site's management key.

Repository layout
newsletter/
  config.yml       # subjects: { confirm: "…", welcome: "…" }
  tokens.json      # values from your design system
  templates/
    confirm.html   # {{confirm_url}} + {{unsubscribe_url}}
    welcome.html   # {{unsubscribe_url}}
    campaign.html  # shell for each campaign's body

A missing required placeholder fails the build. Uploaded HTML is sanitized; the stored result is what the subscriber receives.

GitHub Actions · workflow step
- uses: awowIO/newsletter-plugin@v1
  with:
    directory: newsletter
    base-url: https://api.maywe.email
  env:
    NEWSLETTER_TOKEN: ${{ secrets.NEWSLETTER_TOKEN }}

One site, one deployment secret

NEWSLETTER_TOKEN is the site's sk_ management key. The SDK reads it too, as an alternative to MAYWE_MANAGEMENT_KEY. Store it as a GitHub Actions secret. Re-enrolling keeps the key, mint_management_key: true included. Rotating it (rotate_management_key: true or maywe enroll --rotate-key) revokes the old key, so update the secret in the same step.

07 / Build your newsletter

The maywe Python SDK & triggers

The maywe package reads maywe.yml, takes its keys from the environment and wraps the API in a few calls. Each call has an async form, and a *_sync twin for WSGI and other synchronous apps.

Install the SDK and the maywe CLI

Install the SDK from sdk/python in the MayWe repository using Python 3.11 or later. It is not published to PyPI. The repository installation includes the maywe CLI. Add [fastapi] for the webhook router.

Install · shell
uv pip install "git+https://github.com/awowIO/newsletter.git#subdirectory=sdk/python"
pip install ./sdk/python                  # from a checkout
pip install "./sdk/python[fastapi]"       # with the webhook router
uvx --from ./sdk/python maywe --help      # run the CLI without installing it
maywe --help                              # validate, sync, enroll

Without the SDK, every call it makes is a plain HTTPS request with a bearer key. The HTTP examples in each section are those calls, for curl or any other language.

VariableUsed for
MAYWE_BASE_URLThe API: set it to https://api.maywe.email for this deployment. Unset, the SDK uses https://api.maywe.email.
MAYWE_PUBLISHABLE_KEYsubscribe, subscribe_waitlist (pk_)
MAYWE_MANAGEMENT_KEY or NEWSLETTER_TOKENMessages, replies, campaigns and sync (sk_)
MAYWE_ACCOUNT_TOKENenroll (ak_)
MAYWE_WEBHOOK_SECRETVerifying webhooks (whsec_)
MAYWE_ORIGINOverrides site.origin for signups

Signups and the sign-in waitlist

subscribe is the same double opt-in as the embed form, posted with the site's origin. subscribe_waitlist labels the signup signin-invite, for someone who signed in before their invitation. When they confirm, a subscriber.confirmed trigger with source="signin-*" can invite them.

Messages with 1-tap replies

Give send_message a context_ref and actions (any of approve, marginal, skip, ask, reply). The SDK first mints signed reply links through POST /v1/manage/messages/reply-links. Then it places them where your HTML names them ({{approve_url}}, {{reply_url}}, {{mailto_url}}, …), or as one link per action below your message.

Outbound · Python
from maywe import MayWe

mw = MayWe.from_yaml("maywe.yml")

# A sign-in from someone not invited yet: double opt-in, labelled signin-invite.
await mw.subscribe_waitlist("[email protected]")
mw.subscribe_waitlist_sync("[email protected]")       # from a WSGI app

# A message whose answers come back as message.reply events.
sent = await mw.send_message(
    "[email protected]",
    subject="Three new roles for you",
    html="<p>Senior engineer at Acme, remote.</p>",
    context_ref="jobflux:s1:p9",
    actions=("approve", "marginal", "skip"),
    meta={"posting": "p9"},
)
sent.links.approve_url

# A named transactional template (POST /v1/messages); the key makes a retry safe.
await mw.send_template(
    "[email protected]", "partner_approved",
    {"workspace_name": "Acme", "join_url": "https://app.example.com/join/7f3a"},
    idempotency_key="partner-approved-acme",
)

Triggers: when this happens, do that

@mw.on(event, ...) binds a function to an event. Every filter given must match: action, a context pattern, a sender glob or bare domain, or, for subscriber events, a source glob. A {name} in the context pattern captures one :-separated segment and is passed to the function as that keyword argument; * matches anything.

EventTyped asFilters
message.replyReplyEventaction, context, sender
email.receivedInboundEmail: mail to the site's forwarding address that answers no messagesender
subscriber.confirmedSubscriberEventsource
subscriber.unsubscribedSubscriberEventsource
mailbox.receivedMailboxEvent: mail to a hosted mailbox, with thread_id and a reply capability for that threadmailbox, sender

event.clean_text holds only the writer's new words. The quoted message (On … wrote:, Op … schreef …:, Am … schrieb …:, Le … a écrit :, -----Original Message-----, From: / Van: header blocks, > lines) is cut away. So are a -- signature and a mobile footer such as Sent from my iPhone or Verzonden vanaf mijn iPhone. event.raw_text keeps the reply as MayWe stored it.

Webhook or poll

Mount mw.fastapi_router() to receive signed webhooks at /webhooks/maywe, or call mw.handle_webhook_sync(body, headers) from any other framework. Each POST carries X-MayWe-Signature: t=<unix>,v1=<hex>, an HMAC-SHA256 of <t>. and the raw body, keyed with the whole whsec_ secret. The SDK refuses a signature made more than five minutes before or after its own clock. A handler's returned string becomes the reply's resolution note, and the answer {"ack": true} acknowledges the reply in the same round trip.

No public endpoint? Run await mw.drain_replies() on a schedule. It reads the unprocessed replies oldest first, runs the triggers and acknowledges each one a trigger took. A reply no trigger matches stays unprocessed.

A trigger that raises is not caught. The webhook answers an error, so MayWe retries the reply, and the drain stops without acknowledging it.

Triggers · Python
@mw.on("message.reply", action="approve",
       context="jobflux:{session_id}:{posting_id}")
async def approved(event, session_id, posting_id):
    await apply(session_id, posting_id)
    return f"applied to {posting_id}"        # the resolution note

@mw.on("message.reply", action="ask", context="jobflux:*")
async def question(event):
    await ask_agent(event.context_ref, event.clean_text)

@mw.on("email.received", sender="*@awow.io")
def forwarded_lead(event):
    file_lead(event.sender, event.subject, event.clean_text)

@mw.on("subscriber.confirmed", source="signin-*")
def invite(event):
    send_invitation(event.email)

app.include_router(mw.fastapi_router())   # FastAPI: signed webhooks
await mw.drain_replies()                  # or poll, from a scheduled job
A WSGI receiver · Python
from maywe import WebhookSignatureError

def maywe_webhook(environ, start_response):
    body = environ["wsgi.input"].read(int(environ.get("CONTENT_LENGTH") or 0))
    headers = {key[5:].replace("_", "-"): value
               for key, value in environ.items() if key.startswith("HTTP_")}
    try:
        answer, status = mw.handle_webhook_sync(body, headers), "200 OK"
    except WebhookSignatureError as refused:
        answer, status = {"detail": str(refused)}, "400 Bad Request"
    payload = json.dumps(answer).encode()
    start_response(status, [("Content-Type", "application/json")])
    return [payload]

08 / Build your newsletter

Campaigns

A campaign combines your HTML body with the site's campaign.html shell. Create a draft with a slug, subject, optional preheader, and body. Preview it as a sample subscriber before sending.

  1. Test: send to an account member. Other test recipients return 422 test_recipient_not_member.
  2. Schedule: choose a time, or send now. A campaign needs an active sending domain and an account within its subscriber band.
  3. Deliver: sending snapshots the confirmed list and passes delivery to the worker.

MayWe paces mail against its available per-second and daily sending capacity. Tests are real sends and use the same window: exhausted capacity returns 429 send_window_full with Retry-After; an unreadable quota returns 503 quota_unavailable.

Delivery counts, including delivered, bounced, complained, and failed, follow provider events.

StageMCP tools
Draftcreate_campaign, update_campaign
Reviewpreview_campaign, send_test_campaign
Sendschedule_campaign, send_campaign
Monitorget_campaign, list_campaigns
Stop / removecancel_campaign, delete_campaign

Public archive

When the site's archive is enabled, sending and sent campaigns appear at its archive address with personal placeholders stripped. Cancelled and failed campaigns are absent.

Use /v1/manage/campaigns from CI or the dashboard to run the same workflow.

09 / Reference

MCP & agent workflows

Connect your coding agent to https://api.maywe.email/mcp and sign in through the browser. Start with get_setup_status, then enroll the project. A connection bound to a site stays scoped to that site.

The newsletter@awow plugin packages the connection and setup skill for Claude Code and Codex. An account token also supports automation that cannot complete browser sign-in.

Read the returned ready_for, next_action, and refusal codes before continuing. Tools report API failures such as capacity and billing_required.

MCP server · JSON
{
  "mcpServers": {
    "newsletter": {
      "url": "https://api.maywe.email/mcp"
    }
  }
}

Projects & senders

enroll_project, enroll_site, list_sites, get_site, update_site, add_sending_domain, check_sending_domain.

Messages & templates

send_message, list_messages, get_message, get_templates, put_template, plus the campaign workflow above.

10 / Reference

Tokens & keys

CredentialScopeWhere it belongs
pk_ publishable keyWebsite signup only, bound to the registered origin. Recover through the embed endpoint.Public form markup.
sk_ management keyOne project on /v1/manage/*: templates, sending domains, campaigns, and messages. Re-enrollment keeps it, mint_management_key: true included. rotate_management_key: true or POST /v1/sites/{site_id}/management-key/rotate replaces it and revokes the previous key.Backend, Kubernetes, or CI secret store; send as Authorization: Bearer sk_….
ak_ account tokenYour account across its sites, through REST and MCP. The service stores its prefix and hash, not a recoverable secret.Private automation. Create and revoke on the tokens page.

11 / Reference

CSV export

Export CSV (confirmed) on the site page downloads <host>-subscribers.csv, or uses the project slug for an origin-less project. Rows are ordered by confirmation time.

Only confirmed subscribers are included. Pending, unsubscribed, bounced, and complained rows are excluded. The audit records the row count, never an address.

Use MCP export_subscribers or the account-authenticated endpoint alongside. Export remains available when billing or subscriber capacity pauses sending.

Download confirmed subscribers · HTTP
curl "https://api.maywe.email/v1/sites/$MAYWE_SITE_ID/subscribers/export" \
  -H "Authorization: Bearer $MAYWE_ACCOUNT_TOKEN" \
  -o subscribers.csv
CSV columns
email,status,confirmed_at

12 / Reference

Band limits & paused signups

Each band sets a site limit and a limit on confirmed subscribers across those sites. See available plans, prices and limits on Pricing or the billing page.

At the ceiling, new signups pause. Existing confirmed subscribers remain, and an earlier confirmation link still works. Only when the total is over the ceiling are campaigns and test sends blocked for capacity.

Creating a site also respects the band's site count. Template uploads, key rotation, export, and deletion remain available. Raising the band takes effect when the billing webhook confirms it.

Direct messages have their own hourly limits and are not blocked by subscriber capacity. They still require active billing and an eligible sender and recipient.

GET /v1/account/usage lists usage.paused_sites. A site's signups_paused_reason explains its pause. The form shows “Signups are paused for now.”

ReasonWhat restores service
sending_domain_requiredActivate the custom sending domain for newsletter signup. Shared self-alerts remain a separate capability.
capacityRaise the band or reduce confirmed subscribers. Over the ceiling, site creation, adding a domain, and campaign/test sends return 402 capacity.
billing_requiredComplete or restore the subscription. Sending and growth operations are gated; existing sites and export stay accessible.
Signup response
{
  "ok": false,
  "status": "paused"
}