Workflow Approvals with Resend

When a Mastra workflow suspends for human review, how does the reviewer send their decision back? This template uses Resend to email the proposal with signed Approve and Decline links. The reviewer opens a link and confirms their choice in the browser. Mastra then resumes the original run and follows the selected path.

Deploy to Mastra Platform

Why we built this

Reviewers often work outside the app that started the workflow. Email brings the proposal and decision links to their inbox, where they can review it on their own time. The template shows how to keep that handoff reliable across restarts and repeated clicks by storing the suspended run and recording the decision before queuing the resume.

Demo

Prerequisites

  • Install a supported release of Node.js. Node.js requirements
  • OpenAI API key for OPENAI_API_KEY.
  • Resend API key and sender for RESEND_API_KEY and RESEND_FROM. For a first run, use onboarding@resend.dev as the sender and your Resend account email as DEMO_APPROVER_EMAIL. Use a verified sending domain with click tracking disabled to test direct approval links for other recipients. Local email setup
  • ngrok account and CLI for local development only, with your account token configured locally. Set APPROVAL_BASE_URL to your assigned HTTPS origin and disable account-level Full Capture. Local tunnel setup
  • Approval signing secret for APPROVAL_SIGNING_SECRET. Generate it during setup and keep the same value across restarts.

Quickstart 🚀

These steps run Studio locally. For a hosted first run, start with the Mastra Platform deployment guide.

  1. Clone the template
    • Run npx create-mastra@latest workflow-approvals-resend --template workflow-approvals-resend to scaffold the project and install its dependencies.
    • Run cd workflow-approvals-resend.
  2. Configure local approvals
    • Run cp .env.example .env and fill in the values from Prerequisites.
    • Run node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))" and save the output as APPROVAL_SIGNING_SECRET. Keep DATABASE_PROVIDER=local and APPROVAL_MODE=confirmation for this walkthrough.
  3. Start Mastra and ngrok
    • Run npm run dev. In a second terminal in the project directory, run npm run tunnel:approvals.
  4. Approve a deployment plan
    • In Mastra Studio, open Workflows, select ai-deployment, and run it with {"request":"Plan a rollout for a fictional inventory dashboard"}.
    • The run drafts a plan and suspends while Resend sends the approval email. Choose Approve in the email, then Confirm approval in the browser. Return to the original run in Studio and check that it completes with protectedEffect: true for the simulated deployment.

Try it out

  • Decline a publication draft. Run ai-content-publishing with {"request":"Draft a launch announcement for a weekly inventory report"}. Confirm Decline from the email and check that the run reports protectedEffect: false.
  • Try the one-click demo. Run simulated-publication with {"reviewerEmail":"you@example.com","draftId":"demo-draft","revision":1}. Use an inbox your sender can reach. The browser submits the selected decision automatically when the link opens. Review modes and expected results
  • Restart with an approval pending. Start a run, wait for its email, then restart Mastra with the same database, origin, and signing secret. Use the original link before it expires and check that the same run resumes. Operations and recovery

Customization

  • Ask a coding agent to trace the proposal, approval, and outcome steps in src/mastra/workflows/use-cases.ts and propose a plan. For example, “Adapt this workflow to email a reviewer before scheduling a simulated data export.”
  • Change what reviewers see in src/mastra/approvals/email.ts, or reuse createApprovalStep in your own workflow. Code walkthrough

Documentation

Deploy to Mastra Platform

Deploy to Mastra Platform

Set DATABASE_PROVIDER=turso in the Deploy form and select Create project. Attach Turso to production while the first build runs. Once the deployment is Ready, use the Server origin from Overview for APPROVAL_BASE_URL. Save the production variables and select Restart saved changes before starting a workflow in Studio. Deploy and verify an email decision

About Mastra templates

This template lives in the Mastra monorepo and shows how to add email review to a suspended workflow. Contributing