Version 0.6.1  
Docs

Users API

Server integration with     code examples.


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.

Create User

POST/users

Create a new user.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.write" permission scope.

Arguments

Name Type Description
email required string

User email.

password required string

User password.

name optional string

User name.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.create('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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->create('email@example.com', 'password');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.create('email@example.com', 'password')
    

List Users

GET/users

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

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.read" permission scope.

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
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.list();
    
    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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->list();
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.list()
    

Get User

GET/users/{userId}

Get user by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.read" permission scope.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.get('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->get('[USER_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.get('[USER_ID]')
    

Get User Preferences

GET/users/{userId}/prefs

Get user preferences by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.read" permission scope.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.getPrefs('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->getPrefs('[USER_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.get_prefs('[USER_ID]')
    

Get User Sessions

GET/users/{userId}/sessions

Get user sessions list by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.read" permission scope.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.getSessions('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->getSessions('[USER_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.get_sessions('[USER_ID]')
    

Get User Logs

GET/users/{userId}/logs

Get user activity logs list by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.read" permission scope.

Arguments

Name Type Description
userId required string

User unique ID.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.getLogs('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->getLogs('[USER_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.get_logs('[USER_ID]')
    

Update User Status

PATCH/users/{userId}/status

Update user status by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.write" permission scope.

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
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.updateStatus('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->updateStatus('[USER_ID]', '1');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.update_status('[USER_ID]', '1')
    

Update User Preferences

PATCH/users/{userId}/prefs

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

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.write" permission scope.

Arguments

Name Type Description
userId required string

User unique ID.

prefs required object

Prefs key-value JSON object.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.updatePrefs('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->updatePrefs('[USER_ID]', []);
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.update_prefs('[USER_ID]', {})
    

Delete User Session

DELETE/users/{userId}/sessions/{sessionId}

Delete user sessions by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.write" permission scope.

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
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.deleteSession('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->deleteSession('[USER_ID]', '[SESSION_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.delete_session('[USER_ID]', '[SESSION_ID]')
    

Delete User Sessions

DELETE/users/{userId}/sessions

Delete all user sessions by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "users.write" permission scope.

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
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let users = new sdk.Users(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = users.deleteSessions('[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('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $users = new Users($client);
    
    $result = $users->deleteSessions('[USER_ID]');
  • from appwrite.client import Client
    from appwrite.services.users import Users
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    users = Users(client)
    
    result = users.delete_sessions('[USER_ID]')