---
title: AccountApi
summary: PHP SDK: the Account operations, 10 methods, each with its parameters, result and a complete example.
order: 13
languages: [php]
sdk-package: PHP SDK · BIMworks
link-terms: true
---

# AccountApi

[[page:reference/sdk/php|PHP SDK]] · `BIMworks\Api` · class · 10 methods

The signed-in account: registration, password, sessions and settings

Construct it with the client of [[page:reference/sdk/php#connect|the connect step]]: `new AccountApi(config: $client)`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/php/accountapi#changepassword|changePassword]]</code></td><td>[[openapi:ChangePassword]]</td><td>Change the password</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#getsettings|getSettings]]</code></td><td>[[openapi:GetSettings]]</td><td>Read the account settings</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#listreferencevalues|listReferenceValues]]</code></td><td>[[openapi:ListReferenceValues]]</td><td>The values of the settings form</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#logout|logout]]</code></td><td>[[openapi:Logout]]</td><td>Record a sign-out</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#register|register]]</code></td><td>[[openapi:Register]]</td><td>Register an account</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#requestpasswordreset|requestPasswordReset]]</code></td><td>[[openapi:RequestPasswordReset]]</td><td>Send a password reset e-mail</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#requestvalidationemail|requestValidationEmail]]</code></td><td>[[openapi:RequestValidationEmail]]</td><td>Send a new validation e-mail</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#savesettings|saveSettings]]</code></td><td>[[openapi:SaveSettings]]</td><td>Change the account settings</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#signoutothersessions|signOutOtherSessions]]</code></td><td>[[openapi:SignOutOtherSessions]]</td><td>Sign out every other session</td></tr>
<tr><td><code>[[page:reference/sdk/php/accountapi#validateemailaddress|validateEmailAddress]]</code></td><td>[[openapi:ValidateEmailAddress]]</td><td>Confirm an e-mail address and set the password</td></tr>
</tbody>
</table>

## `changePassword` {#changepassword}

```php
public function changePassword(ChangePasswordRequest $change_password_request): AuthResult
```

Change the password. Changes the password of the signed-in account and signs out every other session; this one continues on the session answered here. An account session only: an API token is refused. `current_password` is needed when the account has a password, `code` when it has two-factor authentication. An account without a password (one that signs in with e-mail codes) gets its first one, which needs a session signed in within the last 10 minutes.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ChangePassword]] · <code>POST /openapi/account/ChangePassword</code></td></tr>
<tr><th>Scope</th><td>[[scope:account:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>change_password_request</code></td><td><code>[[page:reference/sdk/php/models#ChangePasswordRequest|ChangePasswordRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ChangePassword]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#AuthResult|AuthResult]]</code> — The new session

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\ChangePasswordRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "current_password": "",
  "password": "",
  "code": 0,
  "response_format": "auth"
}
JSON, ChangePasswordRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->changePassword($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `getSettings` {#getsettings}

```php
public function getSettings(): AccountSettings
```

Read the account settings. The settings of the account behind the credential: name, country, language, time zone and the web app preferences. With an API token, those of the account that created it.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetSettings]] · <code>POST /openapi/account/GetSettings</code></td></tr>
<tr><th>Scope</th><td>[[scope:account:read]]</td></tr>
</tbody>
</table>

### Parameters

None: the operation takes no request.

### Returns

<code>[[page:reference/sdk/php/models#AccountSettings|AccountSettings]]</code> — The settings

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
// (GetSettings takes no request)

// 3. The call
$result = (new AccountApi(config: $client))->getSettings();

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `listReferenceValues` {#listreferencevalues}

```php
public function listReferenceValues(ListReferenceValuesRequest $list_reference_values_request): ReferenceValue[]
```

The values of the settings form. The countries (ISO 3166 codes), languages (ISO 639-1 codes) or time zones (tz identifiers) that the settings take, with a name to show. Names are in English.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ListReferenceValues]] · <code>POST /openapi/account/ListReferenceValues</code></td></tr>
<tr><th>Scope</th><td>any login</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>list_reference_values_request</code></td><td><code>[[page:reference/sdk/php/models#ListReferenceValuesRequest|ListReferenceValuesRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ListReferenceValues]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#ReferenceValue|ReferenceValue]][]</code> — The values

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\ListReferenceValuesRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "kind": "countries"
}
JSON, ListReferenceValuesRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->listReferenceValues($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `logout` {#logout}

```php
public function logout(): void
```

Record a sign-out. Records that the session signed out. It revokes nothing: the bearer token stays valid until it expires. To end sessions, use SignOutOtherSessions or ChangePassword.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:Logout]] · <code>POST /openapi/account/Logout</code></td></tr>
<tr><th>Scope</th><td>any login</td></tr>
</tbody>
</table>

### Parameters

None: the operation takes no request.

### Returns

Nothing: the operation answers without a body (Recorded).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
// (Logout takes no request)

// 3. The call
(new AccountApi(config: $client))->logout();

// 4. The result
// (Logout answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```

## `register` {#register}

```php
public function register(RegisterRequest $register_request): void
```

Register an account. Creates an account for an e-mail address and sends it the validation e-mail; the account is usable once the address is confirmed with ValidateEmailAddress. Refused (REGISTRATION_NOT_ALLOWED) when the instance does not allow self-registration (security.account_self_registration) or the address asked too often; an address that already has an account is refused with EMAIL_ADDRESS_ALREADY_REGISTERED.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:Register]] · <code>POST /openapi/account/Register</code></td></tr>
<tr><th>Scope</th><td>none: callable before logging in</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>register_request</code></td><td><code>[[page:reference/sdk/php/models#RegisterRequest|RegisterRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:Register]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (The validation e-mail is sent).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RegisterRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (Register needs no login)
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": "",
  "preferred_language": ""
}
JSON, RegisterRequest::class);

// 3. The call
(new AccountApi(config: $client))->register($request);

// 4. The result
// (Register answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```

## `requestPasswordReset` {#requestpasswordreset}

```php
public function requestPasswordReset(RequestPasswordResetRequest $request_password_reset_request): void
```

Send a password reset e-mail. Sends a link to reset the password. The reset itself is completed in the BIM.works web app. It answers the same whether or not the account exists.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:RequestPasswordReset]] · <code>POST /openapi/account/RequestPasswordReset</code></td></tr>
<tr><th>Scope</th><td>none: callable before logging in</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>request_password_reset_request</code></td><td><code>[[page:reference/sdk/php/models#RequestPasswordResetRequest|RequestPasswordResetRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:RequestPasswordReset]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RequestPasswordResetRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (RequestPasswordReset needs no login)
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": ""
}
JSON, RequestPasswordResetRequest::class);

// 3. The call
(new AccountApi(config: $client))->requestPasswordReset($request);

// 4. The result
// (RequestPasswordReset answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```

## `requestValidationEmail` {#requestvalidationemail}

```php
public function requestValidationEmail(RequestValidationEmailRequest $request_validation_email_request): void
```

Send a new validation e-mail. A new validation link for an address that registered but did not confirm yet. It answers the same whether or not such an account exists.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:RequestValidationEmail]] · <code>POST /openapi/account/RequestValidationEmail</code></td></tr>
<tr><th>Scope</th><td>none: callable before logging in</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>request_validation_email_request</code></td><td><code>[[page:reference/sdk/php/models#RequestValidationEmailRequest|RequestValidationEmailRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:RequestValidationEmail]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RequestValidationEmailRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (RequestValidationEmail needs no login)
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": ""
}
JSON, RequestValidationEmailRequest::class);

// 3. The call
(new AccountApi(config: $client))->requestValidationEmail($request);

// 4. The result
// (RequestValidationEmail answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```

## `saveSettings` {#savesettings}

```php
public function saveSettings(AccountSettings $account_settings): void
```

Change the account settings. Changes the settings that are passed; the others stay as they are. With an API token, those of the account that created it.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:SaveSettings]] · <code>POST /openapi/account/SaveSettings</code></td></tr>
<tr><th>Scope</th><td>[[scope:account:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>account_settings</code></td><td><code>[[page:reference/sdk/php/models#AccountSettings|AccountSettings]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:SaveSettings]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Saved).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\AccountSettings;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "full_name": "",
  "country_code": "",
  "preferred_language": "",
  "time_zone_id": "",
  "bim_context": "",
  "show_deleted_nodes": false,
  "email_about_vulnerabilities": false,
  "ui_mode": "END_USER"
}
JSON, AccountSettings::class);

// 3. The call
(new AccountApi(config: $client))->saveSettings($request);

// 4. The result
// (SaveSettings answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```

## `signOutOtherSessions` {#signoutothersessions}

```php
public function signOutOtherSessions(?SignOutOtherSessionsRequest $sign_out_other_sessions_request = null): AuthResult
```

Sign out every other session. Ends every session of the signed-in account except this one, which continues on the session answered here: for a lost or shared device. An account session only. API tokens are separate credentials and keep working; revoke them with DeleteApiToken.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:SignOutOtherSessions]] · <code>POST /openapi/account/SignOutOtherSessions</code></td></tr>
<tr><th>Scope</th><td>[[scope:account:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>sign_out_other_sessions_request</code></td><td><code>[[page:reference/sdk/php/models#SignOutOtherSessionsRequest|SignOutOtherSessionsRequest]]</code><span class="opt">optional</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:SignOutOtherSessions]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/php/models#AuthResult|AuthResult]]</code> — The new session

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\SignOutOtherSessionsRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => 'BIM_WORKS_API_TOKEN']));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "response_format": "auth"
}
JSON, SignOutOtherSessionsRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->signOutOtherSessions($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;
```

## `validateEmailAddress` {#validateemailaddress}

```php
public function validateEmailAddress(ValidateEmailAddressRequest $validate_email_address_request): void
```

Confirm an e-mail address and set the password. Confirms the address with the token from the validation e-mail and sets the account's password (8 to 128 characters, not a common one, not the address). It does not sign in: use LoginWithUsernamePassword after. The link is valid for a day.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ValidateEmailAddress]] · <code>POST /openapi/account/ValidateEmailAddress</code></td></tr>
<tr><th>Scope</th><td>none: callable before logging in</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>validate_email_address_request</code></td><td><code>[[page:reference/sdk/php/models#ValidateEmailAddressRequest|ValidateEmailAddressRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ValidateEmailAddress]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (The address is confirmed).

### Example

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\ValidateEmailAddressRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (ValidateEmailAddress needs no login)
$client = (new Configuration())->setHost('BIM_WORKS_ADDRESS/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": "",
  "token": "",
  "password": ""
}
JSON, ValidateEmailAddressRequest::class);

// 3. The call
(new AccountApi(config: $client))->validateEmailAddress($request);

// 4. The result
// (ValidateEmailAddress answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;
```
