Docs

Users

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('')
        setKey('')
    ;
    
    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();

Get User

GET/users/{id}

Get user by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');

Get User Prefs

GET/users/{id}/prefs

Get user preferences by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');

Get User Sessions

GET/users/{id}/sessions

Get user sessions list by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');

Get User Logs

GET/users/{id}/logs

Get user activity logs list by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');

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('')
        setKey('')
    ;
    
    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');

Block User

PATCH/users/{id}/status

Update user status by its unique ID.

Arguments

Name Type Description
id 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('')
        setKey('')
    ;
    
    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');

Delete User Session

DELETE/users/{id}/sessions/{session}

Delete user sessions by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

session required string

User unique session ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');

Delete User Sessions

DELETE/users/{id}/sessions

Delete all user sessions by its unique ID.

Arguments

Name Type Description
id required string

User unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    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]');