> For the complete documentation index, see [llms.txt](https://ksdaemon.gitbook.io/wampy.js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ksdaemon.gitbook.io/wampy.js/api/unsubscribe.md).

# unsubscribe()

### unsubscribe(subscriptionIdKey\[, onEvent])

Unsubscribe subscription from receiving events.

Parameters:

* **subscriptionIdKey**. Required. Subscription ID (number) or Key (string), received during .subscribe()
* **onEvent**. Published event callback instance to remove, or it can be not specified, in this case all callbacks and subscription will be removed.

Returns `promise`:

* Resolved with one hash-table parameter with following attributes:
  * **topic**
  * **requestId**
* Rejected with one of the [Errors instances](broken://pages/e80SGqRyzZXRlbWTYu1Y)

```javascript
const f1 = function (data) { console.log('this was event handler for topic') };
await ws.unsubscribe('subscribed.topic', f1);

let defer = ws.unsubscribe('chat.message.received');
```
