# Supabase + Brew

Trigger Brew automations from Supabase auth.users database webhooks, including derived events for email confirmation, password change, anonymous-to-real upgrade, and ban or unban.

Canonical: https://brew.new/browse/integrations/supabase

- Direction: Data in
- Connection: Webhook secret
- Auth event triggers

## Live capabilities

- **Event triggers**: Trigger Brew automations from Supabase auth.users database webhooks, including derived events for email confirmation, password change, and sign-in.

## Turn auth events into useful emails

Connect Supabase to start branded emails when someone signs up, confirms their email, changes their password, or is banned. A setup script adds a trigger to your auth.users table, and Brew turns each change into one of 12 automation triggers.

Supabase Auth remains responsible for sign-in, confirmation links, magic links, and password resets. Brew creates and sends the emails that follow those changes.


## What you can build

- Welcome emails: start from auth.user.email_confirmed so the first email reaches only verified addresses. Brew derives that event only from an update that sets email_confirmed_at, so a user whose row is created already confirmed produces auth.user.created alone. Check which case applies to your project, then choose one trigger to avoid duplicate welcomes.
- Guest-to-account welcomes: auth.user.upgraded_from_anonymous fires when is_anonymous changes from true to false, which is when an anonymous user becomes a permanent account.
- Password-change notices: auth.user.password_changed fires on any change to encrypted_password. The payload carries no password data. Link to your own account-recovery page in case the user did not make the change.
- Email-change notices: auth.user.email_changed carries the old address in previousValue and the new address in newValue. Brew sends to the new address.
- Invite follow-ups: auth.user.invited fires when an update sets invited_at. Supabase Auth sends the invitation link itself, and a Brew email can add onboarding context. Send a real test invite from your project before relying on this trigger.
- Suspension notices: auth.user.banned fires when banned_until is set and carries its value in newValue. auth.user.unbanned fires when banned_until is cleared. A ban unsubscribes the contact, and an unban does not resubscribe it.
- Deletion confirmations: auth.user.deleted fires when the row is deleted and still includes the email address from that row. It also unsubscribes the contact.

## Sign-in events are not return visits

auth.user.signed_in fires when last_sign_in_at changes. Supabase token refreshes also change that column, so the event can fire repeatedly while a user stays signed in. It does not show that someone came back after a long absence.

It is also the lowest-priority derived event. When the same update confirms an email or upgrades an anonymous user, Brew emits that event instead of auth.user.signed_in.

For a check-in with inactive users, decide inactivity in your application from its own activity data. Fire a separate Brew custom event only for users who qualify, and let a Live automation send the check-in from that event.

Test both paths: an inactive user receives the check-in; a user who was active before the check does not.


## Set up Supabase in Brew

- Open Integrations, choose Supabase, and select Connect Supabase. Brew pre-fills your webhook URL in the setup SQL.
- Create a signing secret with openssl rand -hex 32. Brew and Supabase do not issue it, and Brew requires at least 16 characters.
- In Supabase, open SQL Editor and paste the setup SQL. Replace the secret placeholder with your secret, then run it. The SQL enables pgcrypto and pg_net, stores the secret in Supabase Vault, and adds a trigger to auth.users for inserts, updates, and deletes.
- Paste the same secret into Brew and select Save and connect. Connecting creates triggers for all 12 events. There is no event enable/disable switch.
- After connecting, create a test user in Supabase under Authentication > Users. Brew changes from "Waiting for the first event" to "Connected", and Recent events shows the delivery with "signature ok".
- Create an automation, select its Supabase event, and send a test while it is still a Draft. Only Live automations execute when a matching event arrives.
- You need permission to run SQL against the auth schema, install extensions, and write to Supabase Vault. Re-running the SQL after rotating the secret is safe.

## Supported Supabase events

auth.user.created, auth.user.updated, and auth.user.deleted come from inserts, updates, and deletes on auth.users. Brew derives the other events from an update by comparing the old and new row.

One update produces one event. When several columns change together, the first match wins in this order: email_confirmed, phone_confirmed, upgraded_from_anonymous, email_changed, password_changed, banned, unbanned, invited, signed_in. An update that matches none of these arrives as auth.user.updated.

Brew supports these 12 event types:

