Platform
Phone and anonymous sign-in
Tested with:supabase-js 2 · @supabase/auth-js 2.117
Anonymous users
Section titled “Anonymous users”Turn on Anonymous sign-ins in Platform services → Auth → Providers. Then supabase.auth.signInAnonymously() creates a
user with no email or phone; its access token carries is_anonymous: true and the authenticated role, so your
policies can treat it differently:
create policy "permanent users only" on orders as restrictive for insert to authenticated with check ((auth.jwt() ->> 'is_anonymous')::boolean is not true);An anonymous user becomes a permanent user, keeping its id and data, when it:
- adds an email (
updateUser({ email }), then the confirmation link or code), - adds a phone (
updateUser({ phone }), thenverifyOtp({ phone, token, type: "phone_change" })), or - links a social provider (
linkIdentity).
A password can be set only after the email or phone is verified. Limits: sign-ins per client IP per hour
(per_ip_per_hour, 30 by default), CAPTCHA when the project has it (require_captcha refuses anonymous sign-ins
while CAPTCHA is off), and anonymous users count as monthly active users like any other; when a project with a hard
MAU cap reaches 90% of it, new anonymous users are refused first.
Phone sign-in
Section titled “Phone sign-in”await supabase.auth.signInWithOtp({ phone: "+14155550100" });await supabase.auth.verifyOtp({ phone: "+14155550100", token: code, type: "sms" });Phone + password works too (signUp({ phone, password }), confirmed by SMS unless autoconfirm is on).
Your SMS provider
Section titled “Your SMS provider”Codes go out from your account; Databasezy never sends or bills SMS. Pick the provider and paste its credential (write-only, stored in your project’s region):
sms_provider | Settings | Credential |
|---|---|---|
twilio | twilio_account_sid, twilio_message_service_sid (a Messaging Service SID or a sender number); optional twilio_api_base | auth token |
twilio + twilio_api_base | a Twilio-compatible service such as SignalWire: https://<space>.signalwire.com/api/laml (https on a public host) | that service’s token |
messagebird | messagebird_originator | access key |
vonage | vonage_api_key, vonage_from | API secret |
textlocal | textlocal_sender | API key |
zb api PUT /v1/orgs/{org}/projects/<project-id>/auth/providers/phone -d '{ "enabled": true, "secret": "<twilio auth token>", "phone": { "sms_provider": "twilio", "twilio_account_sid": "AC...", "twilio_message_service_sid": "MG...", "allowed_countries": ["1", "44"] }}'Twilio can also deliver over WhatsApp (channel: "whatsapp"). Instead of a provider you can deliver codes yourself with
a send_sms auth hook: a Postgres function or an HTTPS endpoint receives
{"user": {..., "phone": "14155550100"}, "sms": {"otp": "123456"}}. Hooks and providers also deliver
MFA phone codes.
Test numbers
Section titled “Test numbers”test_otp maps up to 20 numbers to fixed codes ({"15555550100": "246810"}): no SMS is sent to them, which is what
you want for app-store reviews and end-to-end tests. Without a provider or a hook, only test numbers can sign in.
SMS pumping protection
Section titled “SMS pumping protection”| Setting | Default |
|---|---|
allowed_countries (calling-code prefixes) | every country |
max_frequency between two codes to a number | 60 s |
max_per_number_per_hour | 5 |
max_per_ip_per_hour | 10 |
max_numbers_per_ip_per_hour (distinct numbers) | 5 |
max_per_hour / max_per_day (project) | 100 / 1000 |
Codes are otp_length digits (6), expire after otp_expiry (60 s) and are single use. A blocked country and a
breached cap are security events in your audit log.