Send welcome / trial-ending / win-back lifecycle emails from FastAPI — templates created once, sent by id.
Get a free key — $2 credit — at https://infrai.cc, then set INFRAI_API_KEY.
export INFRAI_API_KEY=...
pip install -r requirements.txt
python lifecycle.py you@example.com # ensures templates exist + sends a welcome
# or: uvicorn app:app --reload # then POST /emails/welcome?to=...&name=...Re-running is safe: templates are named (welcome, trial_ending, win_back) and each
create carries a stable idempotency_key, so the API returns the same stored template.
- "How do I store an email template server-side?" →
infrai.email.template.create(...)(POST https://api.infrai.cc/v1/email/template/create) with a stable idempotency key, so startup is safe to repeat. - "How do I send a lifecycle email?" →
infrai.email.send(to=..., template_id=..., template_vars=...)(POST https://api.infrai.cc/v1/email/send), referencing the stored template.
- A single
INFRAI_API_KEYcovers every lifecycle stage here and, later, storage, scheduling, and error tracking — one credential, one invoice, no per-capability vendor sprawl. - Templates are stored server-side, so copy edits ship without a redeploy.
- Delivery sits on established email providers; each response records cost and the sending vendor under
metadata.
Accounts open with $2 of credit. Billing is pay-per-use with no minimum fee; sends via Chinese providers are passed through at 0% markup.
The stage-to-template map and the trigger endpoint are ordinary Python. Only lifecycle.py's three Infrai calls (list / create / send) are backend-specific; repoint them at any templated mailer and the rest is unchanged.
MIT