- auth.user.created
- auth.user.updated
- auth.user.deleted
- auth.user.email_confirmed
- auth.user.phone_confirmed
- auth.user.email_changed
- auth.user.password_changed
- auth.user.signed_in
- auth.user.banned
- auth.user.unbanned
- auth.user.invited
- auth.user.upgraded_from_anonymous

## Contact sync and personalization

Each verified event with a real email address creates or updates a Brew contact, matched by email, whether or not an automation uses the event. When the data is present, Brew sets first and last name, supabase_user_id, supabase_created_at, supabase_phone, supabase_role, supabase_full_name, supabase_avatar_url, and supabase_auth_provider. Scalar values in raw_user_meta_data land as supabase_metadata_<key>.

Every event carries the whole auth.users row, so each one also refreshes supabase_account_status, supabase_email_verified, supabase_email_verified_at, supabase_phone_verified_at, and supabase_last_sign_in_at. supabase_account_status is active, invited until an invited user confirms their email, banned while banned_until is in the future, or deleted.

A ban or a deletion unsubscribes an existing contact unless it holds a different supabase_user_id, and never creates a contact. An unban sets the status back to active but does not resubscribe the contact.

Use the selected event's declared payload schema for merge tags. Every event includes email and, when present, firstName, lastName, fullName, displayName, avatarUrl, phone, role, provider, createdAt, lastSignInAt, and emailConfirmedAt. Names and avatars come from raw_user_meta_data, with fallbacks for OAuth sign-ups. The three timestamps are Unix seconds.

Derived events add previousValue, newValue, or both, holding the old and new column value as text. auth.user.password_changed has neither. provider holds the sign-up method, such as email, google, or github, so you can route welcome flows by how someone signed up.

The Supabase user ID is not a merge tag. Brew stores it on the contact as supabase_user_id for filtering and segmentation.

A Supabase account does not establish consent for marketing email. Record consent at sign-up and check it before promotional sends.


## Does Brew replace Supabase's auth emails?

No. Supabase Auth still sends confirmation links, magic links, invitations, and password resets through its own email setup, such as custom SMTP. Brew starts automations after those changes reach auth.users. Supabase recommends separate sending domains for auth and marketing email.


## Why does an event appear without sending an email?

Receiving an event and sending an email are separate steps. Confirm a matching automation is Live, then check its filters, execution history, recipient eligibility, and sending domain. An event for a user with no email address, such as an anonymous user who has not added one, creates no contact and starts no automation.


## Limits and troubleshooting

- Brew reads only auth.users. For events from other tables, create a custom trigger in Brew and fire it through the Brew API from your application or a Supabase Edge Function.
- Brew cannot create, ban, or delete Supabase users, and it does not send Supabase Auth emails.
- If deliveries fail signature checks, the secret in Supabase Vault does not match the one in Brew. Generate a new secret, re-run the setup SQL with it, and reconnect Supabase in Brew with the same value.
- If no deliveries arrive, re-run the setup SQL, then confirm that pgcrypto is installed and the Vault secret matches the one in Brew.
- After auth.user.email_changed, Brew creates or updates the contact at the new address. The contact at the old address is left unchanged.
- auth.user.deleted sets supabase_account_status to deleted and unsubscribes the contact. It does not remove the contact from Brew.
- Review consent and the purpose of each email. Syncing Supabase users does not authorize promotional sends.

## Sources and setup guides

- [Compare email tools for Supabase](/blog/best-email-tools-for-supabase-auth-emails-product-events-and-lifecycle-campaigns)
- [Supabase setup guide](https://docs.brew.new/integrations/import/supabase)
- [Build an automation](https://docs.brew.new/create-emails/build-an-automation)
- [Merge tags](https://docs.brew.new/create-emails/merge-tags)
- [What you can send with Brew](https://docs.brew.new/get-started/what-you-can-send)
- [Supabase database webhooks](https://supabase.com/docs/guides/database/webhooks)
- [Supabase user fields](https://supabase.com/docs/guides/auth/users)
- [Supabase custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp)

## Related

- [All integrations](https://brew.new/browse/integrations.md)
- [Sign up](https://brew.new/sign-up.md)
- Website: https://brew.new
