Better Auth RS

Users & Accounts

User entities, account linking, and management endpoints.

User Entity

The User struct represents a registered user:

FieldTypeDescription
idStringUUID primary key
nameOption<String>Display name
emailOption<String>Email address (unique)
emailVerifiedboolWhether email is verified
imageOption<String>Profile image URL
usernameOption<String>Unique username
displayUsernameOption<String>Case-preserved display name
roleOption<String>User role
bannedboolWhether user is banned
banReasonOption<String>Ban reason
banExpiresOption<DateTime>Ban expiration
twoFactorEnabledbool2FA status
metadataHashMapArbitrary key-value data
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update timestamp

Account Entity

Accounts represent authentication methods linked to a user (email/password, OAuth providers, etc.):

FieldTypeDescription
idStringUUID primary key
accountIdStringProvider-specific account ID
providerIdStringProvider name (e.g., "credential", "google")
userIdStringOwning user ID
passwordOption<String>Hashed password (for credential accounts)
accessTokenOption<String>OAuth access token
refreshTokenOption<String>OAuth refresh token

User Management Endpoints

These endpoints are built into the core and don't require a plugin.

Update User

POST /update-user
Authorization: Bearer <token>
Content-Type: application/json
{
  "name": "New Name",
  "image": "https://example.com/photo.jpg",
  "username": "newusername",
  "displayUsername": "NewUsername"
}

All fields are optional. Only provided fields are updated.

Delete User

POST /delete-user
Authorization: Bearer <token>

Deletes the authenticated user and all associated sessions and accounts.

Change Email

POST /change-email
Authorization: Bearer <token>
Content-Type: application/json
{
  "newEmail": "new@example.com"
}

AccountManagementPlugin

Provides endpoints for listing and unlinking accounts.

use better_auth::plugins::AccountManagementPlugin;

let auth = BetterAuth::new(config)
    .database(database)
    .plugin(AccountManagementPlugin::new())
    .build()
    .await?;

List Accounts

GET /list-accounts
Authorization: Bearer <token>
{
  "accounts": [
    {
      "id": "uuid",
      "accountId": "user@example.com",
      "providerId": "credential",
      "userId": "uuid",
      ...
    }
  ]
}
POST /unlink-account
Authorization: Bearer <token>
Content-Type: application/json
{
  "providerId": "google"
}

Removes the specified provider link. Fails if it's the user's only authentication method.

On this page