
<a name="classesapierrormd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Class: APIError

An error received from the Cobrowse API

## Extends

- `Error`

## Constructors

<a id="constructor"></a>

### Constructor

> **new APIError**(`message?`): `APIError`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `message?` | `string` |

#### Returns

`APIError`

#### Inherited from

`Error.constructor`

### Constructor

> **new APIError**(`message?`, `options?`): `APIError`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `message?` | `string` |
| `options?` | `ErrorOptions` |

#### Returns

`APIError`

#### Inherited from

`Error.constructor`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="id"></a> `id` | `string` | The internal cobrowse identifier for the error |
| <a id="status"></a> `status` | `number` | An optional HTTP status code |


<a name="classescobrowseapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Class: CobrowseAPI

The Cobrowse Agent SDK provides a way to interact with the Cobrowse APIs for a variety of use cases.
Primarily this library is designed for building a fully white-labeled version of Cobrowse, including
custom user interfaces and styling to match your own platform.

The library can be used either from the browser (most common), or a NodeJS environment. Note: not all APIs are
available when used in NodeJS.

## Extends

- `EventEmitter`

## Constructors

<a id="constructor"></a>

### Constructor

> **new CobrowseAPI**(`token?`, `options?`): `CobrowseAPI`

Create a new Agent SDK instance. An instance encapsulates information about your API location (if
using the self-hosted Cobrowse Enterprise option), and optionally, the authorization token for the
agent using the SDK.

**Options**

`api` - The url for an Enterprise Cobrowse instance. You do not need to configure this when using our global hosted service.

