API Stability |
Long-Term
|
The sessions() GraphQL query provides paginated search results for tokens.
For information on session management, see the
Session management documentation page.
You may also want to look at session()
.
Syntax
Below is the syntax for the sessions() query field:
sessions(
searchFilter: string
skip: integer
limit: integer
onlyActiveSessions: boolean
level: Sessions__Filter_Level
sortBy: Sessions__SortBy
orderBy: OrderBy
): SessionQueryResultSet!
For the input, there are several parameters, with the choices for each special datatype. They're described in the Given Datatypes section below. What to use for the return, for SessionQueryResultSet is listed in the Results Datatypes section. For now, look at this example:
query{
sessions(
searchFilter: "company.com"
limit: 10
skip: 0
onlyActiveSessions: false
level: Organization
sortBy: User
orderBy: DESC
)
{totalResults, results {id, user{username}}}
}
{
"data": {
"sessions": {
"totalResults": 2,
"results": [
{
"id": "hOIfDrvLcC3jNP2RbZS9aYdP2j4ml6la",
"user": {
"username": "steve@company.com"
}
},
{
"id": "3bDFGc6CGGRJ7I203dG3JMg1LKs3cvZ6",
"user": {
"username": "bob@company.com"
}
}
]
}
}
}
This example is searching for sessions with users who have an email address using company.com. It includes active and inactive sessions. And sorts by users in descending order.
For the results, it's requesting the ID and username for each session.
Given Datatypes
The given datatypes are described in the table below:
Table: Mix of Input for Sessions
Parameter | Type | Required | Default | Stability | Description | |||
---|---|---|---|---|---|---|---|---|
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column. | ||||||||
Table last updated: Sep 6, 2024 | ||||||||
searchFilter | string | Text on which to search the active sessions. | ||||||
limit | integer | 50 | The maximum number of rows to return. | |||||
skip | integer | 0 | The initial number of rows to skip; display only rows after number given. | |||||
onlyActiveSessions | boolean | true | Whether to include only active sessions. | |||||
level | Sessions__Filter_level | Whether information on the session should be filtered based on the level (e.g., user level). | ||||||
Valid Values | ||||||||
Organization | Filter returned data on organization. | |||||||
User | Filter data at user level. | |||||||
sortBy | Sessions__SortBy | yes | Indicates the field by which to sort the session data returned (e.g., date and time of the last act). | |||||
Valid Values | ||||||||
ClientInfo | Sort by client information of users. | |||||||
IPAddress | Sort by IP addresses of session users. | |||||||
LastActivityTime | Sort by date and time of last act. | |||||||
Location | Sort by location of users. | |||||||
LoginTime | Sort by login times for sessions. | |||||||
User | Sort by user. | |||||||
orderBy | OrderBy | ASC | Whether the results should be returned in ascending or descending order. | |||||
Valid Values | ||||||||
ASC | In ascending order. | |||||||
DESC | In descending order. |
Returned Datatypes
The returned datatype SessionQueryResultSet
has its own parameters. Below is a list of them along with their
datatypes and a description of each:
Table: SessionQueryResultSet
Parameter | Type | Required | Default | Stability | Description |
---|---|---|---|---|---|
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column. | |||||
Table last updated: Oct 3, 2024 | |||||
results | [Session ] | yes | Long-Term | The paginated results set. See Session . | |
totalResults | integer | yes | Long-Term | The total number of matching results. |