Docs

Account

The account service allows you to fetch and update information related to the currently logged-in user. You can use the service to retrieve a list of all the user sessions across different devices and a security log with the recent account activity.

Using the account service, you can also allow the logged-in user to update his account name, email, or passwords.

This service also exposes an endpoint to save and read user preferences as a key-value object. This feature is handy if you want to allow extra customization in your app. Common usage for this feature may include saving the user preferred locale, timezone, or custom app theme. The usage of this feature is only limited only by your imagination.

Get Account

GET/account

Get currently logged in user data as JSON object.

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

Get Account Preferences

GET/account/prefs

Get currently logged in user preferences key-value object.

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

Get Account Active Sessions

GET/account/sessions

Get currently logged in user list of active sessions across different devices.

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

Get Account Security Log

GET/account/security

Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.

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

Update Account Name

PATCH/account/name

Update currently logged in user account name.

Arguments

Name Type Description
name required string

User name

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

Update Account Password

PATCH/account/password

Update currently logged in user password. For validation, user is required to pass the password twice.

Arguments

Name Type Description
password required string

New password

old-password required string

Old password

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

Update Account Email

PATCH/account/email

Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request.

Arguments

Name Type Description
email required string

Email Address

password required string

User Password

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

Update Account Prefs

PATCH/account/prefs

Update currently logged in user account preferences. You can pass only the specific settings you wish to update.

Arguments

Name Type Description
prefs required string

Prefs key-value JSON object string.

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

Delete Account

DELETE/account

Delete currently logged in user account.

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