1. Knowledge Base
  2. Account management

How can I list active sessions?

Seeing active sessions on your account can be useful for supervising your agents. We have two ways to do this.

Listing using the Cobrowse.io dashboard

Active sessions will be shown to account Administrators at the top of the device listing page at https://cobrowse.io/dashboard, or in the dashboard of your self-hosted instance if you self-host

Listing using the Agent SDK

You can use the Agent SDK listing API to filter down to active sessions programmatically: https://docs.cobrowse.io/agent-side-integrations/agent-sdk/api-reference#list-1.
Something like the code below retrieves active session IDs, edited from sample code here: https://docs.cobrowse.io/agent-side-integrations/agent-sdk#list-devices-and-sessions-jwt-required.
You'll need to use a JWT with a "role": "administrator" claim and be authenticating to an administrator's account. Then use the following to get the session.id's of the active sessions:
const myInstance = new CobrowseSDK(generateAToken())
const [ session ] = await myInstance.sessions.list({
agent: 'all',
state: 'active',
filter_XXX: 'custom_data_filter',
filter_YYY: 'additional_custom_data_filter'
})
console.log('id =', session.id)
See our article on programmatically downloading session recordings and device metadata to also download historical session recordings or data!
Any questions? Please contact us at hello@cobrowse.io!