Skip to content
Start here

Get single active session

client.zeroTrust.access.users.activeSessions.get(stringuserId, stringnonce, ActiveSessionGetParams { account_id } params, RequestOptionsoptions?): ActiveSessionGetResponse { account_id, auth_status, common_name, 16 more }
GET/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}

Get an active session for a single user.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Access: Audit Logs Read
ParametersExpand Collapse
userId: string

UUID.

maxLength36
nonce: string
params: ActiveSessionGetParams { account_id }
account_id: string

Identifier.

maxLength32
ReturnsExpand Collapse
ActiveSessionGetResponse { account_id, auth_status, common_name, 16 more }
account_id?: string
auth_status?: string
common_name?: string
device_id?: string
device_sessions?: Record<string, DeviceSessions>
last_authenticated?: number
devicePosture?: Record<string, DevicePosture>
id?: string
check?: Check { exists, path }
exists?: boolean
path?: string
data?: unknown
description?: string
error?: string
rule_name?: string
success?: boolean
timestamp?: string
type?: string
email?: string
geo?: Geo { country }
country?: string
iat?: number
idp?: IdP { id, type }
id?: string
type?: string
ip?: string
is_gateway?: boolean
is_warp?: boolean
isActive?: boolean
mtls_auth?: MTLSAuth { auth_status, cert_issuer_dn, cert_issuer_ski, 2 more }
auth_status?: string
cert_issuer_dn?: string
cert_issuer_ski?: string
cert_presented?: boolean
cert_serial?: string
service_token_id?: string
service_token_status?: boolean
user_uuid?: string
version?: number

Get single active session

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const activeSession = await client.zeroTrust.access.users.activeSessions.get(
  'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
  'X1aXj1lFVcqqyoXF',
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);

console.log(activeSession.account_id);
{
  "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": {
    "account_id": "1234567890",
    "auth_status": "NONE",
    "common_name": "",
    "device_id": "",
    "device_sessions": {
      "foo": {
        "last_authenticated": 1638832687
      }
    },
    "devicePosture": {
      "foo": {
        "id": "id",
        "check": {
          "exists": true,
          "path": "path"
        },
        "data": {},
        "description": "description",
        "error": "error",
        "rule_name": "rule_name",
        "success": true,
        "timestamp": "timestamp",
        "type": "type"
      }
    },
    "email": "test@cloudflare.com",
    "geo": {
      "country": "US"
    },
    "iat": 1694791905,
    "idp": {
      "id": "id",
      "type": "type"
    },
    "ip": "127.0.0.0",
    "is_gateway": false,
    "is_warp": false,
    "isActive": true,
    "mtls_auth": {
      "auth_status": "auth_status",
      "cert_issuer_dn": "cert_issuer_dn",
      "cert_issuer_ski": "cert_issuer_ski",
      "cert_presented": true,
      "cert_serial": "cert_serial"
    },
    "service_token_id": "",
    "service_token_status": false,
    "user_uuid": "57cf8cf2-f55a-4588-9ac9-f5e41e9f09b4",
    "version": 2
  }
}
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": {
    "account_id": "1234567890",
    "auth_status": "NONE",
    "common_name": "",
    "device_id": "",
    "device_sessions": {
      "foo": {
        "last_authenticated": 1638832687
      }
    },
    "devicePosture": {
      "foo": {
        "id": "id",
        "check": {
          "exists": true,
          "path": "path"
        },
        "data": {},
        "description": "description",
        "error": "error",
        "rule_name": "rule_name",
        "success": true,
        "timestamp": "timestamp",
        "type": "type"
      }
    },
    "email": "test@cloudflare.com",
    "geo": {
      "country": "US"
    },
    "iat": 1694791905,
    "idp": {
      "id": "id",
      "type": "type"
    },
    "ip": "127.0.0.0",
    "is_gateway": false,
    "is_warp": false,
    "isActive": true,
    "mtls_auth": {
      "auth_status": "auth_status",
      "cert_issuer_dn": "cert_issuer_dn",
      "cert_issuer_ski": "cert_issuer_ski",
      "cert_presented": true,
      "cert_serial": "cert_serial"
    },
    "service_token_id": "",
    "service_token_status": false,
    "user_uuid": "57cf8cf2-f55a-4588-9ac9-f5e41e9f09b4",
    "version": 2
  }
}