# Session

## Generate Session

To establish a websocket connection, you must first generate a **session ID**. This session ID is required for authenticating your websocket connection.

**Request**

* **Endpoint**: `POST {baseUrl}/auth/session`
* **Headers**:\
  Provide your `appId` and `appSecret` in the request headers.

**Response**

* The **session ID** is included in the response body as shown below.
* **Session Expiry**:\
  The generated session ID is valid for **6 hours**. After expiry, you will need to generate a new session.
* To connect to the websocket, include the session ID as a request query param. Detailed instructions on how to establish a websocket connection can be found [here](/live-tracking-apis/positions/stream-positions.md)

```json
{
    "status": true,
    "message": "Session successfully generated",
    "data": {
        "session": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsiYXBwSWQiOiI2NjQyMDk3IiwiYXBwU2VjcmV0IjoiQUNVTEdFV1VaVlE5UlI4NVJBVktLMlRBTEFSOVlSRFEifSwiaWF0IjoxNzQwNDY1NjAzLCJleHAiOjE3NDA0ODcyMDN9.1pEoVBbXvgeDEZHhSjSUFUfN7GEe-EhDXIxUjy7A6oI",
        "expiresAt": "2025-02-25T12:40:03.965Z"
    }
}
```


---

# 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.sendstackhq.com/the-basics/session.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.
