# 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](https://docs.sendstackhq.com/live-tracking-apis/positions/stream-positions)

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