URL structure
Signed URLs use either a query string or path-based format:Parameters
| Parameter | Required | Description |
|---|---|---|
token | Yes | Hashed signature |
expires | Yes | UNIX timestamp in seconds when the URL becomes invalid |
token_path | No | URL-encoded path prefix for directory-level access |
token_countries | No | Comma-separated allowed country codes (ISO 3166-1) |
token_countries_blocked | No | Comma-separated blocked country codes (ISO 3166-1) |
token_ignore_params | No | When true, query parameters are excluded from token validation |
limit | No | Download speed limit in kB/s |
Directory tokens
By default, tokens are valid only for the exact URL path. Directory tokens allow access to any file within a path prefix, essential for video streaming where players request multiple segment files. Signing withtoken_path=/videos/stream1/ allows access to all files in that directory:
IP locking
IP locking binds a token to a specific client IP address. Any request from a different IP will be rejected, even if the token is otherwise valid. This is useful for preventing token sharing or URL redistribution. To use IP locking, pass the client’s IP address (IPv4 or IPv6) as theuserIp parameter when signing the URL. The IP is included in the HMAC signature but is not appended to the URL itself.
IP locking requires the Token IP Validation setting to be enabled on your Pull Zone. Enabling this without including the IP in your tokens will cause all requests to fail.
Expiration
By default, the token expiry is calculated as a relative offset from the current time usingexpirationTime (in seconds). If you need the URL to expire at a specific point in time, use expiresAt to set an absolute UTC timestamp instead. When expiresAt is set, expirationTime is ignored.
Ignore query parameters
By default, all query string parameters present on the URL are included in the token signature. If a parameter is added, removed, or changed after signing, the token will fail validation. SetignoreParams to true when you need to append arbitrary query parameters to signed URLs after generation, for example, analytics tags, cache-busting parameters, or player configuration. When enabled, the token_ignore_params=true parameter is included in the signature instead of the actual query parameters.
Speed limits
Thelimit parameter restricts the maximum download speed for the request in kB/s. Pass the desired speed as the speedLimit parameter when signing. A value of 0 means no limit.
Country restrictions
Usetoken_countries to allow access only from specific countries, or token_countries_blocked to allow all except specific countries (only one should be necessary per token). Country codes follow the ISO 3166-1 alpha-2 format (e.g. US, GB, DE).
Generate the token
security_keyis used as the HMAC key (not included in the message)signature_pathis the URL path, or thetoken_pathoverride if setsigning_datais the alphabetically-sorted parameters joined askey=valuepairs separated by&, excludingtokenandexpiresuser_ipis the optional IP address (empty string if not set)
+ with -, / with _, and remove = padding characters.
Code examples
Tested implementations are available for C#, Python, Node.js, PHP, Java, Go, and Rust in the BunnyCDN.TokenAuthentication repository.Query string vs path-based tokens
TheisDirectory parameter controls how the token is embedded in the URL:
false(query string) - the token and parameters are appended as query string parameters. Suitable for direct file downloads and simple URL signing.true(path-based) - the token is embedded in the URL path as/bcdn_token=.... This is required for HLS/DASH video delivery, where the player resolves relative segment URLs against the manifest path. Placing the token in the path ensures segment requests automatically inherit authentication without modifying the player.