> For the complete documentation index, see [llms.txt](https://emotiv.gitbook.io/cortex-library-for-mobile/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emotiv.gitbook.io/cortex-library-for-mobile/jsonapi/createvirtualheadset.md).

# createVirtualHeadset

This method lets you create a new virtual headset.

## Parameters

| Name               | Type      | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------ | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cortexToken        | `string`  | yes      | A token returned by [authorize](https://emotiv.gitbook.io/cortex-api/authentication/authorize)                                                                                                                                                                                                                                                                                                                                                                                                             |
| type               | `string`  | yes      | <p>The type of the headset to create.</p><p>The possible values are "MN8", "INSIGHT", "EPOCPLUS", "EPOCX", "EPOCFLEX".</p>                                                                                                                                                                                                                                                                                                                                                                                 |
| motionRate         | `number`  | no       | <p>If the type is "EPOCPLUS" or "EPOCX", then you must set the motion rate to 0, 32 or 64 Hertz.<br>The value 64 is only available on Android.</p><p>The default value is 0.</p>                                                                                                                                                                                                                                                                                                                           |
| name               | `string`  | no       | The name of the headset. When you call [queryHeadsets](https://emotiv.gitbook.io/cortex-api/headset/queryheadsets) you will find this name in the field `customName`                                                                                                                                                                                                                                                                                                                                       |
| powerOn            | `boolean` | no       | <p>If <code>true</code> then this virtual headset is ON. So you can see this headset in the result of <a href="https://emotiv.gitbook.io/cortex-api/headset/queryheadsets">queryHeadsets</a>.<br>If <code>false</code> then this virtual headset is OFF. It will not appear in the result of queryHeadsets. But it will still be visible in the result of <a href="/cortex-library-for-mobile/jsonapi/queryvirtualheadsets.md">queryVirtualHeadsets</a>.</p><p>The default value is <code>false</code></p> |
| battery            | `number`  | no       | <p>The battery level of the headset. It is an integer in the range \[0, 4].</p><p>The default value is zero.</p>                                                                                                                                                                                                                                                                                                                                                                                           |
| cq                 | `object`  | no       | <p>This parameter sets the contact quality of each EEG sensor of the headset. It is an object. The keys are the name of the sensors, the values are integers in the range \[0, 4].<br>Example for a MN8 headset: <code>{"T7": 4, "T8": 0}</code></p>                                                                                                                                                                                                                                                       |
| pm                 | `object`  | no       | See below.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| preRecordedSamples | `string`  | no       | See below.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| mc                 | `object`  | no       | See below.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| fe                 | `object`  | no       | See below.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

### pm and preRecordedSamples

These two parameters sets the output of the performance metric detection.

The possible value for **preRecordedSamples** are "low", "mid"," high" or an empty string.&#x20;

| Value        | Description                                                                        |
| ------------ | ---------------------------------------------------------------------------------- |
| "low"        | All the PM will output low (around 0.2) random values.                             |
| "mid"        | All the PM will output medium (around 0.5) random values.                          |
| "high"       | All the PM will output high (around 0.8) random values.                            |
| Empty string | You can use the parameter **pm** to manually set the output of each individual PM. |

The parameter **pm** is an object. Each key is the name of a PM, and each value is an object. The available PM depends on the type of the virtual headset and the version of Cortex. New PM can be added in the future.

Example for a virtual Insight headset:

```javascript
{
  "engagement": {
    "isActive": true,
    "score": 0.9
  },
  "excitement": {
    "isActive": true,
    "score": 0.25
  },
  "focus": {
    "isActive": true,
    "score": 0.4
  },
  "interest": {
    "isActive": false,
    "score": 0.0
  },
  "relaxation": {
    "isActive": true,
    "score": 0.6
  },
  "stress": {
    "isActive": true,
    "score": 0.5
  }
}
```

### mc

This parameter sets the output of the mental command detection. It is an object that contains these fields:

| Name   | Type     | Required | Description                                                                                                                                                                                                                           |
| ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| action | `string` | yes      | The name of the action. The possible values are "neutral", "push", "pull", "lift", "drop", "left", "right", "rotateLeft", "rotateRight", "rotateClockwise", "rotateCounterClockwise", "rotateForwards", "rotateReverse", "disappear". |
| power  | `number` | yes      | The power of this action. It must be a number between zero and one.                                                                                                                                                                   |

If you omit this parameter when creating the virtual headset, then the default action is "neutral", with a power of zero.

### fe

This parameter sets the output of the facial expression detection. It is an object that contains these fields:

| Name            | Type     | Required | Description                                                                              |
| --------------- | -------- | -------- | ---------------------------------------------------------------------------------------- |
| upperFaceAction | `string` | yes      | The action of the upper face. The possible values are "neutral", "frown" and "surprise". |
| lowerFaceAction | `string` | yes      | The action of the lower face. The possible values are "neutral", "clench" and "smile".   |
| upperFacePower  | `number` | yes      | The power of the upper face action. It must be a number between zero and one.            |
| lowerFacePower  | `number` | yes      | The power of the lower face action. It must be a number between zero and one.            |

If you omit this parameter when creating the virtual headset, then the default actions are "neutral", with a power of zero.

## Result

The result is a [Virtual headset object](/cortex-library-for-mobile/jsonapi/virtual-headset-object.md).

## Example

{% tabs %}
{% tab title="Request" %}

```javascript
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "createVirtualHeadset",
  "params": {
    "cortexToken": "xxx",
    "type": "INSIGHT"
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "battery": 0,
    "connectionType": "bluetooth",
    "cq": {},
    "cqStatus": "",
    "fe": {
      "lowerFaceAction": "neutral",
      "lowerFacePower": 0,
      "upperFaceAction": "neutral",
      "upperFacePower": 0
    },
    "mc": {
      "action": "neutral",
      "power": 0
    },
    "name": "",
    "ownerId": "c7f6d941-d972-496b-8504-fcc903c46f02",
    "pm": {},
    "powerOn": false,
    "preRecordedSamples": "",
    "serial": "B651BE6B",
    "type": "INSIGHT",
    "uuid": "b651be6b-135a-4c42-9075-d07b238725de"
  }
}
```

{% endtab %}
{% endtabs %}
