# Sessions

Session routes fetch, inspect, message, and disconnect active script sessions.

## Get Sessions

**`GET`** `/api/v1/sessions/get`

#### Query

| Query     | Description                                                     |
| --------- | --------------------------------------------------------------- |
| discordId | Discord ID to look for.                                         |
| key       | Key to look for.                                                |
| hubId     | Hub ID to fetch all active sessions for all scripts in the hub. |

{% hint style="warning" %}
Provide `hubId`, or provide one of `discordId` / `key`. If `hubId` is given, it is used instead of the key lookup.
{% endhint %}

{% hint style="info" %}
Sessions may take up to 90 seconds to get removed after getting disconnected.
{% endhint %}

#### Response

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

```json
{
  "success": true,
  "message": "Successfully fetched sessions.",
  "sessions": [
    {
      "id": "97963719390038484793",
      "robloxUsername": "LuaProtOnTop",
      "robloxJobId": "5580cdf5-19cf-40ce-9fd9-fb6d3ca0098a",
      "robloxUniverseId": "9432747410",
      "created": 1768140224
    }
  ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Key could not be found."
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "success": false,
  "message": "Hub not found or linked to your account."
}
```

{% endtab %}
{% endtabs %}

## Session Info

**`GET`** `/api/v1/sessions/:sessionId/info`

#### Params

| Param     | Description             |
| --------- | ----------------------- |
| sessionId | Session ID to look for. |

#### Response

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

```json
{
  "success": true,
  "message": "Successfully fetched session info.",
  "session": {
    "id": "97963719390038484793",
    "key": "73978994376e1f3e307914c4",
    "robloxUsername": "LuaProtOnTop",
    "robloxJobId": "5580cdf5-19cf-40ce-9fd9-fb6d3ca0098a",
    "robloxUniverseId": "9432747410",
    "created": 1768140224
  },
  "key": {
    "hubId": "40511091490620200512",
    "discordId": "123456789098765432",
    "key": "73978994376e1f3e307914c4",
    "expire": 1764749562,
    "note": "Customer note",
    "created": 1764749562,
    "activated": true,
    "hwid": "589401805431295092384985734",
    "hwidResetCount": 0,
    "lastHwidReset": 0,
    "executionCount": 0,
    "lastExecution": 0,
    "blacklisted": false,
    "blacklistReason": null,
    "limitedScripts": null,
    "discordData": {
      "id": "123456789098765432",
      "username": "wompus_dompus",
      "avatar": null,
      "global_name": "Wompus",
      "modified": 1759761781,
      "created": 1759761781
    }
  }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Invalid session."
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "success": false,
  "message": "Session not found or unauthorized to manage."
}
```

{% endtab %}
{% endtabs %}

## Message Session

**`POST`** `/api/v1/sessions/message/:sessionId`

#### Params

| Param     | Description            |
| --------- | ---------------------- |
| sessionId | Session ID to message. |

#### Payload

```json
{
  "message": "Hello from the dashboard"
}
```

{% hint style="info" %}
`message` must be between 1 and 100 characters.
{% endhint %}

#### Response

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

```json
{
  "success": true,
  "message": "Successfully messaged session."
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "You cannot manage this session."
}
```

{% endtab %}
{% endtabs %}

## Disconnect Session

**`DELETE`** `/api/v1/sessions/disconnect/:sessionId`

#### Params

| Param     | Description               |
| --------- | ------------------------- |
| sessionId | Session ID to disconnect. |

#### Response

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

```json
{
  "success": true,
  "message": "Successfully disconnected session."
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "You cannot manage this session."
}
```

{% endtab %}
{% endtabs %}

## Message Sessions

**`POST`** `/api/v1/sessions/messageall`

#### Payload

```json
{
  "hubId": "40511091490620200512",
  "message": "Hello everyone"
}
```

{% hint style="warning" %}
Provide `hubId` or `key`. If `hubId` is given, every active session for every script in the hub is messaged.
{% endhint %}

{% hint style="info" %}
`message` must be between 1 and 100 characters.
{% endhint %}

#### Response

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

```json
{
  "success": true,
  "message": "Successfully messaged sessions."
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "No active sessions found."
}
```

{% endtab %}
{% endtabs %}

## Disconnect Sessions

**`DELETE`** `/api/v1/sessions/disconnectall`

#### Query

| Query | Description                                                          |
| ----- | -------------------------------------------------------------------- |
| key   | Key to disconnect sessions for.                                      |
| hubId | Hub ID to disconnect all active sessions for all scripts in the hub. |

{% hint style="warning" %}
Provide `hubId` or `key`. If `hubId` is given, every active session for every script in the hub is disconnected.
{% endhint %}

#### Response

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

```json
{
  "success": true,
  "message": "Successfully disconnected sessions."
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "No active sessions found."
}
```

{% endtab %}
{% endtabs %}


---

# 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://docs.luaprot.net/luaprot/api-documentation/sessions.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.
