Docs

Account

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

Get Account

GET/account

Get currently logged in user data as JSON object.

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

Get Account Preferences

GET/account/prefs

Get currently logged in user preferences key-value object.

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

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

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

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

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

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

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

Delete Account

DELETE/account

Delete currently logged in user account.

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