← All use cases

SaaS Invitation Flows

Verify team invitation emails and magic links

Test invitation-based flows in your SaaS app end to end: team member invitations, magic link sign-in, shared links, and more. Write tests that check the invitation arrives, its link opens, and the invited user gets the right permissions.

What you can do with MailBrew

  1. 01

    Test the whole invitation flow

    Cover sending the invite, receiving it, opening the link, and creating the account in a single test.

  2. 02

    Magic link checks

    Extract the link with the link extraction API, then check against your app that it works only once and stops working after it expires.

  3. 03

    Permission testing

    Check that invited users get the right permissions in your app (admin/member/viewer, for example).

  4. 04

    Parallel invitation tests

    Each test uses its own address, so multiple invitation scenarios can run at the same time without their emails mixing.

Sample code

cURL

cURL
# cURL + MailBrew: SaaS invitation flow test
ADDRESS=$(curl -sS -X POST https://mailbrew.dev/api/mailbrew/addresses \
  -H "X-API-Key: $MAILBREW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ttl": 600}' | jq -r '.data.address')

curl -X POST https://staging.example.com/api/team/invite \
  -H "Content-Type: application/json" \
  -d "{\"email\": \"$ADDRESS\", \"role\": \"member\"}"

# Wait for the email (timeout in seconds, max 60)
EMAIL_ID=$(curl -sS "https://mailbrew.dev/api/mailbrew/addresses/$ADDRESS/emails/wait?timeout=30" \
  -H "X-API-Key: $MAILBREW_API_KEY" | jq -r '.data[0].id')

# Extract the invitation link
curl -sS "https://mailbrew.dev/api/mailbrew/addresses/$ADDRESS/emails/$EMAIL_ID/links?pattern=invitations" \
  -H "X-API-Key: $MAILBREW_API_KEY" | jq -r '.data.links[0]'

Ready to try this use case?

Get started with the free plan today. No credit card required.
Free plan: up to 100 emails/month and 5 addresses

Create free account →