Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/appwrite/mod.ts>Users

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

Constructors

new
Users(client: Client)

Methods

create<Preferences extends Models.Preferences>(
userId: string,
email?: string,
phone?: string,
password?: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user

Create a new user.

createArgon2User<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user with Argon2 password

Create a new user. Password provided must be hashed with the Argon2 algorithm. Use the POST /users endpoint to create users with a plain text password.

createBcryptUser<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user with bcrypt password

Create a new user. Password provided must be hashed with the Bcrypt algorithm. Use the POST /users endpoint to create users with a plain text password.

createMD5User<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user with MD5 password

Create a new user. Password provided must be hashed with the MD5 algorithm. Use the POST /users endpoint to create users with a plain text password.

Create MFA Recovery Codes

Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in createMfaChallenge method by client SDK.

createPHPassUser<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user with PHPass password

Create a new user. Password provided must be hashed with the PHPass algorithm. Use the POST /users endpoint to create users with a plain text password.

createScryptModifiedUser<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
passwordSalt: string,
passwordSaltSeparator: string,
passwordSignerKey: string,
name?: string,
): Promise<Models.User<Preferences>>

Create user with Scrypt modified password

Create a new user. Password provided must be hashed with the Scrypt Modified algorithm. Use the POST /users endpoint to create users with a plain text password.

createScryptUser<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
passwordSalt: string,
passwordCpu: number,
passwordMemory: number,
passwordParallel: number,
passwordLength: number,
name?: string,
): Promise<Models.User<Preferences>>

Create user with Scrypt password

Create a new user. Password provided must be hashed with the Scrypt algorithm. Use the POST /users endpoint to create users with a plain text password.

createSession(userId: string): Promise<Models.Session>

Create session

Creates a session for a user. Returns an immediately usable session object.

If you want to generate a token for a custom authentication flow, use the POST /users/{userId}/tokens endpoint.

createSHAUser<Preferences extends Models.Preferences>(
userId: string,
email: string,
password: string,
passwordVersion?: PasswordHash,
name?: string,
): Promise<Models.User<Preferences>>

Create user with SHA password

Create a new user. Password provided must be hashed with the SHA algorithm. Use the POST /users endpoint to create users with a plain text password.

createTarget(
userId: string,
targetId: string,
providerType: MessagingProviderType,
identifier: string,
providerId?: string,
name?: string,
): Promise<Models.Target>

Create User Target

Create a messaging target.

createToken(
userId: string,
length?: number,
expire?: number,
): Promise<Models.Token>

Create token

Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the PUT /account/sessions/token endpoint to complete the login process.

delete(userId: string): Promise<Response>

Delete user

Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the updateStatus endpoint instead.

deleteIdentity(identityId: string): Promise<Response>

Delete identity

Delete an identity by its unique ID.

deleteMfaAuthenticator<Preferences extends Models.Preferences>(userId: string, type: AuthenticatorType): Promise<Models.User<Preferences>>

Delete Authenticator

Delete an authenticator app.

deleteSession(userId: string, sessionId: string): Promise<Response>

Delete user session

Delete a user sessions by its unique ID.

deleteSessions(userId: string): Promise<Response>

Delete user sessions

Delete all user's sessions by using the user's unique ID.

deleteTarget(userId: string, targetId: string): Promise<Response>

Delete user target

Delete a messaging target.

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

Get user

Get a user by its unique ID.

Get MFA Recovery Codes

Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using createMfaRecoveryCodes method.

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

Get user preferences

Get the user preferences by its unique ID.

getTarget(userId: string, targetId: string): Promise<Models.Target>

Get User Target

Get a user's push notification target by ID.

list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>>

List users

Get a list of all the project's users. You can use the query params to filter your results.

listIdentities(queries?: string[], search?: string): Promise<Models.IdentityList>

List Identities

Get identities for all users.

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

List user logs

Get the user activity logs list by its unique ID.

listMemberships(userId: string): Promise<Models.MembershipList>

List user memberships

Get the user membership list by its unique ID.

listMfaFactors(userId: string): Promise<Models.MfaFactors>

List Factors

List the factors available on the account to be used as a MFA challange.

listSessions(userId: string): Promise<Models.SessionList>

List user sessions

Get the user sessions list by its unique ID.

listTargets(userId: string, queries?: string[]): Promise<Models.TargetList>

List User Targets

List the messaging targets that are associated with a user.

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

Update email

Update the user email by its unique ID.

updateEmailVerification<Preferences extends Models.Preferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>>

Update email verification

Update the user email verification status by its unique ID.

updateLabels<Preferences extends Models.Preferences>(userId: string, labels: string[]): Promise<Models.User<Preferences>>

Update user labels

Update the user labels by its unique ID.

Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the Permissions docs for more info.

updateMfa<Preferences extends Models.Preferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>>

Update MFA

Enable or disable MFA on a user account.

Regenerate MFA Recovery Codes

Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using createMfaRecoveryCodes method.

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

Update name

Update the user name by its unique ID.

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

Update password

Update the user password by its unique ID.

updatePhone<Preferences extends Models.Preferences>(userId: string, number: string): Promise<Models.User<Preferences>>

Update phone

Update the user phone by its unique ID.

updatePhoneVerification<Preferences extends Models.Preferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>>

Update phone verification

Update the user phone verification status by its unique ID.

updatePrefs<Preferences extends Models.Preferences>(userId: string, prefs: object): Promise<Preferences>

Update user preferences

Update the user preferences by its unique ID. 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.

updateStatus<Preferences extends Models.Preferences>(userId: string, status: boolean): Promise<Models.User<Preferences>>

Update user status

Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved.

updateTarget(
userId: string,
targetId: string,
identifier?: string,
providerId?: string,
name?: string,
): Promise<Models.Target>

Update User target

Update a messaging target.