---
title: MediaKeys.createSession()
slug: Web/API/MediaKeys/createSession
tags:
  - API
  - EncryptedMediaExtensions
  - Experimental
  - Media
  - MediaKeys
  - Method
  - Reference
  - createSession
browser-compat: api.MediaKeys.createSession
---
{{APIRef("EncryptedMediaExtensions")}}{{SeeCompatTable}}

The `MediaKeys.createSession()` method returns a new
{{domxref("MediaKeySession")}} object, which represents a context for message exchange
with a content decryption module (CDM).

## Syntax

```js
var mediaKeySessionObject = MediaKeys.createSession([MediaKeySessionType]);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
