# How to configure User Session Timeout

import DocButton from '~/components/webkit/DocButton.vue';
import Tag from '~/components/webkit/Tag.vue';

<Tag severity="info">Preview</Tag>

The **User Session Timeout** policy enables you to define a **maximum idle time**, ensuring that sessions are automatically terminated after a period of inactivity. It also allows you to define a **maximum session time** to avoid sessions staying open indefinitely.

This guide walks you through configuring the User Session Timeout policy.

<DocButton href="/en/documentation/products/accounts/user-session-timeout/" label="Go to User Session Timeout reference" kind="secondary" target="_blank" size="medium" />

:::note
When an organization sets up the User Session Timeout, it applies to all account levels.

This policy is available for customers of all [Azion Support](https://www.azion.com/en/professional-services/) services.
:::

---

## Configuring a user session timeout

:::note
To configure User Session Timeout, you must have *Account Owner* privileges.

If you aren't an *Account Owner*, the system returns an *Error 403*.
:::

1. Run the following `GET` request in your terminal to obtain the current values for the User Session Timeout in your account. 

```bash
curl --request GET \
  --url https://api.azion.com/v4/auth/policies/session \
  --header 'Accept: application/json' \
  --header 'Authorization: 123'
```

2. You'll receive a response similar to this:

```bash
{
  "data": {
    "max_idle_time": 1,
    "max_session_time": 5
  }
```

This means the policy is configured with *1 minute for the maximum idle time and 5 minutes for the maximum session time*.

3. Run the following `PUT` request in your terminal to update the values for the User Session Timeout in your account. 

```bash
curl --request PUT \
  --url https://api.azion.com/v4/auth/policies/session \
  --header 'Accept: application/json' \
  --header 'Authorization: 123' \
  --header 'Content-Type: application/json' \
  --data '{
  "max_idle_time": 1,
  "max_session_time": 5
}'
```

Where: 

| Key | Type | Description |
| ----------- | ----------- | ----------- |
| `max_idle_time` | Integer | Defines the period of inactivity after which a session is automatically terminated. The value must be in *minutes*. Default value and maximum idle time allowed: `1440`, equivalent to *1 day* |
| `max_session_time` | Integer | Defines the total time a session can remain active, regardless of activity, ensuring sessions don't stay open indefinitely. The value must be in *minutes*, between `5` minutes and `21600` minutes, equivalent to *15 days*. Default value: `21600` |

4. You'll receive a response similar to this:

```bash
{
  "state": "executed",
  "data": {
    "max_idle_time": 1,
    "max_session_time": 5
  }
```

Done. The User Session Timeout is now configured with the new values.

:::tip
Check the [Azion API documentation](https://api.azion.com/) to know more about all features available via API.
:::