> For the complete documentation index, see [llms.txt](https://clients.medianova.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clients.medianova.com/products/security/security-token/parametric-secure-token.md). Agents can also search and read this documentation through its [MCP server](https://clients.medianova.com/~gitbook/mcp).

# Parametric Secure Token

Learn how to configure Parametric Secure Token and control which URL values are protected by a signature.

Parametric Secure Token protects CDN content using signed URLs with expiration times. You can include the requested file path in the signature or generate a token that works across the entire CDN Resource.

You can also include the `ri` and `rs` rate parameters in the signature when network rate limiting is enabled.

## How Parametric Secure Token works

Parametric Secure Token generates an MD5 signature using a secret key, an expiration timestamp, and optional request values.

Your application generates the signed URL. Medianova CDN recalculates the signature using the configured Token Key and validates the expiration time.

The signing behavior depends on two settings:

| Setting                    | Enabled                                                | Disabled                                                              |
| -------------------------- | ------------------------------------------------------ | --------------------------------------------------------------------- |
| **Token URI**              | Includes the file path in the signature.               | Excludes the file path, allowing the token to cover the CDN Resource. |
| **Rate parameter signing** | Includes the values of `ri` and `rs` in the signature. | Excludes `ri` and `rs` from the signature.                            |

These options let you select the values protected against modification.

{% hint style="warning" %}
When Token URI is disabled, a valid token can authorize any file path within the CDN Resource until expiration.
{% endhint %}

### Understand the signing options

| Token URI | Rate parameter signing | Signed values                         |
| --------- | ---------------------- | ------------------------------------- |
| Enabled   | Disabled               | Key + path + expiration               |
| Disabled  | Disabled               | Key + expiration                      |
| Enabled   | Enabled                | Key + path + expiration + `ri` + `rs` |
| Disabled  | Enabled                | Key + expiration + `ri` + `rs`        |

All values are concatenated without separators.

## Supported CDN Resource types

Parametric Secure Token is available for:

| CDN Resource type | Availability  |
| ----------------- | ------------- |
| Small CDN         | Supported     |
| Large CDN         | Supported     |
| Large Streaming   | Not supported |
| Streaming         | Not supported |
| VOD               | Not supported |
| Dynamic CDN       | Not supported |

## Configure Parametric Secure Token

Use the [Medianova Control Panel](https://cloud.medianova.com) to configure Parametric Secure Token for a supported CDN Resource.

{% stepper %}
{% step %}

### Select a CDN Resource

Open the CDN Resource you want to protect in the [Medianova Control Panel](https://cloud.medianova.com).
{% endstep %}

{% step %}

### Open Security settings

Navigate to **Security → General**.
{% endstep %}

{% step %}

### Enable Security Token

Enable **Security Token**.
{% endstep %}

{% step %}

### Select Parametric Secure Token

Choose **Parametric Secure Token** from **Token Type**.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2FMCgGd3BqNY6xy2NWGZEM%2Fimage.png?alt=media&amp;token=88cdec33-5d9e-496b-8afc-1430a69f5a57" alt=""><figcaption><p>Parametric Secure Token configuration in the Medianova Control Panel.</p></figcaption></figure>
{% endstep %}

{% step %}

### Configure the Token Key

Enter a secret key in **Token Key**.

Use 8–64 alphanumeric characters. A randomly generated key of at least 32 characters is recommended.
{% endstep %}

{% step %}

### Configure Token URI

Enable **Token URI** to include the file path in the signature.

Disable it only when the token must authorize all paths within the CDN Resource.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2FaqdhTw3ynUkOX1XQZdIl%2Fimage.png?alt=media&amp;token=d5af114a-4676-41ed-9e30-586b24607d81" alt="" width="553"><figcaption><p>Signing inputs with Token URI enabled and disabled.</p></figcaption></figure>
{% endstep %}

{% step %}

### Configure rate parameter signing

Enable the rate parameter signing option when your CDN Resource uses the supported network rate limiting feature.
{% endstep %}

{% step %}

### Save the configuration

Click **Save** to apply the settings.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Keep your Token Key confidential. Changing the key invalidates URLs generated with the previous key.
{% endhint %}

## Generate a signed URL

Parametric Secure Token uses two required query parameters.

<table><thead><tr><th width="280.5">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>st</code></td><td>MD5 signature encoded using Base64URL without padding.</td></tr><tr><td><code>e</code></td><td>Expiration time as a Unix timestamp in seconds.</td></tr></tbody></table>

When rate parameter signing is enabled, the URL also includes `ri` and `rs`.

The signing input must match the options configured for the CDN Resource.

### Generate a path-based signature

When Token URI is enabled, include the requested file path.

Use this formula:

```
st = base64url(MD5(KEY + PATH + EXPIRATION))
```

Where:

* `KEY` is the configured Token Key.
* `PATH` is the requested file path, beginning with `/`.
* `EXPIRATION` is the Unix expiration timestamp.

Concatenate the values without separators.

**Verify the path-based example**

Use the following test values:

| Input           | Value                   |
| --------------- | ----------------------- |
| Token Key       | `ExampleKey2026`        |
| File path       | `/videos/sample.mp4`    |
| Expiration      | `1798761600`            |
| Expiration date | 2027-01-01 00:00:00 UTC |

The signed string is:

```
ExampleKey2026/videos/sample.mp41798761600
```

The expected signature is:

```
xxUT-FCjC3EMOW_pjtmJ1g
```

The resulting URL is:

```
https://cdn.example.com/videos/sample.mp4?st=xxUT-FCjC3EMOW_pjtmJ1g&e=1798761600
```

The signature protects the requested file path. A different file path requires a new signature.

### Generate a path-independent signature

When Token URI is disabled, exclude the file path from the signature.

Use this formula:

```
st = base64url(MD5(KEY + EXPIRATION))
```

**Verify the path-independent example**

Use the following values:

| Input           | Value                   |
| --------------- | ----------------------- |
| Token Key       | `ExampleKey2026`        |
| Expiration      | `1798761600`            |
| Expiration date | 2027-01-01 00:00:00 UTC |

The signed string is:

```
ExampleKey20261798761600
```

The expected signature is:

```
QnM1knHP9LpXljy-zd8PbQ
```

The resulting URL is:

```
https://cdn.example.com/videos/sample.mp4?st=QnM1knHP9LpXljy-zd8PbQ&e=1798761600
```

The same token can authorize other paths within the CDN Resource until expiration.

{% hint style="warning" %}
The example key is for testing only. Never use it to protect production content.
{% endhint %}

## Sign rate parameters

Parametric Secure Token can include the values of `ri` and `rs` in the signature.

Use this option only when the CDN Resource has the required network rate limiting configuration.

When rate parameter signing is enabled, append the values of `ri` and `rs` to the signed string after the expiration timestamp.

### Sign rate parameters with Token URI enabled

Use this formula:

```
st = base64url(MD5(KEY + PATH + EXPIRATION + RI + RS))
```

Where:

* `RI` is the value of the `ri` query parameter.
* `RS` is the value of the `rs` query parameter.

The values must appear in the order `ri`, then `rs`.

For example:

| Input      | Value                |
| ---------- | -------------------- |
| Token Key  | `ExampleKey2026`     |
| File path  | `/videos/sample.mp4` |
| Expiration | `1798761600`         |
| `ri`       | `100`                |
| `rs`       | `200`                |

The signed string is:

```
ExampleKey2026/videos/sample.mp41798761600100200
```

The expected signature is:

```
POPFPTJdEZdvW0zi5m7EgQ
```

The resulting URL is:

```
https://cdn.example.com/videos/sample.mp4?st=POPFPTJdEZdvW0zi5m7EgQ&e=1798761600&ri=100&rs=200
```

Changing either rate parameter value invalidates the signature.

### Sign rate parameters with Token URI disabled

Exclude the file path but retain both rate parameter values.

Use this formula:

```
st = base64url(MD5(KEY + EXPIRATION + RI + RS))
```

The resulting token is path-independent, but its signature still protects the included rate parameter values.

{% hint style="warning" %}
Do not enable rate parameter signing unless the required network rate limiting feature is enabled for the CDN Resource. The source implementation rejects unsupported configurations.
{% endhint %}

## Generate signed URLs with Python

The following example supports path-based signing, path-independent signing, and optional rate parameter signing.

It reads the Token Key from an environment variable and generates a URL valid for one hour.

```python
import base64
import hashlib
import os
import time
from urllib.parse import urlencode


def sign_url(
    base_url: str,
    path: str,
    key: str,
    ttl: int,
    token_uri: bool = True,
    ri: str | None = None,
    rs: str | None = None,
) -> str:
    expiration = int(time.time()) + ttl

    if (ri is None) != (rs is None):
        raise ValueError(
            "Provide both ri and rs, or neither."
        )

    signed_data = key

    if token_uri:
        signed_data += path

    signed_data += str(expiration)

    parameters = {"e": str(expiration)}

    if ri is not None and rs is not None:
        signed_data += ri + rs
        parameters["ri"] = ri
        parameters["rs"] = rs

    digest = hashlib.md5(
        signed_data.encode("utf-8")
    ).digest()

    signature = (
        base64.urlsafe_b64encode(digest)
        .rstrip(b"=")
        .decode("ascii")
    )

    parameters = {
        "st": signature,
        **parameters,
    }

    return (
        f"{base_url}{path}?"
        f"{urlencode(parameters)}"
    )


url = sign_url(
    base_url="https://cdn.example.com",
    path="/videos/sample.mp4",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    token_uri=True,
)

print(url)
```

Set `MN_TOKEN_KEY` to the Token Key configured in the Medianova Control Panel.

Replace the example hostname and file path with your actual CDN Resource values.

Set `token_uri` to match the Token URI setting.

When rate parameter signing is enabled, pass both values as strings:

```python
url = sign_url(
    base_url="https://cdn.example.com",
    path="/videos/sample.mp4",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    token_uri=True,
    ri="100",
    rs="200",
)
```

The signature uses the raw 16-byte MD5 digest encoded with Base64URL. Remove trailing `=` padding characters.

{% hint style="info" %}
Generate signed URLs on your application backend. Never expose the Token Key in client-side code or public repositories.
{% endhint %}

## Follow path and parameter rules

### Match the requested path

When Token URI is enabled, sign the exact file path requested by the viewer.

| Rule                      | Example                                        |
| ------------------------- | ---------------------------------------------- |
| Begin the path with `/`.  | `/videos/sample.mp4`                           |
| Exclude the hostname.     | Sign `/videos/sample.mp4`, not the full URL.   |
| Exclude query parameters. | Sign `/video.mp4` for `/video.mp4?quality=hd`. |
| Sign the decoded path.    | Sign `/my file.mp4` for `/my%20file.mp4`.      |
| Preserve letter case.     | `/Video.mp4` differs from `/video.mp4`.        |

When Token URI is disabled, the path is not part of the signature.

### Protect the required query parameters

By default, Parametric Secure Token signs the expiration timestamp and, optionally, the file path.

Other query parameters are not protected unless they are explicitly included by the token type.

When rate parameter signing is enabled, the signature also protects `ri` and `rs`.

For example:

```
https://cdn.example.com/video.mp4?st=<SIGNATURE>&e=<EXPIRATION>&ri=<RI>&rs=<RS>
```

Replace the placeholders with the generated signature, expiration timestamp, and rate parameter values.

Do not change any signed value after generating the signature.

{% hint style="info" %}
Adding an unrelated query parameter does not automatically include it in the signature. Use the documented signing options to protect supported values.
{% endhint %}

## Manage token expiration

The `e` parameter defines the expiration time as a Unix timestamp in seconds.

Calculate the expiration using the current Unix time and the required validity period.

For example, a one-hour token uses:

```
EXPIRATION = CURRENT_UNIX_TIME + 3600
```

Use a synchronized system clock when generating signatures.

After expiration, the CDN rejects new requests using the expired token.

A request started before expiration can complete. However, a new request requires a valid token.

{% hint style="info" %}
Use UTC-based Unix timestamps. The existing technical guide recommends keeping the Token Timezone setting at UTC.
{% endhint %}

## Deploy Parametric Secure Token safely

Prepare your application before enabling token enforcement.

{% stepper %}
{% step %}

### Generate a Token Key

Create a secure key and store it in your application's secret management system.
{% endstep %}

{% step %}

### Implement URL signing

Add Parametric Secure Token signature generation to your backend.
{% endstep %}

{% step %}

### Validate the signing implementation

Compare the generated signatures with the worked examples on this page.
{% endstep %}

{% step %}

### Deploy signed URLs

Update your application to distribute signed URLs with the configured signing options.
{% endstep %}

{% step %}

### Configure public path exceptions

Create Page Rules for content that must remain publicly accessible.
{% endstep %}

{% step %}

### Enable Parametric Secure Token

Apply the prepared configuration in the Medianova Control Panel.
{% endstep %}

{% step %}

### Verify protected requests

Test valid, invalid, expired, and modified-parameter URLs.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Enabling Security Token can cause existing unsigned URLs to fail. Deploy signed URLs before enforcing token validation.
{% endhint %}

## Validate protected requests

For the validated Small CDN implementation:

| Condition                      | HTTP response                        |
| ------------------------------ | ------------------------------------ |
| Valid signature and expiration | Request proceeds to content delivery |
| Missing token                  | 403 Forbidden                        |
| Invalid signature              | 403 Forbidden                        |
| Modified signed rate parameter | 403 Forbidden                        |
| Expired token                  | 410 Gone                             |

A successful token validation does not guarantee an HTTP 200 response. Content availability and other CDN settings still affect the final response.

## Troubleshoot Parametric Secure Token

### HTTP 403 Forbidden

The CDN rejects requests that fail token validation.

Check the following:

* The URL contains both `st` and `e`.
* The Token Key matches the configured key.
* The Token URI setting matches the signing method.
* The signed path matches the requested path.
* The expiration value has not changed after signing.
* The rate parameter signing option matches the CDN configuration.
* The values of `ri` and `rs` have not changed after signing.
* The signed string contains no extra separators.
* The signature uses the raw MD5 digest.
* Base64URL encoding excludes `=` padding.

Compare your output with the worked signatures:

| Configuration                         | Expected signature       |
| ------------------------------------- | ------------------------ |
| Token URI enabled                     | `xxUT-FCjC3EMOW_pjtmJ1g` |
| Token URI disabled                    | `QnM1knHP9LpXljy-zd8PbQ` |
| Token URI enabled, `ri=100`, `rs=200` | `POPFPTJdEZdvW0zi5m7EgQ` |

### HTTP 410 Gone

For the validated Small CDN implementation, HTTP 410 indicates an expired token.

Generate a new signed URL with a future expiration timestamp.

Verify that your application clock is synchronized.

### A token works for unexpected paths

Check the Token URI setting.

When Token URI is disabled, the signature does not include the requested path.

Enable Token URI when each file path must have its own signature.

### Changing rate parameters causes an error

The signature may include `ri` and `rs`.

Generate a new signature using the updated values.

Do not modify signed rate parameters independently.

### The rate parameter option cannot be enabled

Verify that the required network rate limiting feature is available and enabled for the CDN Resource.

Do not send unsupported rate parameter settings through the API.

### Signed URLs stop working after a key change

Changing the Token Key invalidates URLs generated with the previous key.

Update your application's signing key and generate new URLs.

## Security recommendations

* Store Token Keys in a secure backend environment.
* Enable Token URI when file-level restrictions are required.
* Avoid path-independent signing unless the use case requires it.
* Sign `ri` and `rs` when their values must be protected.
* Select expiration periods appropriate for the content.
* Use HTTPS when delivering protected content.
* Coordinate Token Key changes with application updates.
* Test signed URLs before enabling enforcement.

{% hint style="warning" %}
Parametric Secure Token does not bind URLs to a viewer's identity, IP address, or country. Anyone with a valid URL can use it until expiration, subject to other access controls.
{% endhint %}

## Related token types

For different access requirements, consider:

* [**Standard Secure Token**](https://clients.medianova.com/products/security/security-token/standard-secure-token.md)**:** Protect individual files using path-based signatures.
* [**Secure Token v2**](https://clients.medianova.com/products/security/security-token/secure-token-v2.md)**:** Protect directories or an entire CDN Resource.
* [**Secure Token v2 – IP Lock**](https://clients.medianova.com/products/security/security-token/secure-token-v2-ip-lock.md)**:** Bind signed URLs to a client IP address.
* [**Secure Token v2 – Country Lock**](https://clients.medianova.com/products/security/security-token/secure-token-v2-country-lock.md)**:** Restrict signed URLs to a country.

{% hint style="info" %}
For general feature configuration, refer to the [Security Token](https://clients.medianova.com/products/security/security-token.md) page.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://clients.medianova.com/products/security/security-token/parametric-secure-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
