Appwrite. Services. Accounts
(appwrite v1.0.0)
View Source
The Account service allows you to authenticate and manage a user account.
You can use the account service to update user information, retrieve sessions across devices, and fetch security logs. Authentication is supported via email/password, magic URLs, OAuth2, phone OTP, and anonymous sessions.
Summary
Functions
Create a new account.
Create an anonymous session.
Create a session using email and password.
Create an email token for passwordless / magic-link authentication.
Create a JWT for the current user.
Create a magic URL token for passwordless authentication.
Create a new MFA authenticator of the given type (e.g. "totp").
Create an MFA challenge for a given factor.
Generate new MFA recovery codes.
Build the OAuth2 authorization URL for the given provider.
Build the OAuth2 token URL (redirects user to provider, then creates a session token).
Create a phone token for SMS-based OTP authentication.
Send a phone verification SMS to the current user's registered phone number.
Register a push notification target (device token).
Send a password recovery email.
Create a session from a short-lived token (userId + secret).
Send an email verification link to the current user.
Delete an identity by its unique ID.
Delete an MFA authenticator.
Delete a push notification target.
Delete a session by ID. Use "current" to log out of the active session.
Delete all active sessions (log out from all devices).
Get the currently logged-in user.
Get the MFA recovery codes for the current account.
Get the current user's preferences object.
Get a session by ID. Use "current" for the active session.
List identities for the currently logged-in user.
List activity logs for the currently logged-in user.
List all available MFA factors on the current account.
List all active sessions for the current user.
Update the currently logged-in user's email address.
Complete a magic-URL session (supply userId + secret from the email link).
Enable or disable MFA on the current account.
Verify and activate an MFA authenticator by providing its one-time password.
Complete an MFA challenge by providing the one-time password.
Regenerate MFA recovery codes (requires a completed OTP challenge).
Update the current user's display name.
Update the current user's password. old_password is required unless the account has no password.
Update the current user's phone number. Requires current password.
Complete a phone OTP session (supply userId + secret from the SMS).
Confirm phone verification using the userId and secret from the verification SMS.
Replace the current user's preferences object.
Update a push notification target's device token.
Complete the password reset flow.
Extend or update an existing session.
Block the current account (sets status to false).
Confirm email verification using the userId and secret from the verification link.
Functions
@spec create(String.t() | nil, String.t(), String.t(), String.t() | nil) :: {:ok, map()} | {:error, any()}
Create a new account.
Parameters
user_id— unique ID; auto-generated whennilemail(required)password(required)name(optional)
Create an anonymous session.
Create a session using email and password.
Create an email token for passwordless / magic-link authentication.
Create a JWT for the current user.
Parameters
duration(optional) — seconds before expiry; default 900, max 3600
@spec create_magic_url_token( String.t(), String.t(), String.t() | nil, boolean() | nil ) :: {:ok, map()} | {:error, any()}
Create a magic URL token for passwordless authentication.
Create a new MFA authenticator of the given type (e.g. "totp").
Create an MFA challenge for a given factor.
factor must be a valid Appwrite.Consts.AuthenticationFactor value.
Generate new MFA recovery codes.
@spec create_oauth2_session( String.t(), String.t() | nil, String.t() | nil, [String.t()] | nil ) :: {:ok, String.t()} | {:error, any()}
Build the OAuth2 authorization URL for the given provider.
Returns the URL as a string — the caller should redirect the user to it.
@spec create_oauth2_token( String.t(), String.t() | nil, String.t() | nil, [String.t()] | nil ) :: {:ok, String.t()} | {:error, any()}
Build the OAuth2 token URL (redirects user to provider, then creates a session token).
Create a phone token for SMS-based OTP authentication.
Send a phone verification SMS to the current user's registered phone number.
@spec create_push_target(String.t(), String.t(), String.t() | nil) :: {:ok, map()} | {:error, any()}
Register a push notification target (device token).
Send a password recovery email.
Parameters
email(required) — the user's email addressurl(required) — redirect URL embedded in the recovery email
Create a session from a short-lived token (userId + secret).
Send an email verification link to the current user.
Delete an identity by its unique ID.
Delete an MFA authenticator.
Delete a push notification target.
Delete a session by ID. Use "current" to log out of the active session.
Delete all active sessions (log out from all devices).
Get the currently logged-in user.
Get the MFA recovery codes for the current account.
Get the current user's preferences object.
Get a session by ID. Use "current" for the active session.
List identities for the currently logged-in user.
Parameters
queries(optional)total(optional) — whenfalse, skips total count calculation
List activity logs for the currently logged-in user.
Parameters
queries(optional)total(optional) — whenfalse, skips total count calculation
List all available MFA factors on the current account.
List all active sessions for the current user.
Update the currently logged-in user's email address.
Requires the current password for confirmation.
Complete a magic-URL session (supply userId + secret from the email link).
Enable or disable MFA on the current account.
Verify and activate an MFA authenticator by providing its one-time password.
@spec update_mfa_challenge(String.t(), String.t()) :: {:ok, Appwrite.Types.Session.t()} | {:error, any()}
Complete an MFA challenge by providing the one-time password.
Returns the created Session on success.
Regenerate MFA recovery codes (requires a completed OTP challenge).
Update the current user's display name.
Update the current user's password. old_password is required unless the account has no password.
Update the current user's phone number. Requires current password.
Complete a phone OTP session (supply userId + secret from the SMS).
Confirm phone verification using the userId and secret from the verification SMS.
Replace the current user's preferences object.
Update a push notification target's device token.
@spec update_recovery(String.t(), String.t(), String.t()) :: {:ok, Appwrite.Types.Token.t()} | {:error, any()}
Complete the password reset flow.
Call this with the userId and secret query parameters from the recovery
email link, plus the user's chosen new password.
Parameters
user_id(required)secret(required) — the reset token from the email linkpassword(required) — the new password (8–256 chars)
Extend or update an existing session.
Block the current account (sets status to false).
Confirm email verification using the userId and secret from the verification link.