# unsubscribe

This method is to cancel a subscription that was previously created by the [subscribe](subscribe) method.

## Parameters

| Name        | Type               | Required | Description                                                         |
| ----------- | ------------------ | -------- | ------------------------------------------------------------------- |
| cortexToken | `string`           | yes      | A token returned by [authorize](../authentication/authorize).       |
| session     | `string`           | yes      | A session id returned by [createSession](../session/createsession). |
| streams     | `array of strings` | yes      | The data streams you want to unsubscribe to.                        |

The parameter **streams** must contain one or more values, chosen from this list: "eeg", "mot", "dev", "pow", "met", "com",  "fac", "sys". See [Data Subscription]() for details.

## Result

The result is an object that includes these fields:

| Name    | Type               | Description                                                                                                  |
| ------- | ------------------ | ------------------------------------------------------------------------------------------------------------ |
| success | `array of objects` | For each stream you successfully unsubscribed to, this array contains an object with the name of the stream. |
| failure | `array of objects` | For each stream you failed to unsubscribed to, this array contains an object that describes the error.       |

In case of success, you get an object with these fields:

| Name       | Type     | Description             |
| ---------- | -------- | ----------------------- |
| streamName | `string` | The name of the stream. |

In case of failure, you get an object with these fields:

| Name       | Type     | Description             |
| ---------- | -------- | ----------------------- |
| streamName | `string` | The name of the stream. |
| code       | `number` | The error code.         |
| message    | `string` | The error message.      |

## Examples

Unsubscribe successfully from the performance metrics and motion streams.

{% tabs %}
{% tab title="Request" %}
```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "unsubscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "c6b52ab2-8828-412c-b1b9-9c48842dc0c2",
        "streams": ["met","mot"]
    }
}
```
{% endtab %}

{% tab title="Response" %}
```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure":[],
        "success":[
            {"streamName":"met"},
            {"streamName":"mot"}
        ]
    }
}
```
{% endtab %}
{% endtabs %}
