# Session Tracking APIs for managing user tracking sessions. These endpoints allow clients to create, retrieve, and delete tracking sessions which are used for analytics and user behavior tracking. ## Retrieve current tracking session - [GET /playouts/{playout_id}/tracking/session](https://docs.jay-metadata.com/apis/playout/latest/openapi/session-tracking/getactivetrackingsession.md): Retrieves the tracking session from the header or cookie sent by the client. The tracking session contains information about the user's session including a unique identifier, creation timestamp, and optional user ID for cross-session tracking. This endpoint allows clients to verify if they have an active valid session. Tries to retrieve the tracking session in this order: 1. Cookie with name 2. Header with name Args: request: The incoming HTTP request containing potential session data in cookies or headers Raises: HTTPException: If the session is invalid or not found (400 Bad Request). Returns: ResultResponse[TrackingSession]: The active tracking session. ## Initiate a new tracking session - [POST /playouts/{playout_id}/tracking/session](https://docs.jay-metadata.com/apis/playout/latest/openapi/session-tracking/createnewtrackingsession.md): Initiates a new tracking session for analytics and user behavior tracking. Creates a new tracking session with a unique ID and current timestamp, and sets it as both a cookie and header in the response. The session data is base64-encoded JSON that contains the session ID, start timestamp, and source information. The tracking session is used to correlate user actions across different API requests and provides analytics capabilities for understanding user behavior. If the client can't process cookies or uses a library that doesn't support set-cookie headers, the client should extract the returned session value and manually add it as a header in subsequent requests. Args: response: The HTTP response object to which the cookie and header will be added user_id: Optional user identifier to track users across multiple sessions Returns: ResultResponse[TrackingSession]: The newly created tracking session object with session ID, timestamp, and source. ## Delete tracking session - [DELETE /playouts/{playout_id}/tracking/session](https://docs.jay-metadata.com/apis/playout/latest/openapi/session-tracking/deletetrackingsession.md): Deletes the tracking session. Removes the tracking session cookie from the client by sending appropriate cookie deletion headers. This effectively ends the tracking session and stops the correlation of user actions across different API requests. Note that this only affects the cookie, not any header values the client might be storing independently. Clients using header-based tracking should stop sending the tracking header after calling this endpoint. Args: response: The HTTP response object to which cookie deletion headers will be added request: The incoming HTTP request containing the session to be deleted Returns: ResultResponse[Dict[str, str]]: A message confirming the session was deleted