> ## Documentation Index
> Fetch the complete documentation index at: https://developers.circularo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 2. Session Token Status Check

> [!WARNING]
>
> You are viewing the documentation of release 26.1, which is no longer the current one. [Go to the documentation of the current release 26.2](https://developers.circularo.com/).

## Session Token Status Check

Before making API calls that require authentication, it's important to verify whether your existing session token is still valid. This scenario demonstrates how to check the status of a session token.

**Key benefits:**

* Verify token validity
* Determine if a new authentication is required
* Retrieve user information and permissions in a single request
* Check if additional authentication steps (like MFA) are needed

### Use Cases

* Application startup to determine if the user is already logged in
* After page refresh to verify session persistence
* Checking if MFA authentication is complete for protected operations

> [!NOTE]
>
> This endpoint is particularly useful for client applications that need to maintain session state across page refreshes or application restarts.

## Step 1 - Check session token status

This endpoint verifies the current authentication status and returns detailed session information.

* Validates if the provided token is still active and usable
* Returns login status and token unlock state
* Provides user profile information if the token is valid
* Includes permission rights and system settings

> [!NOTE]
>
> You can use this endpoint to determine if you need to re-authenticate or if your current token can be used for API calls.

**Endpoint**

```http theme={null}
GET /login
```

**Request**

```http theme={null}
GET /login?token=0CUa8ZNRugg3SHSuyKNBOmecXI0sYx5noqxhTSEpnpiwVhiffDHyaXeAyLp3QK8d&returnToken=true
```

**Response**

```json theme={null}
{
  "logged": true,
  "isUnlocked": true,
  "token": "0CUa8ZNRugg3SHSuyKNBOmecXI0sYx5noqxhTSEpnpiwVhiffDHyaXeAyLp3QK8d",
  "tenant": "default",
  "user": {
    ...
  },
  "settings": {
    ...
  },
  "rights": [
    ...
  ],
  ...
}
```

The response provides comprehensive information about the session token status.

* **logged**: Indicates if the token is valid and the user is authenticated
* **isUnlocked**: Shows if the token is fully unlocked (especially important for MFA-enabled accounts)
* **rights**: Lists all permissions the user has in the system
* **user**: Contains detailed user profile information

> [!NOTE]
>
> Based on this response, your application can make decisions about whether to proceed with API calls or it needs to obtain a new session token.

***

## Session Token Status Check Summary

* If **logged: true** and **isUnlocked: true**, the token is valid and can be used for API calls
* If **logged: true** but **isUnlocked: false**, the token requires additional authentication (MFA)
* If **logged: false**, the token is invalid or expired, and a new login is required

### Example Usage in Client Applications

> [!NOTE]
>
> See our OpenAPI documentation to learn about the full set of API endpoints and parameters.

> [!NOTE]
>
> Please use proper exception handling and function decomposition in your own code. The code is provided for illustrative purposes only and is not intended for production use.

```javascript theme={null}
// Check session token status
const URL = "https://sandbox.circularo.com";
const API_PATH = "/api/v1";

const TOKEN = "YOUR_TOKEN";

try {
    const response = await fetch(`${URL}${API_PATH}/login?token=${TOKEN}&returnToken=true`);
    if (!response.ok) {
        throw new Error(`Login check failed: ${response.status} ${response.statusText}`);
    }

    const statusData = await response.json();

    // Check if the token is valid and unlocked
    if (statusData.logged && statusData.isUnlocked) {
        console.log('Token is valid and unlocked');

    } else if (statusData.logged && !statusData.isUnlocked) {
        console.log('Token is valid but requires MFA unlock');

    } else {
        console.log('Token is invalid or expired');
    }

} catch (error) {
    console.error('Error in login check flow:', error.message);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.