Skip to main content

Private Videos

Restricting Playback

This guide is helpful for when you have a video you want to secure. This video could be paid content or sensitive.

By signing, even if someone has the Edge Key, they cannot play the video back.

What This Does Not Accomplish

This does not make a video bulletproof unpirate-able.

DRMs protect videos, not JWTs.

It does, however, make the process of stealing and disseminating a video much more challenging.

High-Level Workflow

  1. Lock the video. Create or update an Edge Key with isPrivate: true.
  2. Sign. Your backend code will generate a JSON Web Token (JWT) using your private signing key.
  3. Play. Take the JWT you generate and add it to the URL of the video.

Important: Tokens Are Bound to Edge Keys

Caution

Each token is strictly bound to a specific Edge Key. A token signed for edge_A will only grant access to resources requested via edge_A. It will NOT work for edge_B, even if both keys point to the same underlying video.

This design provides critical security benefits:

  • Granular Revocation: Revoking edge_A immediately invalidates all tokens for that key, without affecting edge_B.
  • Isolated Access Control: Different Edge Keys can have different access policies (e.g., one for web, one for mobile app).
  • No Cross-Key Leakage: A leaked token for one key cannot be used to access content via another key.

Practical Implication: When generating signed URLs, always use the same Edge Key in:

  1. The URL path (e.g., /v1/{edgeKey}/master.m3u8)
  2. The token claims (sub and aud must match the Edge Key)

If you store a thumbnailUrl that contains a default Edge Key, but generate a token for a different Edge Key, the request will fail. See Thumbnails for how to construct proper signed thumbnail URLs.

Step 1: Generating Your Signing Key

Under “API Keys” in your app.antcdn.net dashboard, select the option to create a new signing key.

You can choose to create a signing key which works for all your environments in your organization, or scoped to development, staging or production.

Save both the signing key and the key ID.

Step 2: Creating a JWT For Playback

When you create your JWT, there are a few arguments you should be aware of which you’ll be using in your code.

FieldTypeDescription
substringSubject. Pass through one Edge Key or ”*” to allow playback of all signed videos.
issstringIssuer. Must match the issuer you specified when creating the signing key. Your backend is the token issuer, so use your domain or app name (e.g., "my-company.com").
audstringAudience. Must match the sub (Video ID or Edge Key).
kidstringKey ID. Include the ID of the key you generated in step 1.
expiresInnumberExpiration. How long the video can be watched, in seconds.

Tip

Custom Issuer: When you create a signing key, you specify an issuer identifier. This identifier ties your tokens to your organization—use your domain name or application name. The edge verifies that the token’s iss claim matches the expected issuer for that key.

Step 3: Playing Back Your Video

From step 2 you have a string. This is your JWT.

When you embed a URL, this key must be present to play your video.

Whereas before you might have had a video look like this:

<!-- Iframe example for public video -->
<iframe
src="https://worker.antcdn.net/v1/{edgeKey}/master.m3u8"
frameborder="0"
allowfullscreen>
</iframe>

Your protected video needs to look like this:

<!------------------------- Add the key as a URL parameter here ⬇️ -->
<iframe
src="https://worker.antcdn.net/v1/{edgeKey}/master.m3u8?jwt={jwt}"
frameborder="0"
allowfullscreen>
</iframe>

Tip

For private videos, playlists, segments, thumbnails, and captions are all protected. Keep the jwt=... query param on the URLs you embed/request.

Using Other Players

Under “Playing Videos” on the left, we have a few examples of video players you can use.

With each player, you pass through a URL like:

https://player.antcdn.net/v1/{edgeKey}/master.m3u8

Similar to the iframe, add the jwt URL param like so:

https://player.antcdn.net/v1/{edgeKey}/master.m3u8?jwt={jwt}

Secure Thumbnails

When a video is secure, so is a thumbnail. Similar to videos, when referencing a private thumbnail, you must pass through the key.

Whereas before you may have used a public thumbnail URL like so:

<video
id="video"
controls
poster="https://worker.antcdn.net/v1/thumbnail/{orgID}/{envID}/{edgeKey}.png?width=1280&timeStamp=30"
></video>

Similarly to the video process, add your key as a URL parameter.

<!-- Add the key as a URL parameter here ⬇️ -->
<video
id="video"
controls
poster="https://worker.antcdn.net/v1/thumbnail/{orgID}/{envID}/{edgeKey}.png?width=1280&timeStamp=30&jwt={jwt}"
></video>