Skip to main content
Module

x/appwrite/mod.ts>Account

[READ-ONLY] Official Appwrite Deno SDK 🦕
Go to Latest
class Account
extends Service
Re-export
import { Account } from "https://deno.land/x/appwrite@8.0.0/mod.ts";

Constructors

new
Account(client: Client)

Methods

Create Phone Verification

Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the accountUpdatePhone endpoint. Learn more about how to complete the verification process. The verification code sent to the user's phone number is valid for 15 minutes.

createRecovery(email: string, url: string): Promise<Models.Token>

Create Password Recovery

Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the PUT /account/recovery endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour.

createVerification(url: string): Promise<Models.Token>

Create Email Verification

Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the userId and secret arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the userId and secret parameters. Learn more about how to complete the verification process. The verification link sent to the user's email address is valid for 7 days.

Please note that in order to avoid a Redirect Attack, the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

deleteIdentity(identityId: string): Promise<Response>

Delete Identity

Delete an identity by its unique ID.

deleteSession(sessionId: string): Promise<Response>

Delete Session

Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use Delete Sessions instead.

Delete Sessions

Delete all sessions from the user account and remove any sessions cookies from the end client.

get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>>

Get Account

Get the currently logged in user.

getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences>

Get Account Preferences

Get the preferences as a key-value object for the currently logged in user.

getSession(sessionId: string): Promise<Models.Session>

Get Session

Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.

listIdentities(queries?: string): Promise<Models.IdentityList>

List Identities

Get the list of identities for the currently logged in user.

listLogs(queries?: string[]): Promise<Models.LogList>

List Logs

Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.

List Sessions

Get the list of active sessions across different devices for the currently logged in user.

updateEmail<Preferences extends Models.Preferences>(email: string, password: string): Promise<Models.User<Preferences>>

Update Email

Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.

updateName<Preferences extends Models.Preferences>(name: string): Promise<Models.User<Preferences>>

Update Name

Update currently logged in user account name.

updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>>

Update Password

Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.

updatePhone<Preferences extends Models.Preferences>(phone: string, password: string): Promise<Models.User<Preferences>>

Update Phone

Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the POST /account/verification/phone endpoint to send a confirmation SMS.

updatePhoneVerification(userId: string, secret: string): Promise<Models.Token>

Create Phone Verification (confirmation)

Use this endpoint to complete the user phone verification process. Use the userId and secret that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code.

updatePrefs<Preferences extends Models.Preferences>(prefs: object): Promise<Models.User<Preferences>>

Update Preferences

Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.

updateRecovery(
userId: string,
secret: string,
password: string,
passwordAgain: string,
): Promise<Models.Token>

Create Password Recovery (confirmation)

Use this endpoint to complete the user account password reset. Both the userId and secret arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the POST /account/recovery endpoint.

Please note that in order to avoid a Redirect Attack the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

updateSession(sessionId: string): Promise<Models.Session>

Update OAuth Session (Refresh Tokens)

Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token.

updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>>

Update Status

Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.

updateVerification(userId: string, secret: string): Promise<Models.Token>

Create Email Verification (confirmation)

Use this endpoint to complete the user email verification process. Use both the userId and secret parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.