# Session Management

## Retrieve User Sessions

> Retrieves all sessions for the authenticated user, ordered by \`created\_at\` in descending order.\
> \
> \### Response Structure\
> \
> On success (HTTP 200), the response is a JSON object containing:\
> \
> \`\`\`json\
> {\
> &#x20; "sessions": {\
> &#x20;   "\<session\_id>": {\
> &#x20;     "created\_at": {\
> &#x20;       "date": "DD/MM/YYYY",\
> &#x20;       "time": "HH:MM AM/PM"\
> &#x20;     },\
> &#x20;     "video\_url": "...",\
> &#x20;     "segments": \<number>,\
> &#x20;     "analyzed\_video\_url": "...",\
> &#x20;     "activity": "...",\
> &#x20;     "title": "...",\
> &#x20;     "user\_id": "...",\
> &#x20;     "user\_name": "...",\
> &#x20;     "report\_comments": {...},\
> &#x20;     "metrics": {...}\
> &#x20;     // other session fields\
> &#x20;   },\
> &#x20;   "...": {...}\
> &#x20; }\
> }\
> \`\`\`\
> \
> \### Error Handling\
> \- \*\*400 Bad Request\*\*: Invalid parameters (e.g., missing or malformed token).\
> \- \*\*401 Unauthorized\*\*: The token is missing or invalid.\
> \- \*\*403 Forbidden\*\*: The user lacks admin privileges.\
> \- \*\*404 Not Found\*\*: Unable to retrieve sessions (e.g., no sessions found).\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred on the server.\
> \
> \### Security\
> A valid API-KEY token must be provided in the \`Authorization\` header.

````json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/":{"get":{"operationId":"session-management_sessions_list","summary":"Retrieve User Sessions","description":"Retrieves all sessions for the authenticated user, ordered by `created_at` in descending order.\n\n### Response Structure\n\nOn success (HTTP 200), the response is a JSON object containing:\n\n```json\n{\n  \"sessions\": {\n    \"<session_id>\": {\n      \"created_at\": {\n        \"date\": \"DD/MM/YYYY\",\n        \"time\": \"HH:MM AM/PM\"\n      },\n      \"video_url\": \"...\",\n      \"segments\": <number>,\n      \"analyzed_video_url\": \"...\",\n      \"activity\": \"...\",\n      \"title\": \"...\",\n      \"user_id\": \"...\",\n      \"user_name\": \"...\",\n      \"report_comments\": {...},\n      \"metrics\": {...}\n      // other session fields\n    },\n    \"...\": {...}\n  }\n}\n```\n\n### Error Handling\n- **400 Bad Request**: Invalid parameters (e.g., missing or malformed token).\n- **401 Unauthorized**: The token is missing or invalid.\n- **403 Forbidden**: The user lacks admin privileges.\n- **404 Not Found**: Unable to retrieve sessions (e.g., no sessions found).\n- **500 Internal Server Error**: An unexpected error occurred on the server.\n\n### Security\nA valid API-KEY token must be provided in the `Authorization` header.","responses":{"200":{"description":"User sessions retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"description":"A dictionary of sessions keyed by their session IDs.","type":"object","additionalProperties":{"type":"object"}}}}}}},"400":{"description":"Bad Request - Invalid parameters or missing token.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Explanation of the bad request.","type":"string"}}}}}},"401":{"description":"Unauthorized - The token is missing or invalid.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message for authentication failure.","type":"string"}}}}}},"403":{"description":"Forbidden - The user lacks the required privileges.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"User is not permitted to access sessions.","type":"string"}}}}}},"404":{"description":"Not Found - Sessions could not be retrieved (e.g., none found).","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message if sessions are not found.","type":"string"}}}}}},"500":{"description":"Internal Server Error - An unexpected issue occurred on the server.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Detailed error message for server-side failures.","type":"string"}}}}}}},"tags":["session-management"]}}}}
````

## Fetch Sessions by IDs

> Retrieve detailed session data for a list of session IDs. This endpoint is used when the client already has specific session IDs (e.g., from saved reports or analytics) and wants to retrieve their complete data.\
> \
> \### Request Body\
> \- \*\*session\_ids\*\* \*(required)\*: A list of session document IDs to fetch.\
> \
> \### Security\
> Requires Bearer Token in the \`Authorization\` header.\
> \
> \### Errors\
> \- \*\*400 Bad Request\*\*: Invalid input.\
> \- \*\*401 Unauthorized\*\*: Missing or invalid token.\
> \- \*\*403 Forbidden\*\*: The user is not authorized.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred.

```json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/by-ids/":{"post":{"operationId":"session-management_sessions_by-ids_create","summary":"Fetch Sessions by IDs","description":"Retrieve detailed session data for a list of session IDs. This endpoint is used when the client already has specific session IDs (e.g., from saved reports or analytics) and wants to retrieve their complete data.\n\n### Request Body\n- **session_ids** *(required)*: A list of session document IDs to fetch.\n\n### Security\nRequires Bearer Token in the `Authorization` header.\n\n### Errors\n- **400 Bad Request**: Invalid input.\n- **401 Unauthorized**: Missing or invalid token.\n- **403 Forbidden**: The user is not authorized.\n- **500 Internal Server Error**: An unexpected error occurred.","responses":{"200":{"description":"Sessions retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"description":"Dictionary of session data keyed by session ID.","type":"object","additionalProperties":{"type":"object","properties":{"session_id":{"type":"string"},"activity":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"uploaded_date":{"type":"string","format":"date-time"},"video_url":{"type":"string","format":"uri"},"thumbnail_url":{"type":"string","format":"uri"},"analyzed_video_url":{"type":"string","format":"uri"},"title":{"type":"string"},"user_id":{"type":"string"},"user_name":{"type":"string"},"uploaded_name":{"type":"string"},"uploaded_uid":{"type":"string"},"user_status":{"type":"string"},"video_status":{"type":"string","enum":["Processed","Failed"]},"exercise":{"description":"Exercise name (optional, only for certain activities).","type":"string"}}}}}}}}},"400":{"description":"Bad Request - session_ids missing or invalid.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Unauthorized - No token provided.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Forbidden - User is not an admin.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal Server Error - Something went wrong on the server.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}},"tags":["session-management"],"requestBody":{"content":{"application/json":{"schema":{"required":["session_ids"],"type":"object","properties":{"session_ids":{"description":"List of session document IDs to retrieve.","type":"array","items":{"type":"string"}}}}}},"required":true}}}}}
```

## Fetch Filtered Sessions

> Retrieves user sessions filtered by optional parameters such as date range, activity type, title, or user ID. It also supports pagination via \`start\_after\_id\` or \`end\_before\_id\` when no filters are applied.\
> \
> \### Query Parameters\
> \- \*\*start\_after\_id\*\* \*(string, optional)\*: Session ID after which to start pagination. Used only if no filters are set.\
> \- \*\*end\_before\_id\*\* \*(string, optional)\*: Session ID before which to end pagination. Used only if no filters are set.\
> \- \*\*limit\*\* \*(integer, optional)\*: Maximum number of sessions to fetch (default=10).\
> \- \*\*activity\*\* \*(string, optional)\*: Filter by activity type (e.g., 'Running', 'Vertical Jump').\
> \- \*\*start\_date\*\* \*(string, optional, format: dd/mm/yyyy)\*: Filter sessions created on or after this date.\
> \- \*\*end\_date\*\* \*(string, optional, format: dd/mm/yyyy)\*: Filter sessions created on or before this date.\
> \- \*\*title\*\* \*(string, optional)\*: Filter by sessions whose title contains this substring (case-insensitive).\
> \- \*\*user\_id\*\* \*(string, optional)\*: Filter by user ID stored in the session.\
> \| \*\*uploaded\_by\*\* | string | \*\*NEW\*\*\&nbsp;UID that uploaded the raw video. |\
> \| \*\*video\_status\*\* | string \`processed\\|failed\` | \*\*NEW\*\* current state. |\
> \
> \### Response Structure (HTTP 200)\
> \
> On success, the response is a JSON object containing:\
> \- \*\*query\_count\*\* \*(integer)\*: The total number of matching sessions.\
> \- \*\*sessions\*\* \*(object)\*: A dictionary of session documents keyed by their session IDs.\
> \- \*\*first\_doc\_id\*\* \*(string or null)\*: The ID of the first document in the returned set.\
> \- \*\*last\_doc\_id\*\* \*(string or null)\*: The ID of the last document in the returned set.\
> \
> Each session object may include fields such as \`video\_url\`, \`activity\`, \`created\_at\`, \`title\`, etc., plus nested data (e.g. \`report\_comments\`, \`metrics\`). Note that \`created\_at\` is returned as a nested object with \`date\` and \`time\`.\
> \
> \### Error Handling\
> \
> \- \*\*400 Bad Request\*\*: Invalid parameters (e.g., malformed date string) or missing user token.\
> \- \*\*401 Unauthorized\*\*: The token is missing or invalid.\
> \- \*\*403 Forbidden\*\*: The user lacks admin privileges.\
> \- \*\*404 Not Found\*\*: No matching sessions found.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred on the server.\
> \
> \### Security\
> A valid API-KEY token must be provided in the \`Authorization\` header.

```json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/filter/":{"get":{"operationId":"session-management_sessions_filter_list","summary":"Fetch Filtered Sessions","description":"Retrieves user sessions filtered by optional parameters such as date range, activity type, title, or user ID. It also supports pagination via `start_after_id` or `end_before_id` when no filters are applied.\n\n### Query Parameters\n- **start_after_id** *(string, optional)*: Session ID after which to start pagination. Used only if no filters are set.\n- **end_before_id** *(string, optional)*: Session ID before which to end pagination. Used only if no filters are set.\n- **limit** *(integer, optional)*: Maximum number of sessions to fetch (default=10).\n- **activity** *(string, optional)*: Filter by activity type (e.g., 'Running', 'Vertical Jump').\n- **start_date** *(string, optional, format: dd/mm/yyyy)*: Filter sessions created on or after this date.\n- **end_date** *(string, optional, format: dd/mm/yyyy)*: Filter sessions created on or before this date.\n- **title** *(string, optional)*: Filter by sessions whose title contains this substring (case-insensitive).\n- **user_id** *(string, optional)*: Filter by user ID stored in the session.\n| **uploaded_by** | string | **NEW**&nbsp;UID that uploaded the raw video. |\n| **video_status** | string `processed\\|failed` | **NEW** current state. |\n\n### Response Structure (HTTP 200)\n\nOn success, the response is a JSON object containing:\n- **query_count** *(integer)*: The total number of matching sessions.\n- **sessions** *(object)*: A dictionary of session documents keyed by their session IDs.\n- **first_doc_id** *(string or null)*: The ID of the first document in the returned set.\n- **last_doc_id** *(string or null)*: The ID of the last document in the returned set.\n\nEach session object may include fields such as `video_url`, `activity`, `created_at`, `title`, etc., plus nested data (e.g. `report_comments`, `metrics`). Note that `created_at` is returned as a nested object with `date` and `time`.\n\n### Error Handling\n\n- **400 Bad Request**: Invalid parameters (e.g., malformed date string) or missing user token.\n- **401 Unauthorized**: The token is missing or invalid.\n- **403 Forbidden**: The user lacks admin privileges.\n- **404 Not Found**: No matching sessions found.\n- **500 Internal Server Error**: An unexpected error occurred on the server.\n\n### Security\nA valid API-KEY token must be provided in the `Authorization` header.","parameters":[{"schema":{"type":"string"},"name":"start_after_id","in":"query","description":"Session ID after which to start pagination (only used if no filters are set).","required":false},{"schema":{"type":"string"},"name":"end_before_id","in":"query","description":"Session ID before which to end pagination (only used if no filters are set).","required":false},{"schema":{"type":"integer"},"name":"limit","in":"query","description":"Maximum number of sessions to fetch (default=10).","required":false},{"schema":{"type":"string","enum":["Running","Weightlifting","Vertical Jump","Mobility Assessment"]},"name":"activity","in":"query","description":"Activity type filter (e.g., 'Running', 'Weightlifting', 'Vertical Jump', or 'Mobility Assessment').","required":false},{"schema":{"type":"string"},"name":"start_date","in":"query","description":"Filter sessions created on or after this date (dd/mm/yyyy).","required":false},{"schema":{"type":"string"},"name":"end_date","in":"query","description":"Filter sessions created on or before this date (dd/mm/yyyy).","required":false},{"schema":{"type":"string"},"name":"title","in":"query","description":"Filter by sessions whose title contains this substring (case-insensitive).","required":false},{"schema":{"type":"string"},"name":"user_id","in":"query","description":"Filter by user ID stored in the session document.","required":false},{"schema":{"type":"string"},"name":"uploaded_by","in":"query","description":"ID of the user (admin / sub-admin) who uploaded the video.","required":false},{"schema":{"type":"string","enum":["processed","failed"]},"name":"video_status","in":"query","description":"Processing state of the session video.","required":false}],"responses":{"200":{"description":"Filtered sessions retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"query_count":{"description":"Total matching sessions.","type":"integer"},"sessions":{"description":"Dictionary of session documents keyed by their IDs.","type":"object","additionalProperties":{"type":"object"}},"first_doc_id":{"description":"ID of the first session in the result or null if none.","type":"string"},"last_doc_id":{"description":"ID of the last session in the result or null if none.","type":"string"}}}}}},"400":{"description":"Bad Request - Potentially invalid parameters (malformed date, etc.) or missing user token.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Detailed error message describing the reason for the invalid request.","type":"string"}}}}}},"401":{"description":"Unauthorized - Missing or invalid access token.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Authentication error.","type":"string"}}}}}},"403":{"description":"Forbidden - The user lacks admin privileges.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Authorization error.","type":"string"}}}}}},"404":{"description":"Not Found - No matching sessions found or resource unavailable.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Message indicating the sessions could not be retrieved.","type":"string"}}}}}},"500":{"description":"Internal Server Error - An unexpected error occurred on the server.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"A detailed error message for server-side issues.","type":"string"}}}}}}},"tags":["session-management"]}}}}
```

## Update Session Data

> Updates session details (such as title and created\_at timestamp) for a specific session. Requires admin privileges and a valid payment plan.\
> \
> \### Path Parameter\
> \- \*\*session\_id\*\* \*(string, required)\*: The unique session identifier.\
> \
> \### Request Body (JSON)\
> \- \*\*title\*\* \*(string, optional)\*: The updated title for the session.\
> \- \*\*created\_at\*\* \*(string, optional, format: \`YYYY-MM-DD HH:MM:SS\`)\*: The updated session timestamp.\
> \
> \### Response Structure\
> \
> On success, the response contains:\
> \- \*\*success\*\* \*(string)\*: Confirmation that the session was updated.\
> \
> \### Error Responses\
> \- \*\*400 Bad Request\*\*: Invalid request parameters or missing required data.\
> \- \*\*401 Unauthorized\*\*: Missing or invalid access token.\
> \- \*\*403 Forbidden\*\*: Insufficient privileges or invalid payment plan.\
> \- \*\*404 Not Found\*\*: Session not found.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred.

```json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/{session_id}":{"put":{"operationId":"session-management_sessions_update","summary":"Update Session Data","description":"Updates session details (such as title and created_at timestamp) for a specific session. Requires admin privileges and a valid payment plan.\n\n### Path Parameter\n- **session_id** *(string, required)*: The unique session identifier.\n\n### Request Body (JSON)\n- **title** *(string, optional)*: The updated title for the session.\n- **created_at** *(string, optional, format: `YYYY-MM-DD HH:MM:SS`)*: The updated session timestamp.\n\n### Response Structure\n\nOn success, the response contains:\n- **success** *(string)*: Confirmation that the session was updated.\n\n### Error Responses\n- **400 Bad Request**: Invalid request parameters or missing required data.\n- **401 Unauthorized**: Missing or invalid access token.\n- **403 Forbidden**: Insufficient privileges or invalid payment plan.\n- **404 Not Found**: Session not found.\n- **500 Internal Server Error**: An unexpected error occurred.","parameters":[{"schema":{"type":"string"},"name":"session_id","in":"path","description":"The session ID for which details will be updated.","required":true}],"responses":{"200":{"description":"Session updated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"description":"Confirmation message.","type":"string"}}}}}},"400":{"description":"Bad Request - Invalid parameters or missing data.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message explaining why the request was invalid.","type":"string"}}}}}},"401":{"description":"Unauthorized - Missing or invalid access token.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error indicating that A valid API-KEY token was not provided.","type":"string"}}}}}},"403":{"description":"Forbidden - The user does not have sufficient privileges to retrieve total metrics.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error indicating insufficient permissions.","type":"string"}}}}}},"404":{"description":"Not Found - The specified session ID does not exist.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message indicating session was not found.","type":"string"}}}}}},"500":{"description":"Internal Server Error - An unexpected issue occurred on the server.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message for debugging.","type":"string"}}}}}}},"tags":["session-management"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"description":"New title for the session.","type":"string"},"created_at":{"description":"Updated session timestamp in `YYYY-MM-DD HH:MM:SS` format.","type":"string","format":"date-time"}}}}},"required":true}}}}}
```

## Delete a Session

> Deletes a specified session and all associated resources, including session data, video files, subcollections, and reports.\
> \
> \### Path Parameter\
> \- \*\*session\_id\*\* \*(string, required)\*: The unique session identifier.\
> \
> \### Response Structure\
> \
> On success, the response contains:\
> \- \*\*success\*\* \*(string)\*: Confirmation that the session was deleted.\
> \
> \### Error Responses\
> \- \*\*400 Bad Request\*\*: Invalid request parameters.\
> \- \*\*401 Unauthorized\*\*: Token is invalid or missing.\
> \- \*\*403 Forbidden\*\*: User does not have admin privileges.\
> \- \*\*404 Not Found\*\*: Session not found.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred.

```json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/{session_id}":{"delete":{"operationId":"session-management_sessions_delete","summary":"Delete a Session","description":"Deletes a specified session and all associated resources, including session data, video files, subcollections, and reports.\n\n### Path Parameter\n- **session_id** *(string, required)*: The unique session identifier.\n\n### Response Structure\n\nOn success, the response contains:\n- **success** *(string)*: Confirmation that the session was deleted.\n\n### Error Responses\n- **400 Bad Request**: Invalid request parameters.\n- **401 Unauthorized**: Token is invalid or missing.\n- **403 Forbidden**: User does not have admin privileges.\n- **404 Not Found**: Session not found.\n- **500 Internal Server Error**: An unexpected error occurred.","parameters":[{"schema":{"type":"string"},"name":"session_id","in":"path","description":"The session ID to be deleted.","required":true}],"responses":{"200":{"description":"Session deleted successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"description":"Confirmation message.","type":"string"}}}}}},"400":{"description":"Bad Request - Invalid parameters or missing data.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message explaining why the request was invalid.","type":"string"}}}}}},"401":{"description":"Unauthorized - Token is invalid or expired.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Authentication error.","type":"string"}}}}}},"403":{"description":"Forbidden - User lacks necessary privileges.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Authorization error.","type":"string"}}}}}},"404":{"description":"Not Found - The specified session ID does not exist.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message indicating session was not found.","type":"string"}}}}}},"500":{"description":"Internal Server Error - An unexpected issue occurred on the server.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"description":"Error message for debugging.","type":"string"}}}}}}},"tags":["session-management"]}}}}
```

## Retrieve Analyzed Video URL

> Retrieves the analyzed video URL for a specific session, or attempts to create it if it does not exist.\
> \
> \### Path Parameter\
> \- \*\*session\_id\*\* \*(string, required)\*: The unique identifier of the session.\
> \
> \### Query Parameters\
> These optional flags determine which kind of analysis to perform if the video doesn't exist:\
> \- \*\*is\_jump\*\* \*(boolean, optional)\*: Indicates whether this session is for jump analysis.\
> \- \*\*is\_weight\*\* \*(boolean, optional)\*: Indicates whether this session is for weightlifting analysis.\
> \- \*\*download\*\* \*(boolean, optional)\*: If \`true\`, returns a signed URL that forces the browser to download the video instead of displaying it.\
> \
> \### Response (HTTP 200)\
> \
> Returns a JSON object with an \`analyzed\_video\_url\` key if successful:\
> \
> \`\`\`json\
> {\
> &#x20; "analyzed\_video\_url": "<https://storage.googleapis.com/.../analyzed\\_video.mp4"\\>
> }\
> \`\`\`\
> \
> \### Error Handling\
> \
> \- \*\*400 Bad Request\*\*: Invalid parameters (e.g., missing or invalid admin UID).\
> \- \*\*401 Unauthorized\*\*: Token is missing or invalid.\
> \- \*\*403 Forbidden\*\*: The user does not have the right privileges or plan.\
> \- \*\*404 Not Found\*\*: The session data or resources could not be found.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred on the server.\
> \
> \### Security\
> A valid API-KEY token must be provided in the \`Authorization\` header.

````json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/{session_id}/analyzed-video/":{"get":{"operationId":"session-management_sessions_analyzed-video_list","summary":"Retrieve Analyzed Video URL","description":"Retrieves the analyzed video URL for a specific session, or attempts to create it if it does not exist.\n\n### Path Parameter\n- **session_id** *(string, required)*: The unique identifier of the session.\n\n### Query Parameters\nThese optional flags determine which kind of analysis to perform if the video doesn't exist:\n- **is_jump** *(boolean, optional)*: Indicates whether this session is for jump analysis.\n- **is_weight** *(boolean, optional)*: Indicates whether this session is for weightlifting analysis.\n- **download** *(boolean, optional)*: If `true`, returns a signed URL that forces the browser to download the video instead of displaying it.\n\n### Response (HTTP 200)\n\nReturns a JSON object with an `analyzed_video_url` key if successful:\n\n```json\n{\n  \"analyzed_video_url\": \"https://storage.googleapis.com/.../analyzed_video.mp4\"\n}\n```\n\n### Error Handling\n\n- **400 Bad Request**: Invalid parameters (e.g., missing or invalid admin UID).\n- **401 Unauthorized**: Token is missing or invalid.\n- **403 Forbidden**: The user does not have the right privileges or plan.\n- **404 Not Found**: The session data or resources could not be found.\n- **500 Internal Server Error**: An unexpected error occurred on the server.\n\n### Security\nA valid API-KEY token must be provided in the `Authorization` header.","parameters":[{"schema":{"type":"string"},"name":"session_id","in":"path","description":"The session ID for which to retrieve or create an analyzed video.","required":true},{"schema":{"type":"boolean"},"name":"is_jump","in":"query","description":"Indicates whether this session is for jump analysis.","required":false},{"schema":{"type":"boolean"},"name":"is_weight","in":"query","description":"Indicates whether this session is for weightlifting analysis.","required":false},{"schema":{"type":"boolean"},"name":"download","in":"query","description":"If true, returns a signed URL that forces download of the video.","required":false}],"responses":{"200":{"description":"Analyzed video URL retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"analyzed_video_url":{"description":"URL of the analyzed video.","type":"string","format":"uri"}}}}}},"400":{"description":"Bad Request - Possibly invalid parameters.","content":{"application/json":{"schema":{"description":"Error schema for invalid requests (e.g., malformed UID)","type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Unauthorized - Token is invalid or missing.","content":{"application/json":{"schema":{"description":"Error schema for missing or invalid token","type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Forbidden - User lacks privileges or plan.","content":{"application/json":{"schema":{"description":"Error schema for forbidden access","type":"object","properties":{"error":{"type":"string"}}}}}},"404":{"description":"Not Found - Session data or resource not found.","content":{"application/json":{"schema":{"description":"Error schema for missing session or resource","type":"object","properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal Server Error - A server-side error occurred.","content":{"application/json":{"schema":{"description":"Error schema for unexpected server failures","type":"object","properties":{"error":{"type":"string"}}}}}}},"tags":["session-management"]}}}}
````

## Upload/Generate Analyzed Video

> Uploads or generates an analyzed video for a specific session, returning its URL.\
> \
> \### Path Parameter\
> \- \*\*session\_id\*\* \*(string, required)\*: The unique identifier of the session.\
> \
> \### Request Body (JSON)\
> \`\`\`json\
> {\
> &#x20; "is\_jump": true,\
> &#x20; "is\_weight": false\
> }\
> \`\`\`\
> \- \*\*is\_jump\*\* \*(boolean, optional)\*: If true, treat this as a jump session.\
> \- \*\*is\_weight\*\* \*(boolean, optional)\*: If true, treat this as a weightlifting session.\
> \
> \### Response Structure (HTTP 200)\
> On success, returns a JSON object with the \`analyzed\_video\_url\`:\
> \
> \`\`\`json\
> {\
> &#x20; "analyzed\_video\_url": "<https://storage.googleapis.com/.../analyzed\\_video.mp4"\\>
> }\
> \`\`\`\
> \### Error Handling\
> \
> \- \*\*400 Bad Request\*\*: Invalid parameters or session already analyzed.\
> \- \*\*401 Unauthorized\*\*: Token is missing or invalid.\
> \- \*\*403 Forbidden\*\*: The user does not have a valid plan.\
> \- \*\*404 Not Found\*\*: Session data not found.\
> \- \*\*500 Internal Server Error\*\*: An unexpected error occurred on the server.\
> \
> \### Security\
> A valid API-KEY token must be provided in the \`Authorization\` header.

````json
{"openapi":"3.1.1","info":{"title":"AIKYNETIX WEB API","version":"v2"},"servers":[{"url":"https://api.aikynetix.app"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","name":"Authorization","in":"header","description":"Enter your bearer token (Firebase auth) in the format: Bearer <token>"},"ApiKeyAuth":{"type":"apiKey","name":"API-KEY","in":"header","description":"Enter your API key in the header: API-KEY: <api_key>"}}},"paths":{"/session-management/sessions/{session_id}/analyzed-video/":{"post":{"operationId":"session-management_sessions_analyzed-video_create","summary":"Upload/Generate Analyzed Video","description":"Uploads or generates an analyzed video for a specific session, returning its URL.\n\n### Path Parameter\n- **session_id** *(string, required)*: The unique identifier of the session.\n\n### Request Body (JSON)\n```json\n{\n  \"is_jump\": true,\n  \"is_weight\": false\n}\n```\n- **is_jump** *(boolean, optional)*: If true, treat this as a jump session.\n- **is_weight** *(boolean, optional)*: If true, treat this as a weightlifting session.\n\n### Response Structure (HTTP 200)\nOn success, returns a JSON object with the `analyzed_video_url`:\n\n```json\n{\n  \"analyzed_video_url\": \"https://storage.googleapis.com/.../analyzed_video.mp4\"\n}\n```\n### Error Handling\n\n- **400 Bad Request**: Invalid parameters or session already analyzed.\n- **401 Unauthorized**: Token is missing or invalid.\n- **403 Forbidden**: The user does not have a valid plan.\n- **404 Not Found**: Session data not found.\n- **500 Internal Server Error**: An unexpected error occurred on the server.\n\n### Security\nA valid API-KEY token must be provided in the `Authorization` header.","parameters":[{"schema":{"type":"string"},"name":"session_id","in":"path","description":"The session ID for which to upload/generate an analyzed video.","required":true}],"responses":{"200":{"description":"Analyzed video URL generated or updated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"analyzed_video_url":{"description":"URL of the newly generated or updated analyzed video.","type":"string","format":"uri"}}}}}},"400":{"description":"Bad Request - Possibly invalid session data or video already analyzed.","content":{"application/json":{"schema":{"description":"Error schema for invalid requests or already analyzed video","type":"object","properties":{"error":{"type":"string"}}}}}},"401":{"description":"Unauthorized - The token is missing or invalid.","content":{"application/json":{"schema":{"description":"Error schema for missing or invalid token","type":"object","properties":{"error":{"type":"string"}}}}}},"403":{"description":"Forbidden - The user does not have a valid payment plan.","content":{"application/json":{"schema":{"description":"Error schema for insufficient plan privileges","type":"object","properties":{"error":{"type":"string"}}}}}},"404":{"description":"Not Found - Session not found or creation failed.","content":{"application/json":{"schema":{"description":"Error schema for missing session data or resource","type":"object","properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal Server Error - A server-side error occurred.","content":{"application/json":{"schema":{"description":"Error schema for unexpected server failures","type":"object","properties":{"error":{"type":"string"}}}}}}},"tags":["session-management"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"is_jump":{"description":"Whether this session is jump-related.","type":"boolean"},"is_weight":{"description":"Whether this session is weightlifting-related.","type":"boolean"}}}}},"required":true}}}}}
````


---

# 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.aikynetix.app/api-documentation/developer-resources-and-api-reference/api-reference/v.2/session-management.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.
