Skip to content

Data Model

These tables are created and managed by Better Auth. Do not modify their structure directly.

TablePurpose
userGlobal identity: id, email, name, image
sessionLogin sessions: token, userId, expiresAt
accountLinked provider accounts: google, apple, credential
verificationEmail verification, magic link tokens
jwksRSA key pairs for JWT signing
oauth_clientOAuth client registrations
oauth_access_tokenIssued access tokens
oauth_refresh_tokenIssued refresh tokens
oauth_consentUser consent records
organizationB2B organizations
memberOrganization members
invitationOrganization invitations
ColumnTypeDescription
idtext PKApplication identifier (e.g. tobby)
nametextDisplay name
oauth_client_idtext UNIQUEFK to oauth_client.id
audiencetextJWT audience claim value
webhook_urltext?Event webhook URL (Phase 3)
webhook_secrettext?Webhook signing secret
statustextactive or suspended
auth_policyjsonbPer-application account policy
created_attimestamptz
updated_attimestamptz
ColumnTypeDescription
idtext PK
app_idtext FKReferences application.id
user_idtext FKReferences user.id
statustextactive, suspended, disabled, pending_approval
roletextmember, admin, billing_admin
display_nametext?Per-application display name
avatar_urltext?
profilejsonbPer-application custom fields
invited_bytext?Inviting user id
first_seen_attimestamptz
last_active_attimestamptz?

Unique constraint: (app_id, user_id)

ColumnTypeDescription
idtext PK
app_idtext FK
emailtextInvited email address
invited_bytext
roletext?Default: member
tokentext UNIQUEInvitation token
expires_attimestamptz
statustextpending, accepted, expired, cancelled
messagetext?Optional invitation message
ColumnTypeDescription
idtext PK
app_idtext FK
nametextHuman-readable identifier
key_prefixtextFirst 8 characters of the plaintext key
key_hashtextSHA-256 hash of the key
scopestext[]Permission scopes
expires_attimestamptz?
last_used_attimestamptz?
created_attimestamptz
ColumnTypeDescription
idtext PKGroup identifier
nametextDisplay name
created_attimestamptz
ColumnTypeDescription
group_idtext FKReferences sso_group.id
app_idtext FKReferences application.id

Primary key: (group_id, app_id).

interface AuthPolicy {
allowed_providers: string[]; // "email", "google", "apple"
signup_policy: "open"
| "invite_only"
| "admin_approval"
| "auto_on_first_access";
password_policy: {
min_length: number;
require_uppercase: boolean;
require_symbol: boolean;
expiry_days: number | null;
};
session_policy: {
ttl_hours: number;
max_concurrent: number | null;
idle_timeout_minutes: number | null;
};
require_email_verification: boolean;
allowed_email_domains: string[];
blocked_email_domains: string[];
required_profile_fields: string[];
}