Get active sessions
client.zeroTrust.access.users.activeSessions.list(stringuserID, ActiveSessionListParams { account_id } params, RequestOptionsoptions?): SinglePage<ActiveSessionListResponse { expiration, metadata, name } >
GET/accounts/{account_id}/access/users/{user_id}/active_sessions
Get active sessions for a single user.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Get active sessions
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const activeSessionListResponse of client.zeroTrust.access.users.activeSessions.list(
'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
)) {
console.log(activeSessionListResponse.expiration);
}{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": [
{
"expiration": 1694813506,
"metadata": {
"apps": {
"foo": {
"hostname": "test.example.com",
"name": "app name",
"type": "self_hosted",
"uid": "cc2a8145-0128-4429-87f3-872c4d380c4e"
}
},
"expires": 1694813506,
"iat": 1694791905,
"nonce": "X1aXj1lFVcqqyoXF",
"ttl": 21600
},
"name": "name"
}
],
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": [
{
"expiration": 1694813506,
"metadata": {
"apps": {
"foo": {
"hostname": "test.example.com",
"name": "app name",
"type": "self_hosted",
"uid": "cc2a8145-0128-4429-87f3-872c4d380c4e"
}
},
"expires": 1694813506,
"iat": 1694791905,
"nonce": "X1aXj1lFVcqqyoXF",
"ttl": 21600
},
"name": "name"
}
],
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}