```javascript
const token = await myJWTGeneratingFunction()
const cobrowse = new CobrowseAPI(token, { api: 'https://cobrowse.example.com' })
```

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `token?` | `string` | The [JWT](https://docs.cobrowse.io/agent-side-integrations/json-web-tokens-jwts) for API authorization. |
| `options?` | `Record`\<`string`, `any`\> | Options for configuring this instance of CobrowseAPI. |

#### Returns

`CobrowseAPI`

#### Overrides

`EventEmitter.constructor`

## Accessors

<a id="accounts"></a>

### accounts

#### Get Signature

> **get** **accounts**(): [`AccountsAPI`](#interfacesaccountsapimd)

Namespace API for accounts.

##### Returns

[`AccountsAPI`](#interfacesaccountsapimd)

***

<a id="api"></a>

### api

#### Get Signature

> **get** **api**(): `string`

The url for the Cobrowse instance.

##### Returns

`string`

***

<a id="devices"></a>

### devices

#### Get Signature

> **get** **devices**(): [`DevicesAPI`](#interfacesdevicesapimd)

Namespace API for devices. A device in Cobrowse is how a single instance of an app or website is tracked by Cobrowse.

##### Returns

[`DevicesAPI`](#interfacesdevicesapimd)

***

<a id="license"></a>

### license

#### Get Signature

> **get** **license**(): `string`

The license key for the Cobrowse account. This uniquely identifies your account within Cobrowse, you may
choose to have different license keys for development, test, and production environments.

##### Returns

`string`

#### Set Signature

> **set** **license**(`license`): `void`

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `license` | `string` |

##### Returns

`void`

***

<a id="policies"></a>

### policies

#### Get Signature

> **get** **policies**(): [`PolicyAPI`](#interfacespolicyapimd)

Namespace API for policies.

##### Returns

[`PolicyAPI`](#interfacespolicyapimd)

***

<a id="recordings"></a>

### recordings

#### Get Signature

> **get** **recordings**(): [`SessionRecordingAPI`](#interfacessessionrecordingapimd)

Namespace API for recordings. A recording in Cobrowse represents the video and event metadata for a recorded session.

##### Returns

[`SessionRecordingAPI`](#interfacessessionrecordingapimd)

***

<a id="regions"></a>

### regions

#### Get Signature

> **get** **regions**(): [`RegionsAPI`](#interfacesregionsapimd)

Namespace API for regions. A region in Cobrowse represents a Cobrowse socket server deployment in a particular geographical region.

##### Returns

[`RegionsAPI`](#interfacesregionsapimd)

***

<a id="sessions"></a>

### sessions

#### Get Signature

> **get** **sessions**(): [`SessionsAPI`](#interfacessessionsapimd)

Namespace API for sessions. A session in Cobrowse represents a single screensharing activity with an agent.

##### Returns

[`SessionsAPI`](#interfacessessionsapimd)

***

<a id="token"></a>

### token

#### Get Signature

> **get** **token**(): `string`

The [JWT](https://docs.cobrowse.io/agent-side-integrations/json-web-tokens-jwts) for API authorization.
This token should be securely generated by your backend to authorize use of the Cobrowse APIs.

##### Returns

`string`

#### Set Signature

> **set** **token**(`token`): `void`

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |

##### Returns

`void`

***

<a id="users"></a>

### users

#### Get Signature

> **get** **users**(): [`UsersAPI`](#interfacesusersapimd)

Namespace API for users.

##### Returns

[`UsersAPI`](#interfacesusersapimd)

## Methods

<a id="attachcontext"></a>

### attachContext()

> **attachContext**(`target`): `Promise`\<[`RemoteContext`](#interfacesremotecontextmd)\>

Attach the agent context to an iframe; no JWT is required to use these APIs.
The returned context allows you to control certain elements within the iframe hosting
the screenshare. For example, you may switch the active agent tool being used, change the
session into a "full device" mode session, or just subscribe to changes in the session parameters.

```javascript
const cobrowse = new CobrowseAPI()
const frameEl = document.getElementById('myIframe')
const ctx = await cobrowse.attachContext(frameEl)

ctx.on('session.updated', (session) => {
  console.log('session was updated', session)
})
```

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `target` | `HTMLIFrameElement` | An iframe element. |

#### Returns

`Promise`\<[`RemoteContext`](#interfacesremotecontextmd)\>

- The context returns contains methods specific to controlling the iframe

***

<a id="disconnect"></a>

### disconnect()

> **disconnect**(): `void`

Disconnect any open sockets

#### Returns

`void`


<a name="interfacesaccountmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Account

Represents an account in Cobrowse.

## Extends

- `EventEmitter`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="features"></a> `features` | `Record`\<`string`, `boolean`\> | Provides the account features |
| <a id="id"></a> `id` | `string` | The unique ID for this account |
| <a id="license_key"></a> `license_key` | `string` | The license key for this account |

## Methods

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `Account`

Converts this account instance to a plain object

#### Returns

`Account`


<a name="interfacesaccountsapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: AccountsAPI

## Methods

<a id="list"></a>

### list()

> **list**(`query?`, `options?`): `Promise`\<[`Account`](#interfacesaccountmd)[]\>

List accounts

```javascript
const cobrowse = new CobrowseAPI(...)
const accounts = await cobrowse.accounts.list()
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Account`](#interfacesaccountmd)[]\>


<a name="interfacesagentmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Agent

Represents an agent

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="colour"></a> `colour` | `string` | Agent icon background colour as a hex value |
| <a id="email"></a> `email?` | `string` | Agent email address (requires `Hide agent emails` to be disabled in the Cobrowse accounts) |
| <a id="id"></a> `id` | `string` | The unique ID for the agent |
| <a id="name"></a> `name` | `string` | The agent's name |
| <a id="picture"></a> `picture?` | `string` | Optional url to a profile picture |


<a name="interfacesdevicemd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Device

Represents a device in Cobrowse. A device in Cobrowse is how a single instance of an app or website is tracked by Cobrowse.
Each website within each different browser on a user's machine will be tracked as a separate device. Devices can be listed
and filtered by support agents to find a specific user's device. Read more about
[Identifying your devices](https://docs.cobrowse.io/sdk-features/identify-your-devices) to add metadata for filtering.

```javascript
const cobrowse = new CobrowseAPI(...)
const device = await cobrowse.device.get('some device id here')
device.subscribe()
device.on('updated', d => console.log('device was updated', d))
```

### Events

## Fires

updated - The updated event will be fired when device data changes.

## Extends

- `EventEmitter`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="connectable"></a> `connectable` | `boolean` | Is the device in a state where it can accept a screenshare connection |
| <a id="custom_data"></a> `custom_data` | `Record`\<`string`, `any`\> | The metadata you have associated with this device for discoverability and filtering by agents |
| <a id="device"></a> `device` | [`DeviceInfo`](#interfacesdeviceinfomd) | The device metadata exposed by the Cobrowse SDKs |
| <a id="id"></a> `id` | `string` | The unique ID of this device, generated internally by the Cobrowse SDKs. You cannot control this value. |
| <a id="last_active"></a> `last_active` | `Date` | The last time the device was seen |
| <a id="online"></a> `online` | `boolean` | Is the device currently connected to the Cobrowse service |

## Methods

<a id="notify"></a>

### notify()

> **notify**(`args`, `query?`, `options?`): `Promise`\<`void`\>

Push a notification to the device indicating the agent wants to start a cobrowse session

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `args` | \{ `attempt?`: `number`; `session`: [`Session`](#interfacessessionmd); \} | - |
| `args.attempt?` | `number` | The attempt, defaults to 1 when omitted |
| `args.session?` | [`Session`](#interfacessessionmd) | The session to push to the device |
| `query?` | `Record`\<`string`, `string`\> | - |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) | - |

#### Returns

`Promise`\<`void`\>

***

<a id="on"></a>

### on()

> **on**(`event`, `listener`): `this`

Listen for events on this device.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `string` |
| `listener` | (`device`) => `void` |

#### Returns

`this`

#### Overrides

`EventEmitter.on`

***

<a id="subscribe"></a>

### subscribe()

> **subscribe**(): `Promise`\<`void`\>

Subscribe to changes in this device. Note: this is a browser only method and will not work from a NodeJS environment

#### Returns

`Promise`\<`void`\>

***

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `Device`

Converts this device instance to a plain object.

#### Returns

`Device`

***

<a id="unsubscribe"></a>

### unsubscribe()

> **unsubscribe**(): `void`

Unsubscribe from this device. Note: this is a browser only method and will not work from a NodeJS environment

#### Returns

`void`


<a name="interfacesdeviceinfomd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: DeviceInfo

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="app_id"></a> `app_id` | `string` | An identifier for the app being used (e.g. the domain name, or iOS app ID). |
| <a id="app_name"></a> `app_name` | `string` | The name of the app being used by the end user. |
| <a id="device"></a> `device` | `string` | The type of the device being used, e.g. iPhone or Chrome Browser. |
| <a id="device_locale"></a> `device_locale` | `string` | The preferred locale of the user's device. |
| <a id="device_timezone"></a> `device_timezone` | `string` | The timezone of the user's device. |
| <a id="full_device_control"></a> `full_device_control` | `boolean` | (Android only) Indicates whether full device remote control is currently available |
| <a id="os_version"></a> `os_version` | `string` | The OS version of the device. |
| <a id="platform"></a> `platform` | `"web"` \| `"ios"` \| `"android"` \| `"windows"` \| `"macos"` | Which platform is being used, e.g. web, ios, android, windows, macos |
| <a id="sdk_version"></a> `sdk_version` | `string` | The version of the Cobrowse SDK that the device is running |


<a name="interfacesdevicesapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: DevicesAPI

## Methods

<a id="get"></a>

### get()

> **get**(`id`, `query?`, `options?`): `Promise`\<[`Device`](#interfacesdevicemd)\>

Get a device by ID.

```javascript
const cobrowse = new CobrowseAPI(...)
const device = await cobrowse.devices.get('some device id here')
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `id` | `string` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Device`](#interfacesdevicemd)\>

***

<a id="list"></a>

### list()

> **list**(`query?`, `options?`): `Promise`\<[`Device`](#interfacesdevicemd)[]\>

List devices, optionally filter by query parameters.

Supported query parameters:

`filter_XXX` - where XXX is replaced by your customData field names. e.g. filter_user_id=abc would filter devices with `customData = { user_id: 'abc' }`

`seen_before` - only include devices that checked-in with the Cobrowse service before this date

`seen_after` - only include devices that checked-in with the Cobrowse service after this date

```javascript
const cobrowse = new CobrowseAPI(...)
const devices = await cobrowse.devices.list({ filter_user_id: 'abcdef' } })
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Device`](#interfacesdevicemd)[]\>


<a name="interfacespolicymd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Policy

Represents a policy in Cobrowse.

## Extends

- `EventEmitter`

## Methods

<a id="haspermission"></a>

### hasPermission()

> **hasPermission**(`permission`): `boolean`

Check if the policy has a specific permission

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `permission` | `string` |

#### Returns

`boolean`

***

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `Policy`

Converts this policy instance to a plain object.

#### Returns

`Policy`


<a name="interfacespolicyapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: PolicyAPI

## Methods

<a id="current"></a>

### current()

> **current**(`query?`, `options?`): `Promise`\<[`Policy`](#interfacespolicymd)\>

Get the current policy

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Policy`](#interfacespolicymd)\>


<a name="interfacesregionmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Region

Represents a Cobrowse socket server deployment in a particular geographical
region.

## Extends

- `EventEmitter`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="id"></a> `id` | `string` | The unique ID for this region |

## Methods

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `Region`

Converts this region instance to a plain object.

#### Returns

`Region`


<a name="interfacesregionsapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: RegionsAPI

## Methods

<a id="closest"></a>

### closest()

> **closest**(`query?`, `options?`): `Promise`\<[`Region`](#interfacesregionmd)\>

Get the closest geographical region

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Region`](#interfacesregionmd)\>


<a name="interfacesremotecontextmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: RemoteContext

Control Cobrowse hosted in an iframe from a parent context.  Note: these are browser only methods and will not work from a NodeJS environment

### Events

## Fires

session.updated - This event is fired when a property of the session is changed, for example full_device mode is switched on of off.

## Fires

session.metrics.updated - This event is fired when the session metrics are changed, for example the last_alive updated or there is a rtt probe update.

## Fires

screen.updated - This event is triggered when some metadata about the screen changes, for example the size or orientation. Note, this event is only available via the RemoteContext.

## Fires

error - This event is triggered when an error happens in the iframe (e.g. a license limit is hit)

## Extends

- `EventEmitter`

## Accessors

<a id="users"></a>

### users

#### Get Signature

> **get** **users**(): [`UsersAPI`](#interfacesusersapimd)

Namespace API for users.

##### Returns

[`UsersAPI`](#interfacesusersapimd)

## Methods

<a id="androidback"></a>

### androidBack()

> **androidBack**(): `Promise`\<`boolean`\>

Triggers the Android Back button

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.androidBack()
```

#### Returns

`Promise`\<`boolean`\>

***

<a id="androidhome"></a>

### androidHome()

> **androidHome**(): `Promise`\<`boolean`\>

Triggers the Android Home button

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.androidHome()
```

#### Returns

`Promise`\<`boolean`\>

***

<a id="clearannotations"></a>

### clearAnnotations()

> **clearAnnotations**(): `Promise`\<`boolean`\>

Clear all agent session annotations from the user's view.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.clearAnnotations()
```

#### Returns

`Promise`\<`boolean`\>

***

<a id="destroy"></a>

### destroy()

> **destroy**(): `void`

Destroy this remote context; stops listening for events and detaches from the iframe.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.destroy()
```

#### Returns

`void`

***

<a id="endsession"></a>

### endSession()

> **endSession**(): `Promise`\<`boolean`\>

End the current agent session.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.endSession()
```

#### Returns

`Promise`\<`boolean`\>

***

<a id="off"></a>

### off()

> **off**(`event`, `listener`): `this`

Stop listening for events in this context.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `string` |
| `listener` | (`param`) => `void` |

#### Returns

`this`

#### Overrides

`EventEmitter.off`

***

<a id="on"></a>

### on()

> **on**(`event`, `listener`): `this`

Listen for events in this context.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `string` |
| `listener` | (`param`) => `void` |

#### Returns

`this`

#### Overrides

`EventEmitter.on`

***

<a id="setfulldevice"></a>

### setFullDevice()

> **setFullDevice**(`state`): `Promise`\<`boolean`\>

Set the current state of the session full-device mode. A full device session enables
the agent to capture all screens of the user's device, not just those inside your app
or website. Initiates request or ends full-device mode. The user must approve when switching
to full device mode.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.setFullDevice('requested')
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `state` | `"off"` \| `"requested"` |

#### Returns

`Promise`\<`boolean`\>

***

<a id="setremotecontrol"></a>

### setRemoteControl()

> **setRemoteControl**(`state`): `Promise`\<`boolean`\>

Set the current state of remote control, allowing the agent to request remote control of
the user's device. Initiate or end remote control.
Note: The agent may not set the remote control state to `on` directly, they can only
set it to `requested` and the user must approve if required.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.setRemoteControl('requested')
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `state` | `"off"` \| `"requested"` \| `"on"` \| `"rejected"` |

#### Returns

`Promise`\<`boolean`\>

***

<a id="settool"></a>

### setTool()

> **setTool**(`tool`): `Promise`\<`boolean`\>

Set the tool to use in the Agent session.

```javascript
const cobrowse = new CobrowseAPI()
const ctx = cobrowse.attachContext(document.querySelector('#my-iframe-id'))
ctx.setTool('drawing')
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tool` | `"laser"` \| `"drawing"` \| `"control"` |

#### Returns

`Promise`\<`boolean`\>


<a name="interfacesrequestoptionsmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: RequestOptions

## Properties

| Property | Type |
| ------ | ------ |
| <a id="signal"></a> `signal?` | `AbortSignal` |


<a name="interfacessessionmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: Session

Represents a session in Cobrowse.

### Events

## Fires

updated - fired when a session property changes

## Fires

ended - fired when a session transitions to the `ended` state

## Extends

- `EventEmitter`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="activated"></a> `activated` | `Date` | The activation timestamp of the session. This is the time the user accepted the session. |
| <a id="agent"></a> `agent` | [`Agent`](#interfacesagentmd) | Metadata about the agent that started the session |
| <a id="agents"></a> `agents` | [`Agent`](#interfacesagentmd)[] | List of agents who viewed the session |
| <a id="calling"></a> `calling` | `"off"` \| `"requested"` \| `"on"` \| `"rejected"` | The state of the calling mode |
| <a id="code"></a> `code` | `string` | A 6 digit, human friendly code that can be used to initiate a session |
| <a id="created"></a> `created` | `Date` | The date the session was first created (this will usually be before the `activated` timestamp). |
| <a id="custom_data"></a> `custom_data` | `Record`\<`string`, `any`\> | The metadata you have associated with this session for discoverability and filtering by agents. |
| <a id="device"></a> `device` | [`DeviceInfo`](#interfacesdeviceinfomd) | Metadata about the user's device |
| <a id="ended"></a> `ended` | `Date` | The timestamp the session was ended |
| <a id="ended_reason"></a> `ended_reason` | `"device_ended"` \| `"agent_ended"` \| `"pending_timeout"` \| `"authorizing_timeout"` \| `"active_timeout"` \| `"limit_enforcement"` | The reason the session ended |
| <a id="expires"></a> `expires` | `Date` | The timestamp when the session expires |
| <a id="full_device"></a> `full_device` | `"off"` \| `"requested"` \| `"on"` \| `"rejected"` | The state of the full device mode |
| <a id="id"></a> `id` | `string` | The unique ID for this screenshare session |
| <a id="recorded"></a> `recorded` | `boolean` | Was the session recorded |
| <a id="remote_control"></a> `remote_control` | `"off"` \| `"requested"` \| `"on"` \| `"rejected"` | The state of the remote control authorization for the session |
| <a id="state"></a> `state` | `"pending"` \| `"authorizing"` \| `"active"` \| `"ended"` | The current state of the session. A session will progress through its lifecycle in this order: `pending` → (`authorizing` →) `active` → `ended`. Only session that require user consent will enter the `authorizing` state. |
| <a id="updated"></a> `updated` | `Date` | The timestamp of the last update to the session |
| <a id="virtual"></a> `virtual` | `boolean` | Whether this is a virtual session |

## Methods

<a id="end"></a>

### end()

> **end**(`state?`, `query?`, `options?`): `Promise`\<`void`\>

Ends this session.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `state?` | `"ended"` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<`void`\>

***

<a id="getrecording"></a>

### getRecording()

> **getRecording**(`query?`, `options?`): `Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

Gets the recording for this session.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

***

<a id="isactive"></a>

### isActive()

> **isActive**(): `boolean`

True if the session is active. An active session is one where the user has accepted
the screen share if required and frame are streaming to the agent

#### Returns

`boolean`

***

<a id="isauthorizing"></a>

### isAuthorizing()

> **isAuthorizing**(): `boolean`

True if the session is authorizing. An authorizing session is one where the user has
been presented with a consent dialog but has not yet agreed.

#### Returns

`boolean`

***

<a id="isended"></a>

### isEnded()

> **isEnded**(): `boolean`

True if the session is ended.

#### Returns

`boolean`

***

<a id="ispending"></a>

### isPending()

> **isPending**(): `boolean`

True if the session is pending. A pending session is the inital state, waiting for
either a device or agent to join

#### Returns

`boolean`

***

<a id="off"></a>

### off()

#### Call Signature

> **off**(`event`, `listener`): `this`

Stop listening for events on this session.

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `"ended"` |
| `listener` | (`session`) => `void` |

##### Returns

`this`

##### Overrides

`EventEmitter.off`

#### Call Signature

> **off**(`event`, `listener`): `this`

Alias for `emitter.removeListener()`.

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `"updated"` |
| `listener` | (`session`) => `void` |

##### Returns

`this`

##### Since

v10.0.0

##### Overrides

`EventEmitter.off`

***

<a id="on"></a>

### on()

#### Call Signature

> **on**(`event`, `listener`): `this`

Listen for events on this session.

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `"ended"` |
| `listener` | (`session`) => `void` |

##### Returns

`this`

##### Overrides

`EventEmitter.on`

#### Call Signature

> **on**(`event`, `listener`): `this`

Adds the `listener` function to the end of the listeners array for the event
named `eventName`. No checks are made to see if the `listener` has already
been added. Multiple calls passing the same combination of `eventName` and
`listener` will result in the `listener` being added, and called, multiple times.

```js
server.on('connection', (stream) => {
  console.log('someone connected!');
});
```

Returns a reference to the `EventEmitter`, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The `emitter.prependListener()` method can be used as an alternative to add the
event listener to the beginning of the listeners array.

```js
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
//   b
//   a
```

##### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `event` | `"updated"` | - |
| `listener` | (`session`) => `void` | The callback function |

##### Returns

`this`

##### Since

v0.1.101

##### Overrides

`EventEmitter.on`

***

<a id="recording"></a>

### ~~recording()~~

> **recording**(`query?`, `options?`): `Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

Gets the recording for this session.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

#### Deprecated

Use [getRecording](#getrecording) instead.

***

<a id="setfulldevice"></a>

### setFullDevice()

> **setFullDevice**(`state`, `query?`, `options?`): `Promise`\<`boolean`\>

Set the current state of the session full-device mode. A full device session enables
the agent to capture all screens of the user's device, not just those inside your app
or website. Initiates request or ends full-device mode. The user must approve when switching
to full device mode.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `state` | `"off"` \| `"requested"` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<`boolean`\>

***

<a id="setremotecontrol"></a>

### setRemoteControl()

> **setRemoteControl**(`state`, `query?`, `options?`): `Promise`\<`void`\>

Set the current state of remote control, allowing the agent to request remote control of
the user's device. Initiate or end remote control.
Note: The agent may not set the remote control state to `on` directly, they can only
set it to `requested` and the user must approve if required.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `state` | `"off"` \| `"requested"` \| `"on"` \| `"rejected"` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<`void`\>

***

<a id="subscribe"></a>

### subscribe()

> **subscribe**(): `Promise`\<`void`\>

Subscribe to changes in this session. Note: this is a browser only method and will not work from a NodeJS environment

#### Returns

`Promise`\<`void`\>

***

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `Session`

Converts this session instance to a plain object.

#### Returns

`Session`

***

<a id="unsubscribe"></a>

### unsubscribe()

> **unsubscribe**(): `void`

Unsubscribe from this session. Note: this is a browser only method and will not work from a NodeJS environment

#### Returns

`void`

***

<a id="update"></a>

### update()

> **update**(`state?`, `query?`, `options?`): `Promise`\<`Session`\>

Update the session

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `state?` | `Partial`\<`Pick`\<`Session`, `"state"` \| `"device"` \| `"calling"` \| `"virtual"` \| `"custom_data"` \| `"full_device"` \| `"remote_control"`\> & `object`\> | Additional state to serialize into the session |
| `query?` | `Record`\<`string`, `string`\> | Query string parameters, if any for the update endpoint |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) | - |

#### Returns

`Promise`\<`Session`\>


<a name="interfacessessionrecordingmd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: SessionRecording

Represents a session recording in Cobrowse.

## Extends

- `EventEmitter`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="id"></a> `id` | `string` | The unique ID for this recording |
| <a id="video"></a> `video` | `object` | Provides access to the video for this recording |
| `video.fetch` | `Promise`\<`any`\> | - |
| `video.url` | `Promise`\<`string`\> | - |

## Methods

<a id="destroy"></a>

### destroy()

> **destroy**(`query?`, `options?`): `Promise`\<`any`\>

Deletes this recording from the server

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<`any`\>

***

<a id="events"></a>

### events()

> **events**(): `Promise`\<`any`[]\>

Gets the list of events for this recording

#### Returns

`Promise`\<`any`[]\>

***

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `SessionRecording`

Converts this session instance to a plain object.

#### Returns

`SessionRecording`


<a name="interfacessessionrecordingapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: SessionRecordingAPI

## Methods

<a id="destroy"></a>

### destroy()

> **destroy**(`id`, `query?`, `options?`): `Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

Deletes a recording by its ID

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `id` | `string` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

***

<a id="get"></a>

### get()

> **get**(`id`, `query?`, `options?`): `Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>

Get a recording by (Session) ID

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `id` | `string` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`SessionRecording`](#interfacessessionrecordingmd)\>


<a name="interfacessessionsapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: SessionsAPI

## Methods

<a id="create"></a>

### create()

> **create**(`resource?`, `query?`, `options?`): `Promise`\<[`Session`](#interfacessessionmd)\>

Create a session, optionally passing additional query parameters.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `resource?` | `any` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Session`](#interfacessessionmd)\>

***

<a id="get"></a>

### get()

> **get**(`id`, `query?`, `options?`): `Promise`\<[`Session`](#interfacessessionmd)\>

Get a session by ID

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `id` | `string` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Session`](#interfacessessionmd)\>

***

<a id="list"></a>

### list()

> **list**(`query?`, `options?`): `Promise`\<[`Session`](#interfacessessionmd)[]\>

List sessions, optionally filter by query parameters.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | [`SessionsQuery`](#interfacessessionsquerymd) |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`Session`](#interfacessessionmd)[]\>


<a name="interfacessessionsquerymd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: SessionsQuery

## Indexable

\[`key`: `` `filter_${string}` ``\]: `string`

`filter_XXX` - where XXX is replaced by your customData field names. e.g. filter_user_id=abc would filter devices with `customData = { user_id: 'abc' }`

## Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| <a id="activated_after"></a> `activated_after?` | `Date` | `activated_after` - only include devices that were activated after this date. Useful for paging. |
| <a id="activated_before"></a> `activated_before?` | `Date` | `activated_before` - only include sessions that were activated before this date. Useful for paging. |
| <a id="agent"></a> `agent?` | `string` | `agent` - Administrator may set this to `all` to list sessions for all agents. Agent roles may only list their own sessions. |
| <a id="limit"></a> `limit?` | `number` | `limit` - Limit the number of results. |
| <a id="state"></a> `state?` | `string` \| `string`[] | `state` - Filter by session that are in one of the supported states: `pending`, `authorizing`, `active`, `ended`. |


<a name="interfacesusermd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: User

Represents a user in Cobrowse.

## Extends

- `EventEmitter`

## Properties

| Property | Type |
| ------ | ------ |
| <a id="id"></a> `id` | `string` |

## Methods

<a id="on"></a>

### on()

> **on**(`event`, `listener`): `this`

Listen for events on this user.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `event` | `"updated"` |
| `listener` | (`user`) => `void` |

#### Returns

`this`

#### Overrides

`EventEmitter.on`

***

<a id="tojson"></a>

### toJSON()

> **toJSON**(): `User`

Converts this device instance to a plain object.

#### Returns

`User`


<a name="interfacesusersapimd"></a>

[**cobrowse-agent-sdk**](../README.md)

***

# Interface: UsersAPI

## Methods

<a id="current"></a>

### current()

> **current**(`query?`, `options?`): `Promise`\<[`User`](#interfacesusermd)\>

Get the current user.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`User`](#interfacesusermd)\>

***

<a id="get"></a>

### get()

> **get**(`id`, `query?`, `options?`): `Promise`\<[`User`](#interfacesusermd)\>

Get a user by ID and optionally filter by query parameters.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `id` | `string` |
| `query?` | `Record`\<`string`, `string`\> |
| `options?` | [`RequestOptions`](#interfacesrequestoptionsmd) |

#### Returns

`Promise`\<[`User`](#interfacesusermd)\>
