> ## Content Index
> Fetch the complete content index at: https://blog.fabrixly.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Use Session and Tenant Switcher APIs
- URL: https://blog.fabrixly.com/how-to-use-session-and-tenant-switcher-apis/
- Published: 2026-07-07T14:10:54.000Z
- Updated: 2026-07-07T14:10:53.000Z
- Author: Fabrixly
- Tags: Documentation

This guide describes how to manage active login sessions and switch organizations (tenants) dynamically.

---

## 🔐 Authentication & Prerequisites

All session and tenant switcher endpoints require standard user authentication: `Authorization: Bearer <user-jwt-token>`

---

## 1\. List Active Sessions

Retrieve all active browser and device sessions for the currently authenticated user.

- **HTTP Method**: `GET`
- **Path**: `/api/sessions`
- **Headers**:
  - `Authorization: Bearer <user-jwt-token>`

### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/sessions \
  -H "Authorization: Bearer <user-jwt-token>"

```

### Response (`200 OK`)

```json
[
  {
    "id": "sess_0011223344",
    "ipAddress": "192.168.1.10",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...",
    "createdAt": "2026-07-07T12:00:00Z",
    "lastAccessedAt": "2026-07-07T13:45:00Z",
    "isCurrent": true
  }
]

```

---

## 2\. Revoke a Specific Session

Terminate an active session on a specific device/browser using the Session ID.

- **HTTP Method**: `DELETE`
- **Path**: `/api/sessions/:sessionId`
- **Headers**:
  - `Authorization: Bearer <user-jwt-token>`

### Example Request (curl)

```bash
curl -X DELETE https://ids.fabrixly.com/api/sessions/sess_0011223344 \
  -H "Authorization: Bearer <user-jwt-token>"

```

### Response (`200 OK`)

```json
{
  "message": "Session terminated successfully"
}

```

---

## 3\. Log Out All Other Devices

Terminates all active sessions for the user except for the one making the request.

- **HTTP Method**: `POST`
- **Path**: `/api/sessions/logout-all`
- **Headers**:
  - `Authorization: Bearer <user-jwt-token>`

### Example Request (curl)

```bash
curl -X POST https://ids.fabrixly.com/api/sessions/logout-all \
  -H "Authorization: Bearer <user-jwt-token>"

```

### Response (`200 OK`)

```json
{
  "message": "All other sessions logged out successfully"
}

```

---

## 4\. List User's Organizations (Tenants)

Lists all organizations (tenants) the currently authenticated user belongs to.

- **HTTP Method**: `GET`
- **Path**: `/api/user/organizations`
- **Headers**:
  - `Authorization: Bearer <user-jwt-token>`

### Example Request (curl)

```bash
curl -X GET https://ids.fabrixly.com/api/user/organizations \
  -H "Authorization: Bearer <user-jwt-token>"

```

### Response (`200 OK`)

```json
{
  "organizations": [
    {
      "id": "org_xyz789abc",
      "name": "Acme Corp",
      "domain": "acme.com",
      "is_default": true,
      "roles": ["ORG_ADMIN"],
      "teams": [
        { "id": "tem_987abc654", "name": "General" }
      ]
    }
  ]
}

```

---

## 5\. Switch Active Organization Context

Changes the active tenant organization context for the user's active session.

- **HTTP Method**: `POST`
- **Path**: `/api/user/switch-organization`
- **Headers**:
  - `Content-Type: application/json`
  - `Authorization: Bearer <user-jwt-token>`

### Example Request (curl)

```bash
curl -X POST https://ids.fabrixly.com/api/user/switch-organization \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <user-jwt-token>" \
  -d '{
    "organizationId": "org_xyz789abc"
  }'

```

### Response (`200 OK`)

```json
{
  "message": "Switched organization context successfully",
  "token": "new-switched-user-jwt-token-string"
}

```