> For the complete documentation index, see [llms.txt](https://docs.appetize.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appetize.io/rest-api/sessions.md).

# Sessions

## Get sessions

> Gets sessions. Query parameters can be used for filtering sessions.

```json
{"openapi":"3.0.3","info":{"title":"Appetize V2 API Reference","version":"2"},"servers":[{"url":"https://api.appetize.io"}],"security":[{"jwt":[]},{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"Use an API token for authentication via X-API-KEY header"}},"schemas":{"Pagination":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"nextPage":{"type":"number","nullable":true,"format":"int32"}}},"SessionLog":{"type":"object","properties":{"targetId":{"type":"string"},"sessionRequestedTime":{"type":"string","format":"date-time","nullable":true},"startTime":{"type":"string","format":"date-time","nullable":true},"userConnectedTime":{"type":"string","format":"date-time","nullable":true},"frameTime":{"type":"string","format":"date-time","nullable":true},"appLaunchTime":{"type":"string","format":"date-time","nullable":true},"endTime":{"type":"string","format":"date-time","nullable":true},"closeTime":{"type":"string","format":"date-time","nullable":true},"sessionLengthSeconds":{"type":"number"},"queueTimeSeconds":{"type":"number"},"referrer":{"type":"string","nullable":true},"referrerHostname":{"type":"string","nullable":true},"sessionToken":{"type":"string","nullable":false},"clientLanguage":{"type":"string","nullable":true},"clientUserAgent":{"type":"string","nullable":true},"versionCode":{"type":"number"},"device":{"type":"string"},"osVersion":{"type":"string"},"rotation":{"type":"number"},"debug":{"type":"boolean"},"proxy":{"type":"string","nullable":true},"warmSession":{"type":"boolean"},"queued":{"type":"boolean"},"noVideo":{"type":"boolean"},"location":{"type":"array","items":{"type":"number"}},"user":{"type":"string","nullable":true},"userCountry":{"type":"string"},"userCity":{"type":"string"},"userAgent":{"type":"string","nullable":true},"platform":{"type":"string"},"params":{"type":"object","additionalProperties":true},"target":{"type":"object","properties":{"name":{"type":"string","nullable":true},"id":{"type":"string","nullable":true},"versionCode":{"type":"string","nullable":true},"versionName":{"type":"string","nullable":true},"appId":{"type":"string","nullable":true},"bundle":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}}}}}},"Error":{"type":"object","properties":{"message":{"description":"Error message.","type":"string"}}}}},"paths":{"/v2/sessions":{"get":{"tags":["Sessions"],"summary":"Get sessions","description":"Gets sessions. Query parameters can be used for filtering sessions.","parameters":[{"name":"page","in":"query","description":"The page number of results","schema":{"type":"integer"}},{"name":"limit","in":"query","description":"The number of results to return per page","schema":{"type":"integer","default":50}},{"name":"startDate","in":"query","description":"The start date of the report (UTC time & inclusive).","required":true,"schema":{"type":"string","format":"date","default":"12 months prior to today"}},{"name":"endDate","in":"query","description":"The end date of the report (UTC time & inclusive).","required":false,"schema":{"type":"string","format":"date","default":"today"}},{"name":"search","in":"query","description":"Text search for sessions. Can be build id, app id, app name, etc.","required":false,"schema":{"type":"string"}},{"name":"targetId","in":"query","description":"Only include sessions for this target ID","required":false,"schema":{"type":"string"}},{"name":"appId","in":"query","description":"Only include sessions for this App ID","required":false,"schema":{"type":"string"}},{"name":"bundle","in":"query","description":"Only include sessions for this bundle","required":false,"schema":{"type":"string"}},{"name":"buildTags","in":"query","description":"Only include builds with these tags","schema":{"type":"string"}},{"name":"buildVersionName","in":"query","description":"Only include builds with this version name","schema":{"type":"string"}},{"name":"device","in":"query","description":"Only include sessions that used this device","required":false,"schema":{"type":"string"}},{"name":"platform","in":"query","description":"Only include sessions for this platform","required":false,"schema":{"type":"string","enum":["ios","android"]}},{"name":"osVersion","in":"query","description":"Only include sessions that used this osVersion. Can be specific version or just major.","required":false,"schema":{"type":"string"}},{"name":"users","in":"query","description":"Only include sessions from these users. Must be admin role, otherwise this will always be yourself.","required":false,"schema":{"type":"string"}},{"name":"sessionToken","in":"query","description":"Find the session by token","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","description":"Sort sessions by this field","required":false,"schema":{"type":"string","enum":["targetId","appId","bundle","buildVersionName","device","platform","osVersion","users","sessionToken","startTime"],"default":"startTime"}},{"name":"order","in":"query","description":"Order the sort by ascending or descending","required":false,"schema":{"type":"string","enum":["asc","desc"],"default":"desc"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Pagination"},{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/SessionLog"}}}}]}},"text/csv":{"schema":{"type":"string","description":"All properties from the JSON response, only in csv format."}}}},"400":{"description":"Invalid query parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{}}},"406":{"description":"Unsupported Accept header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Get session attachment

> Gets a session attachment

```json
{"openapi":"3.0.3","info":{"title":"Appetize V2 API Reference","version":"2"},"servers":[{"url":"https://api.appetize.io"}],"security":[{"jwt":[]},{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"Use an API token for authentication via X-API-KEY header"}},"schemas":{"Error":{"type":"object","properties":{"message":{"description":"Error message.","type":"string"}}}}},"paths":{"/v2/sessions/{sessionToken}/attachment":{"get":{"tags":["Sessions"],"summary":"Get session attachment","description":"Gets a session attachment","parameters":[{"name":"sessionToken","in":"path","description":"The session token of the session to get the attachment for","required":true,"schema":{"type":"string"}},{"name":"type","in":"query","description":"The type of attachment to get","required":true,"schema":{"type":"string","enum":["network-captures","debug-logs"]}}],"responses":{"307":{"description":"Redirect to the attachment file","headers":{"Location":{"content":{"text/plain":{"schema":{"type":"string","enum":["/session/attachment/path"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```
