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
search Search term to filter your list results. Max length: 256 chars.
limit Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset Offset value. The default value is 0. Use this param to manage pagination. learn more about pagination
cursor ID of the user used as the starting point for the query, excluding the user itself. Should be used for efficient pagination when working with large sets of data. learn more about pagination
cursorDirection Direction of the cursor, can be either 'before' or 'after'.
orderType Order result by ASC or DESC order.
Response
200
GET /users
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.list(
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Create User
Create a new user.
Request
userId requiredUser ID. Choose your own unique ID or pass the string "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. Must be at least 8 chars.
name User name. Max length: 128 chars.
Response
201
POST /users
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.create(
userId: '[USER_ID]',
email: 'email@example.com',
password: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
GET /users/{userId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.get(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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.
Request
userId requiredUser ID.
Response
204
DELETE /users/{userId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.delete(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updateEmail(
userId: '[USER_ID]',
email: 'email@example.com',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Get User Logs
Get the user activity logs list by its unique ID.
Request
userId requiredUser ID.
limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset Offset value. The default value is 0. Use this value to manage pagination. learn more about pagination
Response
200
GET /users/{userId}/logs
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.getLogs(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Get 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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.getMemberships(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updateName(
userId: '[USER_ID]',
name: '[NAME]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updatePassword(
userId: '[USER_ID]',
password: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updatePhone(
userId: '[USER_ID]',
number: '',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.getPrefs(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updatePrefs(
userId: '[USER_ID]',
prefs: {},
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Get 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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.getSessions(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.deleteSessions(
userId: '[USER_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.deleteSession(
userId: '[USER_ID]',
sessionId: '[SESSION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updateStatus(
userId: '[USER_ID]',
status: false,
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updateEmailVerification(
userId: '[USER_ID]',
emailVerification: false,
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
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';
void main() { // Init SDK
Client client = Client();
Users users = Users(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = users.updatePhoneVerification(
userId: '[USER_ID]',
phoneVerification: false,
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}