Docs

Users

The users' service allows you to manage your users in admin mode (AKA server-side integration). Use this service to search, block, and view your Users info, current sessions, and latest activities. You can also use the Users service to edit your users' preferences and personal info.

List Users

GET/users

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

Arguments

Name Type Description
search optional string

Search term to filter your list results.

limit optional integer

Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.

offset optional integer

Results offset. The default value is 0. Use this param to manage pagination.

orderType optional string

Order result by ASC or DESC order.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.listUsers();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->listUsers();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.listUsers();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Get User

GET/users/{userId}

Get user by its unique ID.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.getUser('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->getUser('[USER_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.getUser('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Get User Prefs

GET/users/{userId}/prefs

Get user preferences by its unique ID.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.getUserPrefs('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->getUserPrefs('[USER_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.getUserPrefs('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Get User Sessions

GET/users/{userId}/sessions

Get user sessions list by its unique ID.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.getUserSessions('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->getUserSessions('[USER_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.getUserSessions('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Get User Logs

GET/users/{userId}/logs

Get user activity logs list by its unique ID.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.getUserLogs('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->getUserLogs('[USER_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.getUserLogs('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Create User

POST/users

Create a new user.

Arguments

Name Type Description
email required string

User account email.

password required string

User account password.

name optional string

User account name.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.createUser('email@example.com', 'password');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->createUser('email@example.com', 'password');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.createUser('email@example.com', 'password');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Update User Status

PATCH/users/{userId}/status

Update user status by its unique ID.

Arguments

Name Type Description
userId required string

User unique ID.

status required string

User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.updateUserStatus('[USER_ID]', '1');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->updateUserStatus('[USER_ID]', '1');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.updateUserStatus('[USER_ID]', '1');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Update User Prefs

PATCH/users/{userId}/prefs

Update user preferences by its unique ID. You can pass only the specific settings you wish to update.

Arguments

Name Type Description
userId required string

User unique ID.

prefs required string

Prefs key-value JSON object string.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.updateUserPrefs('[USER_ID]', '{}');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->updateUserPrefs('[USER_ID]', '{}');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.updateUserPrefs('[USER_ID]', '{}');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Delete User Session

DELETE/users/{userId}/sessions/:session

Delete user sessions by its unique ID.

Rate Limits

This endpoint is limited to 100 requests in every 60 minutes. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

Arguments

Name Type Description
userId required string

User unique ID.

sessionId required string

User unique session ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.deleteUserSession('[USER_ID]', '[SESSION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->deleteUserSession('[USER_ID]', '[SESSION_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.deleteUserSession('[USER_ID]', '[SESSION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Delete User Sessions

DELETE/users/{userId}/sessions

Delete all user sessions by its unique ID.

Rate Limits

This endpoint is limited to 100 requests in every 60 minutes. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('')
    ;
    
    let promise = sdk.users.deleteUserSessions('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Users;
    
    $client = new Client();
    
    $client
        ->setProject('')
        ->setKey('')
    ;
    
    $users = new Users($client);
    
    $result = $users->deleteUserSessions('[USER_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('')
        .setKey('')
    ;
    
    let promise = users.deleteUserSessions('[USER_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });