Sessions
Retrieve user sessions
Section titled Retrieve user sessionsReturns the list of sessions for a particular user, identified via the tracker.setUserID JavaScript function. Results are paginated.
Method
Section titled MethodPOST
/public/:projectKey/users/:userId/sessions
Parameters
Section titled Parameters| Name | Type | Description |
|---|---|---|
| projectKey | string | The project key (required) |
| userId | string | The ID set via tracker.setUserID (required, max 256) |
Payload
Section titled Payload| Name | Type | Description |
|---|---|---|
| startTimestamp | epoch (ms) | Start of time window (required, min 946684800000) |
| endTimestamp | epoch (ms) | End of time window (required, > startTimestamp) |
| limit | integer | Page size, 1-200 (optional, default: 50) |
| page | integer | Page number, starts at 1 (optional, default: 1) |
| sortOrder | string | asc or desc (optional) |
Request Headers
Section titled Request HeadersAuthorization: Bearer {YOUR_ORGANIZATION_API_KEY}
Status Codes
Section titled Status Codes200: Response sent as JSON in body
400: Invalid body or invalid userId (empty or > 256 chars)
Example Request
Section titled Example Requestcurl -X POST \
{BASE_URL}/public/3sWXSsqHgSKnE87YkNJK/users/mickael@openreplay.com/sessions \
-H 'content-type: application/json' \
-H 'Authorization: Bearer {YOUR_ORGANIZATION_API_KEY}' \
--data-raw '{
"startTimestamp": 1623440000000,
"endTimestamp": 1623540000000,
"limit": 50,
"page": 1,
"sortOrder": "desc"
}'
Example Response
Section titled Example Response{
"data": {
"total": 2,
"sessions": [
{ "sessionId": "4813018042986240", "eventsCount": 1, "startTs": 1623440822825, "endTs": 1623440835604 },
{ "sessionId": "4813023023591169", "eventsCount": 6, "startTs": 1623440902620, "endTs": 1623440920846 }
]
}
}