Docs

Users

The users' service allows you to to manage your users in admin mode, you can search, block and view your users' current sessions and latest activity.

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 Users.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 Users.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 Users.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 Users.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 Users.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 Users.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 blocking 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 Users.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);
    });

Delete User Session

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

Delete user sessions by its unique ID.

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.deleteUsersSession('[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->deleteUsersSession('[USER_ID]', '[SESSION_ID]');
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Users.Client();
    
    let users = new sdk.Users(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = users.deleteUsersSession('[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.

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 Users.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);
    });