> ## Documentation Index
> Fetch the complete documentation index at: https://bmdrm.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Session management

> Create one-time use streaming sessions in BMDRM using the HTTP API for a reliable, fast, and encrypted video playback.

## What You’ll Need

Before you begin, ensure you have:

* A [BMDRM](https://dev.bmdrm.com/) account ([Log in](https://dev.bmdrm.com/login) or sign up for a [free trial](https://dev.bmdrm.com/en/register)).
* Have your API key prepared. To learn how to obtain your Streaming API key, see [Obtaining your API key](/docs/bmdrm/authentication).
* The requested video to be **uploaded and ready**.

## How to create streaming sessions

Make an authenticated POST request to the following endpoint:

```bash theme={null}
POST https://cdn-lb.video-crypt.com/api/v2.0/sessions?videoId={video ID}&userId={user ID}
```

This endpoint creates sessions for both mobile and web playback.

**Headers:**

* `apiKey`: **Your Streaming API key**.
* `accept`: Must be `application/json`.

**Query Parameters:**

* `videoId`: The ID of the video to play. This is the `uploadJobId` returned during the [upload initialization step](/docs/upload/multipart#initializing-an-upload-job).
* `userId` : The user's identifier in your system. This value is rendered into the session's visible watermark.

**Example request:**

```bash theme={null}
curl --request POST \
  --url 'https://cdn-lb.video-crypt.com/api/v2.0/sessions?videoId=00f05208-a732-4b7a-a616-74d2fb51445b&userId=demo_user' \
  --header 'apiKey: <Your Streaming API key>' \
  --header 'Accept: application/json'
```

**Response schema:**

The response will return a new session object, including:

Returns `200 OK` with the new session object.

* `edge`: A CDN edge url, responsible for serving the created session (string)
* `videoId`: The ID of the requested video (uuid)
* `signature`: A session signature to be verified by BMDRM (string)
* `userId`: The user ID supplied by the client (string)
* `subscriptionId`: The corresponding ID of the client subscription (uuid)
* `sessionId`: The ID of the one-time use session (uuid)
* `nonce`: One-time use number (string)
* `date`: Timestamp of session creation (number)

<Note>
  The player needs **every field** from this response object to authenticate in the next step.
</Note>

### Session lifetime

* Each session is valid for a single playback. Requesting playback again with the same `sessionId` and `nonce` will fail.

## Web-only streaming sessions

<Warning>
  This method is deprecated. Use the [v2.0 session endpoint](#how-to-create-streaming-sessions) instead, which supports both web and mobile playback.
</Warning>

<Accordion title="View the deprecated web-only method">
  Make an authenticated POST request to the following endpoint:

  ```bash theme={null}
  POST https://cdn-lb.video-crypt.com/api/sessions?videoId={video ID}&userId={user ID}
  ```

  **Headers:**

  * `apiKey`: Your **Streaming API key**
  * `accept: application/json`

  **Query Parameters:**

  * `videoId`: The ID of the video to play. This is the `uploadJobId` returned during the [upload initialization step](/docs/upload/multipart#initializing-an-upload-job). (uuid)
  * `userId` : The user's identifier in your system. This value is rendered into the session's visible watermark. (string)

  **Example request:**

  ```bash theme={null}
  curl --request POST \
    --url 'https://cdn-lb.video-crypt.com/api/sessions?videoId=00f05208-a732-4b7a-a616-74d2fb51445b&userId=demo_user' \
    --header 'apiKey: <Your Streaming API key>' \
    --header 'Accept: application/json'
  ```

  **Response schema:**

  The response will return a web-only session object, including:

  * `urlToEdge`: A session url that could be opened independantely in the browser or [integrated in your web application](/docs/)
</Accordion>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.