# Updating Users

{% hint style="danger" %}
**Important Note!**\
\
Constructor Groups’ XAPI V1 has been retired and is no longer available to new customers. Please use the Groups V2 API going forward.\
\
Link to V2 API documentation: <https://developer.perculus.com/v2-en>
{% endhint %}

Below is a list of available parameters for updating users:

<table><thead><tr><th>Parameter</th><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>string</td><td>Name of the user</td></tr><tr><td>surname</td><td>string</td><td>Surname of the user</td></tr><tr><td>email</td><td>string</td><td>Email of the user</td></tr><tr><td>username</td><td>string</td><td>Username of the user</td></tr><tr><td>role</td><td>string</td><td>Role of the user(<a href="/pages/s7xHSgEOsXGduC8JhoWN">see</a>)</td></tr><tr><td>psd</td><td>string</td><td>Password of the user</td></tr><tr><td>mobile</td><td>string</td><td>Mobile of the user</td></tr><tr><td>login_allowed</td><td>bool</td><td>Flag if the login is allowed</td></tr><tr><td>active</td><td>bool</td><td>Flag if the user is active</td></tr><tr><td>lang</td><td>string</td><td>Language of the user(<a href="/pages/g1PtbMSKQwBvj8rlAjqB">see</a>). This option modifies: <mark style="color:green;">session interface, panel interface and mails.</mark></td></tr><tr><td>timezone</td><td>string</td><td>Timezone of the user(<a href="/pages/QQkLKY0zSq1aG5jrSdPH">see</a>) This option modifies: how the user sees <mark style="color:green;">sessions' hours.</mark></td></tr><tr><td>expires_at</td><td>string</td><td>Date which the user will expire(<a href="/pages/lLpdFu4z4JIivcKEy2nr">see</a>)</td></tr></tbody></table>

{% hint style="info" %}
If a parameter is not sent or if its null, it won't be applied. So if you only want to update the field email for a user, you don't have to send other parameters.&#x20;

A request like so would achieve that:

```bash
curl --location --request PUT 'https://<DOMAIN>/xapi/user/<USER_ID>' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
    "role": "a"
}'
```

{% endhint %}

**Example payload:**

{% tabs %}
{% tab title="CURL" %}

```bash
curl --location --request PUT 'https://<DOMAIN>/xapi/user/<USER_ID>' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
    "name": "John1",
    "surname": "Doe1",
    "username": "johndoe1",
    "email": "john@doe.com1"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
from perculus_sdk.client import APIClient

# API client
client = APIClient()
...

# Update user 
user = client.users.update_user("<USER_ID>",{
    "name": "john1",
    "surname": "Doe1",
    "username": "johndoe1",
    "email": "john@doe.com1"
})
print(user)
```

{% endtab %}

{% tab title="C#" %}

```
// ASAP :)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import APIClient from "perculus-sdk"

// API client
const client = new APIClient()
...

// Update user 
const user = client.users.updateUser("<USER_ID>", {
    name: "<USER_NAME>",
    surname: "<USER_SURNAME>",
    username: "<USERNAME>",
    email: "<USER_EMAIL>",
    role: "<USER_ROLE>"
})
console.log(user)
```

{% endtab %}

{% tab title="Go" %}

```
// ASAP :)
```

{% endtab %}
{% endtabs %}

**Example response:**

```json
{
    "user_id": "<USER_ID>",
    "name": "john1",
    "surname": "Doe1",
    "username": "johndoe1",
    "email": "john@doe.com1",
    "role": "u",
    "mobile": "",
    "login_allowed": true,
    "status": 1,
    "lang": "tr-TR",
    "timezone": null,
    "expires_at": null,
    "creation_date": "2024-08-01T00:45:03.8888474+00:00",
    "updating_date": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.perculus.com/services/user-management/user-update.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
