The Users service allows you to manage your project users. Use this service to search, block, and view your users' info, current sessions, and latest activity logs. You can also use the Users service to edit your users' preferences and personal info.
https://cloud.appwrite.io/v1
List users
Get a list of all the project's users. You can use the query params to filter your results.
Request
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /users
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
UserList result = await users.list(
queries: [], // (optional)
search: '<SEARCH>', // (optional)
);
Create user
Create a new user.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email User email.
phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
password Plain text user password. Must be at least 8 chars.
name User name. Max length: 128 chars.
Response
201
POST /users
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.create(
userId: '<USER_ID>',
email: 'email@example.com', // (optional)
phone: '+12065550100', // (optional)
password: '', // (optional)
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using Argon2.
name User name. Max length: 128 chars.
Response
201
POST /users/argon2
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createArgon2User(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using Bcrypt.
name User name. Max length: 128 chars.
Response
201
POST /users/bcrypt
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createBcryptUser(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
name: '<NAME>', // (optional)
);
List Identities
Get identities for all users.
Request
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /users/identities
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
IdentityList result = await users.listIdentities(
queries: [], // (optional)
search: '<SEARCH>', // (optional)
);
Delete identity
Delete an identity by its unique ID.
Request
identityId requiredIdentity ID.
Response
204
DELETE /users/identities/{identityId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.deleteIdentity(
identityId: '<IDENTITY_ID>',
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using MD5.
name User name. Max length: 128 chars.
Response
201
POST /users/md5
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createMD5User(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or pass the string
ID.unique()
to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using PHPass.
name User name. Max length: 128 chars.
Response
201
POST /users/phpass
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createPHPassUser(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using Scrypt.
passwordSalt requiredOptional salt used to hash password.
passwordCpu requiredOptional CPU cost used to hash password.
passwordMemory requiredOptional memory cost used to hash password.
passwordParallel requiredOptional parallelization cost used to hash password.
passwordLength requiredOptional hash length used to hash password.
name User name. Max length: 128 chars.
Response
201
POST /users/scrypt
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createScryptUser(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
passwordSalt: '<PASSWORD_SALT>',
passwordCpu: 0,
passwordMemory: 0,
passwordParallel: 0,
passwordLength: 0,
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using Scrypt Modified.
passwordSalt requiredSalt used to hash password.
passwordSaltSeparator requiredSalt separator used to hash password.
passwordSignerKey requiredSigner key used to hash password.
name User name. Max length: 128 chars.
Response
201
POST /users/scrypt-modified
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createScryptModifiedUser(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
passwordSalt: '<PASSWORD_SALT>',
passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>',
passwordSignerKey: '<PASSWORD_SIGNER_KEY>',
name: '<NAME>', // (optional)
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.email requiredUser email.
password requiredUser password hashed using SHA.
passwordVersion Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'
name User name. Max length: 128 chars.
Response
201
POST /users/sha
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.createSHAUser(
userId: '<USER_ID>',
email: 'email@example.com',
password: 'password',
passwordVersion: PasswordHash.sha1, // (optional)
name: '<NAME>', // (optional)
);
GET /users/{userId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.get(
userId: '<USER_ID>',
);
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.
Request
userId requiredUser ID.
Response
204
DELETE /users/{userId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.delete(
userId: '<USER_ID>',
);
Update email
Update the user email by its unique ID.
Request
userId requiredUser ID.
email requiredUser email.
Response
200
PATCH /users/{userId}/email
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateEmail(
userId: '<USER_ID>',
email: 'email@example.com',
);
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.
Request
userId requiredUser ID.
labels requiredArray of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long.
Response
200
PUT /users/{userId}/labels
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateLabels(
userId: '<USER_ID>',
labels: [],
);
List user logs
Get the user activity logs list by its unique ID.
Request
userId requiredUser ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Only supported methods are limit and offset
Response
200
GET /users/{userId}/logs
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
LogList result = await users.listLogs(
userId: '<USER_ID>',
queries: [], // (optional)
);
List user memberships
Get the user membership list by its unique ID.
Request
userId requiredUser ID.
Response
200
GET /users/{userId}/memberships
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
MembershipList result = await users.listMemberships(
userId: '<USER_ID>',
);
Update MFA
Enable or disable MFA on a user account.
Request
userId requiredUser ID.
mfa requiredEnable or disable MFA.
Response
200
PATCH /users/{userId}/mfa
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateMfa(
userId: '<USER_ID>',
mfa: false,
);
Delete Authenticator
Delete an authenticator app.
Request
userId requiredUser ID.
type requiredType of authenticator.
Response
200
DELETE /users/{userId}/mfa/authenticators/{type}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.deleteMfaAuthenticator(
userId: '<USER_ID>',
type: AuthenticatorType.totp,
);
List Factors
List the factors available on the account to be used as a MFA challange.
Request
userId requiredUser ID.
Response
200
GET /users/{userId}/mfa/factors
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
MfaFactors result = await users.listMfaFactors(
userId: '<USER_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.
Request
userId requiredUser ID.
Response
GET /users/{userId}/mfa/recovery-codes
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
MfaRecoveryCodes result = await users.getMfaRecoveryCodes(
userId: '<USER_ID>',
);
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.
Request
userId requiredUser ID.
Response
PUT /users/{userId}/mfa/recovery-codes
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
MfaRecoveryCodes result = await users.updateMfaRecoveryCodes(
userId: '<USER_ID>',
);
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.
Request
userId requiredUser ID.
Response
PATCH /users/{userId}/mfa/recovery-codes
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
MfaRecoveryCodes result = await users.createMfaRecoveryCodes(
userId: '<USER_ID>',
);
Update name
Update the user name by its unique ID.
Request
userId requiredUser ID.
name requiredUser name. Max length: 128 chars.
Response
200
PATCH /users/{userId}/name
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateName(
userId: '<USER_ID>',
name: '<NAME>',
);
Update password
Update the user password by its unique ID.
Request
userId requiredUser ID.
password requiredNew user password. Must be at least 8 chars.
Response
200
PATCH /users/{userId}/password
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updatePassword(
userId: '<USER_ID>',
password: '',
);
Update phone
Update the user phone by its unique ID.
Request
userId requiredUser ID.
number requiredUser phone number.
Response
200
PATCH /users/{userId}/phone
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updatePhone(
userId: '<USER_ID>',
number: '+12065550100',
);
Get user preferences
Get the user preferences by its unique ID.
Request
userId requiredUser ID.
Response
200
GET /users/{userId}/prefs
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Preferences result = await users.getPrefs(
userId: '<USER_ID>',
);
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.
Request
userId requiredUser ID.
prefs requiredPrefs key-value JSON object.
Response
200
PATCH /users/{userId}/prefs
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Preferences result = await users.updatePrefs(
userId: '<USER_ID>',
prefs: {},
);
List user sessions
Get the user sessions list by its unique ID.
Request
userId requiredUser ID.
Response
200
GET /users/{userId}/sessions
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
SessionList result = await users.listSessions(
userId: '<USER_ID>',
);
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.
Request
userId requiredUser ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
Response
201
POST /users/{userId}/sessions
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Session result = await users.createSession(
userId: '<USER_ID>',
);
Delete user sessions
Delete all user's sessions by using the user's unique ID.
Request
userId requiredUser ID.
Response
204
DELETE /users/{userId}/sessions
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.deleteSessions(
userId: '<USER_ID>',
);
Delete user session
Delete a user sessions by its unique ID.
Request
userId requiredUser ID.
sessionId requiredSession ID.
Response
204
DELETE /users/{userId}/sessions/{sessionId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.deleteSession(
userId: '<USER_ID>',
sessionId: '<SESSION_ID>',
);
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.
Request
userId requiredUser ID.
status requiredUser Status. To activate the user pass
true
and to block the user passfalse
.
Response
200
PATCH /users/{userId}/status
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateStatus(
userId: '<USER_ID>',
status: false,
);
List User Targets
List the messaging targets that are associated with a user.
Request
userId requiredUser ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels
Response
200
GET /users/{userId}/targets
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
TargetList result = await users.listTargets(
userId: '<USER_ID>',
queries: [], // (optional)
);
Create User Target
Create a messaging target.
Request
userId requiredUser ID.
targetId requiredTarget ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.providerType requiredThe target provider type. Can be one of the following:
email
,sms
orpush
.identifier requiredThe target identifier (token, email, phone etc.)
providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.
name Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.
Response
201
POST /users/{userId}/targets
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Target result = await users.createTarget(
userId: '<USER_ID>',
targetId: '<TARGET_ID>',
providerType: MessagingProviderType.email,
identifier: '<IDENTIFIER>',
providerId: '<PROVIDER_ID>', // (optional)
name: '<NAME>', // (optional)
);
Get User Target
Get a user's push notification target by ID.
Request
userId requiredUser ID.
targetId requiredTarget ID.
Response
200
GET /users/{userId}/targets/{targetId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Target result = await users.getTarget(
userId: '<USER_ID>',
targetId: '<TARGET_ID>',
);
Update User target
Update a messaging target.
Request
userId requiredUser ID.
targetId requiredTarget ID.
identifier The target identifier (token, email, phone etc.)
providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.
name Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.
Response
200
PATCH /users/{userId}/targets/{targetId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Target result = await users.updateTarget(
userId: '<USER_ID>',
targetId: '<TARGET_ID>',
identifier: '<IDENTIFIER>', // (optional)
providerId: '<PROVIDER_ID>', // (optional)
name: '<NAME>', // (optional)
);
Delete user target
Delete a messaging target.
Request
userId requiredUser ID.
targetId requiredTarget ID.
Response
204
DELETE /users/{userId}/targets/{targetId}
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
await users.deleteTarget(
userId: '<USER_ID>',
targetId: '<TARGET_ID>',
);
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.
Request
userId requiredUser ID.
length Token length in characters. The default length is 6 characters
expire Token expiration period in seconds. The default expiration is 15 minutes.
Response
201
POST /users/{userId}/tokens
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
Token result = await users.createToken(
userId: '<USER_ID>',
length: 4, // (optional)
expire: 60, // (optional)
);
Update email verification
Update the user email verification status by its unique ID.
Request
userId requiredUser ID.
emailVerification requiredUser email verification status.
Response
200
PATCH /users/{userId}/verification
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updateEmailVerification(
userId: '<USER_ID>',
emailVerification: false,
);
Update phone verification
Update the user phone verification status by its unique ID.
Request
userId requiredUser ID.
phoneVerification requiredUser phone verification status.
Response
200
PATCH /users/{userId}/verification/phone
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Users users = Users(client);
User result = await users.updatePhoneVerification(
userId: '<USER_ID>',
phoneVerification: false,
);