## Create signed URL tokens for videos `client.stream.token.create(stringidentifier, TokenCreateParamsparams, RequestOptionsoptions?): TokenCreateResponse` **post** `/accounts/{account_id}/stream/{identifier}/token` Creates a signed URL token for a video. If a body is not provided in the request, a token is created with default values. ### Parameters - `identifier: string` A Cloudflare-generated unique identifier for a media item. - `params: TokenCreateParams` - `account_id: string` Path param: The account identifier tag. - `id?: string` Body param: The optional ID of a Stream signing key. If present, the `pem` field is also required. - `accessRules?: Array` Body param: The optional list of access rule constraints on the token. Access can be blocked or allowed based on an IP, IP range, or by country. Access rules are evaluated from first to last. If a rule matches, the associated action is applied and no further rules are evaluated. - `action?: "allow" | "block"` The action to take when a request matches a rule. If the action is `block`, the signed token blocks views for viewers matching the rule. - `"allow"` - `"block"` - `country?: Array` An array of 2-letter country codes in ISO 3166-1 Alpha-2 format used to match requests. - `ip?: Array` An array of IPv4 or IPV6 addresses or CIDRs used to match requests. - `type?: "any" | "ip.src" | "ip.geoip.country"` Lists available rule types to match for requests. An `any` type matches all requests and can be used as a wildcard to apply default actions after other rules. - `"any"` - `"ip.src"` - `"ip.geoip.country"` - `downloadable?: boolean` Body param: The optional boolean value that enables using signed tokens to access MP4 download links for a video. - `exp?: number` Body param: The optional unix epoch timestamp that specficies the time after a token is not accepted. The maximum time specification is 24 hours from issuing time. If this field is not set, the default is one hour after issuing. - `nbf?: number` Body param: The optional unix epoch timestamp that specifies the time before a the token is not accepted. If this field is not set, the default is one hour before issuing. - `pem?: string` Body param: The optional base64 encoded private key in PEM format associated with a Stream signing key. If present, the `id` field is also required. ### Returns - `TokenCreateResponse` - `token?: string` The signed token used with the signed URLs feature. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.stream.token.create('ea95132c15732412d22c1476fa83f27a', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(token.token); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImU5ZGI5OTBhODI2NjZkZDU3MWM3N2Y5NDRhNWM1YzhkIn0.eyJzdWIiOiJlYTk1MTMyYzE1NzMyNDEyZDIyYzE0NzZmYTgzZjI3YSIsImtpZCI6ImU5ZGI5OTBhODI2NjZkZDU3MWM3N2Y5NDRhNWM1YzhkIiwiZXhwIjoiMTUzNzQ2MDM2NSIsIm5iZiI6IjE1Mzc0NTMxNjUifQ.OZhqOARADn1iubK6GKcn25hN3nU-hCFF5q9w2C4yup0C4diG7aMIowiRpP-eDod8dbAJubsiFuTKrqPcmyCKWYsiv0TQueukqbQlF7HCO1TV-oF6El5-7ldJ46eD-ZQ0XgcIYEKrQOYFF8iDQbqPm3REWd6BnjKZdeVrLzuRaiSnZ9qqFpGu5dfxIY9-nZKDubJHqCr3Imtb211VIG_b9MdtO92JjvkDS-rxT_pkEfTZSafl1OU-98A7KBGtPSJHz2dHORIrUiTA6on4eIXTj9aFhGiir4rSn-rn0OjPRTtJMWIDMoQyE_fwrSYzB7MPuzL2t82BWaEbHZTfixBm5A" } } ```