# List user sessions (/docs/apis/management/users/GetAllUserSessions)

`GET /users/{user_id}/sessions`

Retrieves a paginated list of all active sessions for the specified user. Optional query parameters allow searching, filtering, and sorting the results. Access to user session management endpoints requires an active Pro plan subscription.

Base URL: `https://{tenant}.{region}.monocloud.com/api`, where `{tenant}`, `{region}` (one of us, eu, in) come from your tenant. Authentication: send your Management API key in the `X-API-KEY` header.

## Parameters

- `user_id` (path) (string, required) The unique identifier of the user.
- `page` (query) (integer, int32, default 1) The page number to retrieve.
- `size` (query) (integer, int32, default 10) The number of user sessions to return per page.
- `client_id` (query) (string) Filters results to user sessions associated with the specified client.
- `sort` (query) (string) Sort expression in the format `field:direction`, where direction is `1` for ascending or `-1` for descending. Supported fields include - `session_id`, `initiated_at`, `expires_at`, `last_updated`.

## Response body

`200`, JSON. The user's sessions were retrieved successfully

Returns `UserSession[]`. Each item has these fields:

- `session_id` (string, required) The unique identifier of the user session.
- `client_ids` (string[], required) The list of client identifiers associated with this session.
- `initiated_at` (integer, required, date-time) Specifies the time at which the session was initiated (in Epoch).
- `expires_at` (integer, required, date-time) Specifies the time at which the session is scheduled to expire (in Epoch).
- `last_updated` (integer, required, date-time) Specifies the time at which the session was last updated (in Epoch).
- `last_metadata` (UserSessionMetadata, required) The most recent metadata recorded for this session.
  - `city` (string) The city recorded during the most recent session activity.
  - `country` (string) The country recorded during the most recent session activity.
  - `region` (string) The geographic region recorded during the most recent session activity.
  - `latitude` (string) The latitude recorded during the most recent session activity.
  - `longitude` (string) The longitude recorded during the most recent session activity.
  - `ip_address` (string) The IP address recorded during the most recent session activity.
  - `user_agent` (string) The user agent recorded during the most recent session activity.

## Errors

- `400` Bad Request
  - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
  - `title` (string, required) A short, human-readable summary of the error.
  - `status` (integer, required, int32) The HTTP status code associated with this error response.
  - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
  - `detail` (string) A human-readable explanation specific to this occurrence of the error.
  - `instance` (string) A URI reference that identifies the specific occurrence of the error.
- `401` Unauthorized
- `402` Payment Required
  Same body as `400`.
- `403` Forbidden
- `404` Not Found
  Same body as `400`.
- `422` Unprocessable Entity
  - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
  - `title` (string, required) A short, human-readable summary of the error.
  - `status` (integer, required, int32) The HTTP status code associated with this error response.
  - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
  - `detail` (string) A human-readable explanation specific to this occurrence of the error.
  - `instance` (string) A URI reference that identifies the specific occurrence of the error.
  - `errors` (Record<string, string[]>, required) A key-value map of validation errors, where each key represents a request field and the value contains one or more messages describing why the request could not be processed.

## Example (MonoCloud .NET SDK)

```csharp
using MonoCloud.Management;
using MonoCloud.Management.Core.Base;

var apiClient = new MonoCloudManagementClient(new MonoCloudConfig("<your-domain>", "[[API-Key]]"));


var userId = "WUgDGqaqzqkRmsgd3PFAT";

var page = 1;

var size = 10;

var clientId = "eCOGRJYpnNwwAAuCeReEW";

var sort = "initiated_at:1";


var result = await apiClient.Users.GetAllUserSessionsAsync(userId, page, size, clientId, sort);
```

## Example (MonoCloud Javascript SDK)

```javascript
import { MonoCloudManagementClient } from '@monocloud/management';

const apiClient = MonoCloudManagementClient.init({ domain: '<your-domain>', apiKey: '[[API-Key]]' });

const userId = 'WUgDGqaqzqkRmsgd3PFAT';

const page = 1;

const size = 10;

const clientId = 'eCOGRJYpnNwwAAuCeReEW';

const sort = 'initiated_at:1';

const result = apiClient.users.getAllUserSessions(userId, page, size, clientId, sort);
```