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

# AccountApi

[[page:reference/sdk/python|Python SDK]] · `bimworks` · class · 10 methods

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

Construct it with the client of [[page:reference/sdk/python#connect|the connect step]]: `bimworks.AccountApi(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/python/accountapi#changepassword|change_password]]</code></td><td>[[openapi:ChangePassword]]</td><td>Change the password</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#getsettings|get_settings]]</code></td><td>[[openapi:GetSettings]]</td><td>Read the account settings</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#listreferencevalues|list_reference_values]]</code></td><td>[[openapi:ListReferenceValues]]</td><td>The values of the settings form</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#logout|logout]]</code></td><td>[[openapi:Logout]]</td><td>Record a sign-out</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#register|register]]</code></td><td>[[openapi:Register]]</td><td>Register an account</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#requestpasswordreset|request_password_reset]]</code></td><td>[[openapi:RequestPasswordReset]]</td><td>Send a password reset e-mail</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#requestvalidationemail|request_validation_email]]</code></td><td>[[openapi:RequestValidationEmail]]</td><td>Send a new validation e-mail</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#savesettings|save_settings]]</code></td><td>[[openapi:SaveSettings]]</td><td>Change the account settings</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#signoutothersessions|sign_out_other_sessions]]</code></td><td>[[openapi:SignOutOtherSessions]]</td><td>Sign out every other session</td></tr>
<tr><td><code>[[page:reference/sdk/python/accountapi#validateemailaddress|validate_email_address]]</code></td><td>[[openapi:ValidateEmailAddress]]</td><td>Confirm an e-mail address and set the password</td></tr>
</tbody>
</table>

## `change_password` {#changepassword}

```python
def change_password(self, change_password_request: ChangePasswordRequest) -> 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/python/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/python/models#AuthResult|AuthResult]]</code> — The new session

### Example

```python
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ChangePasswordRequest.from_json(r"""
{
  "current_password": "",
  "password": "",
  "code": 0,
  "response_format": "auth"
}
""")

# 3. The call
result = bimworks.AccountApi(client).change_password(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))
```

## `get_settings` {#getsettings}

```python
def get_settings(self) -> 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/python/models#AccountSettings|AccountSettings]]</code> — The settings

### Example

```python
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

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

# 3. The call
result = bimworks.AccountApi(client).get_settings()

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))
```

## `list_reference_values` {#listreferencevalues}

```python
def list_reference_values(self, list_reference_values_request: ListReferenceValuesRequest) -> List[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/python/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>List[[[page:reference/sdk/python/models#ReferenceValue|ReferenceValue]]]</code> — The values

### Example

```python
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListReferenceValuesRequest.from_json(r"""
{
  "kind": "countries"
}
""")

# 3. The call
result = bimworks.AccountApi(client).list_reference_values(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))
```

## `logout` {#logout}

```python
def logout(self) -> None
```

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

```python
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

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

# 3. The call
bimworks.AccountApi(client).logout()

# 4. The result
# (Logout answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```

## `register` {#register}

```python
def register(self, register_request: RegisterRequest) -> None
```

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/python/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

```python
import bimworks

# 1. Connect to BIM.works (Register needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))

# 2. The request
request = bimworks.RegisterRequest.from_json(r"""
{
  "username": "",
  "preferred_language": ""
}
""")

# 3. The call
bimworks.AccountApi(client).register(request)

# 4. The result
# (Register answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```

## `request_password_reset` {#requestpasswordreset}

```python
def request_password_reset(self, request_password_reset_request: RequestPasswordResetRequest) -> None
```

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/python/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

```python
import bimworks

# 1. Connect to BIM.works (RequestPasswordReset needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))

# 2. The request
request = bimworks.RequestPasswordResetRequest.from_json(r"""
{
  "username": ""
}
""")

# 3. The call
bimworks.AccountApi(client).request_password_reset(request)

# 4. The result
# (RequestPasswordReset answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```

## `request_validation_email` {#requestvalidationemail}

```python
def request_validation_email(self, request_validation_email_request: RequestValidationEmailRequest) -> None
```

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/python/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

```python
import bimworks

# 1. Connect to BIM.works (RequestValidationEmail needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))

# 2. The request
request = bimworks.RequestValidationEmailRequest.from_json(r"""
{
  "username": ""
}
""")

# 3. The call
bimworks.AccountApi(client).request_validation_email(request)

# 4. The result
# (RequestValidationEmail answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```

## `save_settings` {#savesettings}

```python
def save_settings(self, account_settings: AccountSettings) -> None
```

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/python/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

```python
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.AccountSettings.from_json(r"""
{
  "full_name": "",
  "country_code": "",
  "preferred_language": "",
  "time_zone_id": "",
  "bim_context": "",
  "show_deleted_nodes": false,
  "email_about_vulnerabilities": false,
  "ui_mode": "END_USER"
}
""")

# 3. The call
bimworks.AccountApi(client).save_settings(request)

# 4. The result
# (SaveSettings answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```

## `sign_out_other_sessions` {#signoutothersessions}

```python
def sign_out_other_sessions(self, sign_out_other_sessions_request: Optional[SignOutOtherSessionsRequest] = None) -> 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/python/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/python/models#AuthResult|AuthResult]]</code> — The new session

### Example

```python
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="BIM_WORKS_API_TOKEN"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.SignOutOtherSessionsRequest.from_json(r"""
{
  "response_format": "auth"
}
""")

# 3. The call
result = bimworks.AccountApi(client).sign_out_other_sessions(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))
```

## `validate_email_address` {#validateemailaddress}

```python
def validate_email_address(self, validate_email_address_request: ValidateEmailAddressRequest) -> None
```

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/python/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

```python
import bimworks

# 1. Connect to BIM.works (ValidateEmailAddress needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="BIM_WORKS_ADDRESS/openapi"))

# 2. The request
request = bimworks.ValidateEmailAddressRequest.from_json(r"""
{
  "username": "",
  "token": "",
  "password": ""
}
""")

# 3. The call
bimworks.AccountApi(client).validate_email_address(request)

# 4. The result
# (ValidateEmailAddress answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")
```
