# Stream
## List videos
`client.Stream.List(ctx, params) (*SinglePage[Video], error)`
**get** `/accounts/{account_id}/stream`
Lists up to 1000 videos from a single request. For a specific range, refer to the optional parameters.
### Parameters
- `params StreamListParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `Asc param.Field[bool]`
Query param: Lists videos in ascending order of creation.
- `Creator param.Field[string]`
Query param: A user-defined identifier for the media creator.
- `End param.Field[Time]`
Query param: Lists videos created before the specified date.
- `IncludeCounts param.Field[bool]`
Query param: Includes the total number of videos associated with the submitted query parameters.
- `Search param.Field[string]`
Query param: Provides a partial word match of the `name` key in the `meta` field. Slow for medium to large video libraries. May be unavailable for very large libraries.
- `Start param.Field[Time]`
Query param: Lists videos created after the specified date.
- `Status param.Field[StreamListParamsStatus]`
Query param: Specifies the processing status for all quality levels for a video.
- `const StreamListParamsStatusPendingupload StreamListParamsStatus = "pendingupload"`
- `const StreamListParamsStatusDownloading StreamListParamsStatus = "downloading"`
- `const StreamListParamsStatusQueued StreamListParamsStatus = "queued"`
- `const StreamListParamsStatusInprogress StreamListParamsStatus = "inprogress"`
- `const StreamListParamsStatusReady StreamListParamsStatus = "ready"`
- `const StreamListParamsStatusError StreamListParamsStatus = "error"`
- `const StreamListParamsStatusLiveInprogress StreamListParamsStatus = "live-inprogress"`
- `Type param.Field[string]`
Query param: Specifies whether the video is `vod` or `live`.
- `VideoName param.Field[string]`
Query param: Provides a fast, exact string match on the `name` key in the `meta` field.
### Returns
- `type Video struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Created Time`
The date and time the media item was created.
- `Creator string`
A user-defined identifier for the media creator.
- `Duration float64`
The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready.
- `Input VideoInput`
- `Height int64`
The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready.
- `Width int64`
The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready.
- `LiveInput string`
The live input ID used to upload a video with Stream Live.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the media item was last modified.
- `Playback VideoPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `ReadyToStream bool`
Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `ReadyToStreamAt Time`
Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `Size float64`
The size of the media item in bytes.
- `Status VideoStatus`
Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details.
- `ErrorReasonCode string`
Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use.
- `ErrorReasonText string`
Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state.
- `PctComplete string`
Indicates the progress as a percentage between 0 and 100.
- `State VideoStatusState`
Specifies the processing status for all quality levels for a video.
- `const VideoStatusStatePendingupload VideoStatusState = "pendingupload"`
- `const VideoStatusStateDownloading VideoStatusState = "downloading"`
- `const VideoStatusStateQueued VideoStatusState = "queued"`
- `const VideoStatusStateInprogress VideoStatusState = "inprogress"`
- `const VideoStatusStateReady VideoStatusState = "ready"`
- `const VideoStatusStateError VideoStatusState = "error"`
- `const VideoStatusStateLiveInprogress VideoStatusState = "live-inprogress"`
- `Thumbnail string`
The media item's thumbnail URI. This field is omitted until encoding is complete.
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `Uploaded Time`
The date and time the media item was uploaded.
- `UploadExpiry Time`
The date and time when the video upload URL is no longer valid for direct user uploads.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.List(context.TODO(), stream.StreamListParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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,
"range": 1000,
"result": [
{
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
],
"total": 35586
}
```
## Retrieve video details
`client.Stream.Get(ctx, identifier, query) (*Video, error)`
**get** `/accounts/{account_id}/stream/{identifier}`
Fetches details for a single video.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `query StreamGetParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type Video struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Created Time`
The date and time the media item was created.
- `Creator string`
A user-defined identifier for the media creator.
- `Duration float64`
The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready.
- `Input VideoInput`
- `Height int64`
The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready.
- `Width int64`
The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready.
- `LiveInput string`
The live input ID used to upload a video with Stream Live.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the media item was last modified.
- `Playback VideoPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `ReadyToStream bool`
Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `ReadyToStreamAt Time`
Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `Size float64`
The size of the media item in bytes.
- `Status VideoStatus`
Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details.
- `ErrorReasonCode string`
Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use.
- `ErrorReasonText string`
Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state.
- `PctComplete string`
Indicates the progress as a percentage between 0 and 100.
- `State VideoStatusState`
Specifies the processing status for all quality levels for a video.
- `const VideoStatusStatePendingupload VideoStatusState = "pendingupload"`
- `const VideoStatusStateDownloading VideoStatusState = "downloading"`
- `const VideoStatusStateQueued VideoStatusState = "queued"`
- `const VideoStatusStateInprogress VideoStatusState = "inprogress"`
- `const VideoStatusStateReady VideoStatusState = "ready"`
- `const VideoStatusStateError VideoStatusState = "error"`
- `const VideoStatusStateLiveInprogress VideoStatusState = "live-inprogress"`
- `Thumbnail string`
The media item's thumbnail URI. This field is omitted until encoding is complete.
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `Uploaded Time`
The date and time the media item was uploaded.
- `UploadExpiry Time`
The date and time when the video upload URL is no longer valid for direct user uploads.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
video, err := client.Stream.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.StreamGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", video.UID)
}
```
#### 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": {
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}
```
## Initiate video uploads using TUS
`client.Stream.New(ctx, params) error`
**post** `/accounts/{account_id}/stream`
Initiates a video upload using the TUS protocol. On success, the server responds with a status code 201 (created) and includes a `location` header to indicate where the content should be uploaded. Refer to https://tus.io for protocol details.
### Parameters
- `params StreamNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `Body param.Field[unknown]`
Body param
- `TusResumable param.Field[StreamNewParamsTusResumable]`
Header param: Specifies the TUS protocol version. This value must be included in every upload request.
Notes: The only supported version of TUS protocol is 1.0.0.
- `const StreamNewParamsTusResumable1_0_0 StreamNewParamsTusResumable = "1.0.0"`
- `UploadLength param.Field[int64]`
Header param: Indicates the size of the entire upload in bytes. The value must be a non-negative integer.
- `DirectUser param.Field[bool]`
Query param: Provisions a URL to let your end users upload videos directly to Cloudflare Stream without exposing your API token to clients.
- `UploadCreator param.Field[string]`
Header param: A user-defined identifier for the media creator.
- `UploadMetadata param.Field[string]`
Header param: Comma-separated key-value pairs following the TUS protocol specification. Values are Base-64 encoded.
Supported keys: `name`, `requiresignedurls`, `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`, `maxdurationseconds`.
### Example
```go
package main
import (
"context"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
err := client.Stream.New(context.TODO(), stream.StreamNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: map[string]interface{}{
},
TusResumable: cloudflare.F(stream.StreamNewParamsTusResumable1_0_0),
UploadLength: cloudflare.F(int64(0)),
})
if err != nil {
panic(err.Error())
}
}
```
#### Response
```json
{}
```
## Edit video details
`client.Stream.Edit(ctx, identifier, params) (*Video, error)`
**post** `/accounts/{account_id}/stream/{identifier}`
Edit details for a single video.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `params StreamEditParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `AllowedOrigins param.Field[[]AllowedOrigins]`
Body param: Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Creator param.Field[string]`
Body param: A user-defined identifier for the media creator.
- `MaxDurationSeconds param.Field[int64]`
Body param: The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta param.Field[unknown]`
Body param: A user modifiable key-value store used to reference other systems of record for managing videos.
- `RequireSignedURLs param.Field[bool]`
Body param: Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion param.Field[Time]`
Body param: Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `ThumbnailTimestampPct param.Field[float64]`
Body param: The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UploadExpiry param.Field[Time]`
Body param: The date and time when the video upload URL is no longer valid for direct user uploads.
### Returns
- `type Video struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Created Time`
The date and time the media item was created.
- `Creator string`
A user-defined identifier for the media creator.
- `Duration float64`
The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready.
- `Input VideoInput`
- `Height int64`
The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready.
- `Width int64`
The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready.
- `LiveInput string`
The live input ID used to upload a video with Stream Live.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the media item was last modified.
- `Playback VideoPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `ReadyToStream bool`
Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `ReadyToStreamAt Time`
Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `Size float64`
The size of the media item in bytes.
- `Status VideoStatus`
Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details.
- `ErrorReasonCode string`
Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use.
- `ErrorReasonText string`
Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state.
- `PctComplete string`
Indicates the progress as a percentage between 0 and 100.
- `State VideoStatusState`
Specifies the processing status for all quality levels for a video.
- `const VideoStatusStatePendingupload VideoStatusState = "pendingupload"`
- `const VideoStatusStateDownloading VideoStatusState = "downloading"`
- `const VideoStatusStateQueued VideoStatusState = "queued"`
- `const VideoStatusStateInprogress VideoStatusState = "inprogress"`
- `const VideoStatusStateReady VideoStatusState = "ready"`
- `const VideoStatusStateError VideoStatusState = "error"`
- `const VideoStatusStateLiveInprogress VideoStatusState = "live-inprogress"`
- `Thumbnail string`
The media item's thumbnail URI. This field is omitted until encoding is complete.
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `Uploaded Time`
The date and time the media item was uploaded.
- `UploadExpiry Time`
The date and time when the video upload URL is no longer valid for direct user uploads.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
video, err := client.Stream.Edit(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.StreamEditParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", video.UID)
}
```
#### 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": {
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}
```
## Delete video
`client.Stream.Delete(ctx, identifier, body) error`
**delete** `/accounts/{account_id}/stream/{identifier}`
Deletes a video and its copies from Cloudflare Stream.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `body StreamDeleteParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Example
```go
package main
import (
"context"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
err := client.Stream.Delete(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.StreamDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
}
```
#### Response
```json
{}
```
## Domain Types
### Allowed Origins
- `type AllowedOrigins string`
### Video
- `type Video struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Created Time`
The date and time the media item was created.
- `Creator string`
A user-defined identifier for the media creator.
- `Duration float64`
The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready.
- `Input VideoInput`
- `Height int64`
The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready.
- `Width int64`
The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready.
- `LiveInput string`
The live input ID used to upload a video with Stream Live.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the media item was last modified.
- `Playback VideoPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `ReadyToStream bool`
Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `ReadyToStreamAt Time`
Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `Size float64`
The size of the media item in bytes.
- `Status VideoStatus`
Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details.
- `ErrorReasonCode string`
Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use.
- `ErrorReasonText string`
Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state.
- `PctComplete string`
Indicates the progress as a percentage between 0 and 100.
- `State VideoStatusState`
Specifies the processing status for all quality levels for a video.
- `const VideoStatusStatePendingupload VideoStatusState = "pendingupload"`
- `const VideoStatusStateDownloading VideoStatusState = "downloading"`
- `const VideoStatusStateQueued VideoStatusState = "queued"`
- `const VideoStatusStateInprogress VideoStatusState = "inprogress"`
- `const VideoStatusStateReady VideoStatusState = "ready"`
- `const VideoStatusStateError VideoStatusState = "error"`
- `const VideoStatusStateLiveInprogress VideoStatusState = "live-inprogress"`
- `Thumbnail string`
The media item's thumbnail URI. This field is omitted until encoding is complete.
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `Uploaded Time`
The date and time the media item was uploaded.
- `UploadExpiry Time`
The date and time when the video upload URL is no longer valid for direct user uploads.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
# Audio Tracks
## List additional audio tracks on a video
`client.Stream.AudioTracks.Get(ctx, identifier, query) (*SinglePage[Audio], error)`
**get** `/accounts/{account_id}/stream/{identifier}/audio`
Lists additional audio tracks on a video. Note this API will not return information for audio attached to the video upload.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `query AudioTrackGetParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type Audio struct{…}`
- `Default bool`
Denotes whether the audio track will be played by default in a player.
- `Label string`
A string to uniquely identify the track amongst other audio track labels for the specified video.
- `Status AudioStatus`
Specifies the processing status of the video.
- `const AudioStatusQueued AudioStatus = "queued"`
- `const AudioStatusReady AudioStatus = "ready"`
- `const AudioStatusError AudioStatus = "error"`
- `UID string`
A Cloudflare-generated unique identifier for a media item.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.AudioTracks.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.AudioTrackGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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": [
{
"default": true,
"label": "director commentary",
"status": "queued",
"uid": "ea95132c15732412d22c1476fa83f27a"
}
]
}
```
## Edit additional audio tracks on a video
`client.Stream.AudioTracks.Edit(ctx, identifier, audioIdentifier, params) (*Audio, error)`
**patch** `/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}`
Edits additional audio tracks on a video. Editing the default status of an audio track to `true` will mark all other audio tracks on the video default status to `false`.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `audioIdentifier string`
The unique identifier for an additional audio track.
- `params AudioTrackEditParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `Default param.Field[bool]`
Body param: Denotes whether the audio track will be played by default in a player.
- `Label param.Field[string]`
Body param: A string to uniquely identify the track amongst other audio track labels for the specified video.
### Returns
- `type Audio struct{…}`
- `Default bool`
Denotes whether the audio track will be played by default in a player.
- `Label string`
A string to uniquely identify the track amongst other audio track labels for the specified video.
- `Status AudioStatus`
Specifies the processing status of the video.
- `const AudioStatusQueued AudioStatus = "queued"`
- `const AudioStatusReady AudioStatus = "ready"`
- `const AudioStatusError AudioStatus = "error"`
- `UID string`
A Cloudflare-generated unique identifier for a media item.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
audio, err := client.Stream.AudioTracks.Edit(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"ea95132c15732412d22c1476fa83f27a",
stream.AudioTrackEditParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audio.UID)
}
```
#### 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": {
"default": true,
"label": "director commentary",
"status": "queued",
"uid": "ea95132c15732412d22c1476fa83f27a"
}
}
```
## Delete additional audio tracks on a video
`client.Stream.AudioTracks.Delete(ctx, identifier, audioIdentifier, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}`
Deletes additional audio tracks on a video. Deleting a default audio track is not allowed. You must assign another audio track as default prior to deletion.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `audioIdentifier string`
The unique identifier for an additional audio track.
- `body AudioTrackDeleteParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type AudioTrackDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
audioTrack, err := client.Stream.AudioTracks.Delete(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"ea95132c15732412d22c1476fa83f27a",
stream.AudioTrackDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audioTrack)
}
```
#### 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": "ok"
}
```
## Add audio tracks to a video
`client.Stream.AudioTracks.Copy(ctx, identifier, params) (*Audio, error)`
**post** `/accounts/{account_id}/stream/{identifier}/audio/copy`
Adds an additional audio track to a video using the provided audio track URL.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `params AudioTrackCopyParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `Label param.Field[string]`
Body param: A string to uniquely identify the track amongst other audio track labels for the specified video.
- `URL param.Field[string]`
Body param: An audio track URL. The server must be publicly routable and support `HTTP HEAD` requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` requests with a `content-range` header that includes the size of the file.
### Returns
- `type Audio struct{…}`
- `Default bool`
Denotes whether the audio track will be played by default in a player.
- `Label string`
A string to uniquely identify the track amongst other audio track labels for the specified video.
- `Status AudioStatus`
Specifies the processing status of the video.
- `const AudioStatusQueued AudioStatus = "queued"`
- `const AudioStatusReady AudioStatus = "ready"`
- `const AudioStatusError AudioStatus = "error"`
- `UID string`
A Cloudflare-generated unique identifier for a media item.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
audio, err := client.Stream.AudioTracks.Copy(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.AudioTrackCopyParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Label: cloudflare.F("director commentary"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audio.UID)
}
```
#### 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": {
"default": true,
"label": "director commentary",
"status": "queued",
"uid": "ea95132c15732412d22c1476fa83f27a"
}
}
```
## Domain Types
### Audio
- `type Audio struct{…}`
- `Default bool`
Denotes whether the audio track will be played by default in a player.
- `Label string`
A string to uniquely identify the track amongst other audio track labels for the specified video.
- `Status AudioStatus`
Specifies the processing status of the video.
- `const AudioStatusQueued AudioStatus = "queued"`
- `const AudioStatusReady AudioStatus = "ready"`
- `const AudioStatusError AudioStatus = "error"`
- `UID string`
A Cloudflare-generated unique identifier for a media item.
# Videos
## Storage use
`client.Stream.Videos.StorageUsage(ctx, params) (*VideoStorageUsageResponse, error)`
**get** `/accounts/{account_id}/stream/storage-usage`
Returns information about an account's storage use.
### Parameters
- `params VideoStorageUsageParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `Creator param.Field[string]`
Query param: A user-defined identifier for the media creator.
### Returns
- `type VideoStorageUsageResponse struct{…}`
- `Creator string`
A user-defined identifier for the media creator.
- `TotalStorageMinutes int64`
The total minutes of video content stored in the account.
- `TotalStorageMinutesLimit int64`
The storage capacity alloted for the account.
- `VideoCount int64`
The total count of videos associated with the account.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
response, err := client.Stream.Videos.StorageUsage(context.TODO(), stream.VideoStorageUsageParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.VideoCount)
}
```
#### 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": {
"creator": "creator-id_abcde12345",
"totalStorageMinutes": 0,
"totalStorageMinutesLimit": 0,
"videoCount": 0
}
}
```
# Clip
## Clip videos given a start and end time
`client.Stream.Clip.New(ctx, params) (*Clip, error)`
**post** `/accounts/{account_id}/stream/clip`
Clips a video based on the specified start and end times provided in seconds.
### Parameters
- `params ClipNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `ClippedFromVideoUID param.Field[string]`
Body param: The unique video identifier (UID).
- `EndTimeSeconds param.Field[int64]`
Body param: Specifies the end time for the video clip in seconds.
- `StartTimeSeconds param.Field[int64]`
Body param: Specifies the start time for the video clip in seconds.
- `AllowedOrigins param.Field[[]AllowedOrigins]`
Body param: Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Creator param.Field[string]`
Body param: A user-defined identifier for the media creator.
- `MaxDurationSeconds param.Field[int64]`
Body param: The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `RequireSignedURLs param.Field[bool]`
Body param: Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ThumbnailTimestampPct param.Field[float64]`
Body param: The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `Watermark param.Field[ClipNewParamsWatermark]`
Body param
- `UID string`
The unique identifier for the watermark profile.
### Returns
- `type Clip struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `ClippedFromVideoUID string`
The unique video identifier (UID).
- `Created Time`
The date and time the clip was created.
- `Creator string`
A user-defined identifier for the media creator.
- `EndTimeSeconds int64`
Specifies the end time for the video clip in seconds.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the live input was last modified.
- `Playback ClipPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `StartTimeSeconds int64`
Specifies the start time for the video clip in seconds.
- `Status ClipStatus`
Specifies the processing status for all quality levels for a video.
- `const ClipStatusPendingupload ClipStatus = "pendingupload"`
- `const ClipStatusDownloading ClipStatus = "downloading"`
- `const ClipStatusQueued ClipStatus = "queued"`
- `const ClipStatusInprogress ClipStatus = "inprogress"`
- `const ClipStatusReady ClipStatus = "ready"`
- `const ClipStatusError ClipStatus = "error"`
- `const ClipStatusLiveInprogress ClipStatus = "live-inprogress"`
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `Watermark ClipWatermark`
- `UID string`
The unique identifier for the watermark profile.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
clip, err := client.Stream.Clip.New(context.TODO(), stream.ClipNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
ClippedFromVideoUID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
EndTimeSeconds: cloudflare.F(int64(0)),
StartTimeSeconds: cloudflare.F(int64(0)),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", clip.ClippedFromVideoUID)
}
```
#### 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": {
"allowedOrigins": [
"example.com"
],
"clippedFromVideoUID": "023e105f4ecef8ad9ca31a8372d0c353",
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"endTimeSeconds": 0,
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"requireSignedURLs": true,
"startTimeSeconds": 0,
"status": "inprogress",
"thumbnailTimestampPct": 0.529241,
"watermark": {
"uid": "ea95132c15732412d22c1476fa83f27a"
}
}
}
```
## Domain Types
### Clip
- `type Clip struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `ClippedFromVideoUID string`
The unique video identifier (UID).
- `Created Time`
The date and time the clip was created.
- `Creator string`
A user-defined identifier for the media creator.
- `EndTimeSeconds int64`
Specifies the end time for the video clip in seconds.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the live input was last modified.
- `Playback ClipPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `StartTimeSeconds int64`
Specifies the start time for the video clip in seconds.
- `Status ClipStatus`
Specifies the processing status for all quality levels for a video.
- `const ClipStatusPendingupload ClipStatus = "pendingupload"`
- `const ClipStatusDownloading ClipStatus = "downloading"`
- `const ClipStatusQueued ClipStatus = "queued"`
- `const ClipStatusInprogress ClipStatus = "inprogress"`
- `const ClipStatusReady ClipStatus = "ready"`
- `const ClipStatusError ClipStatus = "error"`
- `const ClipStatusLiveInprogress ClipStatus = "live-inprogress"`
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `Watermark ClipWatermark`
- `UID string`
The unique identifier for the watermark profile.
# Copy
## Upload videos from a URL
`client.Stream.Copy.New(ctx, params) (*Video, error)`
**post** `/accounts/{account_id}/stream/copy`
Uploads a video to Stream from a provided URL.
### Parameters
- `params CopyNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `URL param.Field[string]`
Body param: A video's URL. The server must be publicly routable and support `HTTP HEAD` requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` requests with a `content-range` header that includes the size of the file.
- `AllowedOrigins param.Field[[]AllowedOrigins]`
Body param: Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Creator param.Field[string]`
Body param: A user-defined identifier for the media creator.
- `Meta param.Field[unknown]`
Body param: A user modifiable key-value store used to reference other systems of record for managing videos.
- `RequireSignedURLs param.Field[bool]`
Body param: Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion param.Field[Time]`
Body param: Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `ThumbnailTimestampPct param.Field[float64]`
Body param: The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `Watermark param.Field[CopyNewParamsWatermark]`
Body param
- `UID string`
The unique identifier for the watermark profile.
- `UploadCreator param.Field[string]`
Header param: A user-defined identifier for the media creator.
### Returns
- `type Video struct{…}`
- `AllowedOrigins []AllowedOrigins`
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Created Time`
The date and time the media item was created.
- `Creator string`
A user-defined identifier for the media creator.
- `Duration float64`
The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready.
- `Input VideoInput`
- `Height int64`
The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready.
- `Width int64`
The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready.
- `LiveInput string`
The live input ID used to upload a video with Stream Live.
- `MaxDurationSeconds int64`
The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing videos.
- `Modified Time`
The date and time the media item was last modified.
- `Playback VideoPlayback`
- `Dash string`
DASH Media Presentation Description for the video.
- `Hls string`
The HLS manifest for the video.
- `Preview string`
The video's preview page URI. This field is omitted until encoding is complete.
- `ReadyToStream bool`
Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `ReadyToStreamAt Time`
Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress.
- `RequireSignedURLs bool`
Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `Size float64`
The size of the media item in bytes.
- `Status VideoStatus`
Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details.
- `ErrorReasonCode string`
Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use.
- `ErrorReasonText string`
Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state.
- `PctComplete string`
Indicates the progress as a percentage between 0 and 100.
- `State VideoStatusState`
Specifies the processing status for all quality levels for a video.
- `const VideoStatusStatePendingupload VideoStatusState = "pendingupload"`
- `const VideoStatusStateDownloading VideoStatusState = "downloading"`
- `const VideoStatusStateQueued VideoStatusState = "queued"`
- `const VideoStatusStateInprogress VideoStatusState = "inprogress"`
- `const VideoStatusStateReady VideoStatusState = "ready"`
- `const VideoStatusStateError VideoStatusState = "error"`
- `const VideoStatusStateLiveInprogress VideoStatusState = "live-inprogress"`
- `Thumbnail string`
The media item's thumbnail URI. This field is omitted until encoding is complete.
- `ThumbnailTimestampPct float64`
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `Uploaded Time`
The date and time the media item was uploaded.
- `UploadExpiry Time`
The date and time when the video upload URL is no longer valid for direct user uploads.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
video, err := client.Stream.Copy.New(context.TODO(), stream.CopyNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
URL: cloudflare.F("https://example.com/myvideo.mp4"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", video.UID)
}
```
#### 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": {
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}
```
# Direct Upload
## Upload videos via direct upload URLs
`client.Stream.DirectUpload.New(ctx, params) (*DirectUploadNewResponse, error)`
**post** `/accounts/{account_id}/stream/direct_upload`
Creates a direct upload that allows video uploads without an API key.
### Parameters
- `params DirectUploadNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `MaxDurationSeconds param.Field[int64]`
Body param: The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown.
- `AllowedOrigins param.Field[[]AllowedOrigins]`
Body param: Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
- `Creator param.Field[string]`
Body param: A user-defined identifier for the media creator.
- `Expiry param.Field[Time]`
Body param: The date and time after upload when videos will not be accepted.
- `Meta param.Field[unknown]`
Body param: A user modifiable key-value store used to reference other systems of record for managing videos.
- `RequireSignedURLs param.Field[bool]`
Body param: Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video.
- `ScheduledDeletion param.Field[Time]`
Body param: Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `ThumbnailTimestampPct param.Field[float64]`
Body param: The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
- `Watermark param.Field[DirectUploadNewParamsWatermark]`
Body param
- `UID string`
The unique identifier for the watermark profile.
- `UploadCreator param.Field[string]`
Header param: A user-defined identifier for the media creator.
### Returns
- `type DirectUploadNewResponse struct{…}`
- `ScheduledDeletion Time`
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
- `UID string`
A Cloudflare-generated unique identifier for a media item.
- `UploadURL string`
The URL an unauthenticated upload can use for a single `HTTP POST multipart/form-data` request.
- `Watermark Watermark`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
directUpload, err := client.Stream.DirectUpload.New(context.TODO(), stream.DirectUploadNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
MaxDurationSeconds: cloudflare.F(int64(1)),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", directUpload.UID)
}
```
#### 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": {
"scheduledDeletion": "2014-01-02T02:20:00Z",
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploadURL": "www.example.com/samplepath",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}
```
# Keys
## List signing keys
`client.Stream.Keys.Get(ctx, query) (*SinglePage[KeyGetResponse], error)`
**get** `/accounts/{account_id}/stream/keys`
Lists the video ID and creation date and time when a signing key was created.
### Parameters
- `query KeyGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type KeyGetResponse struct{…}`
- `ID string`
Identifier.
- `Created Time`
The date and time a signing key was created.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.Keys.Get(context.TODO(), stream.KeyGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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": [
{
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"created": "2014-01-02T02:20:00Z"
}
]
}
```
## Create signing keys
`client.Stream.Keys.New(ctx, params) (*Keys, error)`
**post** `/accounts/{account_id}/stream/keys`
Creates an RSA private key in PEM and JWK formats. Key files are only displayed once after creation. Keys are created, used, and deleted independently of videos, and every key can sign any video.
### Parameters
- `params KeyNewParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `Body param.Field[unknown]`
Body param
### Returns
- `type Keys struct{…}`
- `ID string`
Identifier.
- `Created Time`
The date and time a signing key was created.
- `Jwk string`
The signing key in JWK format.
- `Pem string`
The signing key in PEM format.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
keys, err := client.Stream.Keys.New(context.TODO(), stream.KeyNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: map[string]interface{}{
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", keys.ID)
}
```
#### 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": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"created": "2014-01-02T02:20:00Z",
"jwk": "eyJ1c2UiOiJzaWciLCJrdHkiOiJSU0EiLCJraWQiOiI1MjEzY2ZhMTIxZjcwYjhjMTM4MDY4NmZmYzM3MWJhMyIsImFsZyI6IlJTMjU2IiwibiI6IjBUandqT2laV21KNDN2ZjNUbzREb1htWFd0SkdOR3lYZmh5dHRMYUJnRjEtRVFXUURLaG9LYm9hS21xakNBc21za3V0YkxVN1BVOGRrUU5ER1p3S3VWczA4elNaNGt4aTR0RWdQUFp5dDdkWEMtbFlSWW95ckFHRjRBWGh5MzI5YkhDUDFJbHJCQl9Ba0dnbmRMQWd1bnhZMHJSZ2N2T3ppYXc2S0p4Rm5jMlVLMFdVOGIwcDRLS0hHcDFLTDlkazBXVDhkVllxYmVSaUpqQ2xVRW1oOHl2OUNsT1ZhUzRLeGlYNnhUUTREWnc2RGFKZklWM1F0Tmd2cG1ieWxOSmFQSG5zc3JodDJHS1A5NjJlS2poUVJsaWd2SFhKTE9uSm9KZkxlSUVIWi1peFdmY1RETUg5MnNHdm93MURPanhMaUNOMXpISy1oN2JMb1hUaUxnYzRrdyIsImUiOiJBUUFCIiwiZCI6IndpQWEwaU5mWnNYSGNOcVMxSWhnUmdzVHJHay1TcFlYV2lReDZHTU9kWlJKekhGazN0bkRERFJvNHNKZTBxX0dEOWkzNlEyZkVadS15elpEcEJkc3U5OHNtaHhNU19Ta0s5X3VFYUo1Zm96V2IyN3JRRnFoLVliUU9MUThkUnNPRHZmQl9Hb2txWWJzblJDR3kzWkFaOGZJZ25ocXBUNEpiOHdsaWxpMUgxeFpzM3RnTWtkTEluTm1yMFAtcTYxZEtNd3JYZVRoSWNEc0kyb2Z1LTFtRm1MWndQb2ZGbmxaTW9QN1pfRU5pUGNfWGtWNzFhaHBOZE9pcW5ablZtMHBCNE5QS1UweDRWTjQyYlAzWEhMUmpkV2hJOGt3SC1BdXhqb3BLaHJ0R2tvcG1jZFRkM1ZRdElaOGRpZHByMXpBaEpvQi16ZVlIaTFUel9ZSFFld0FRUSIsInAiOiIyVTZFVUJka3U3TndDYXoyNzZuWGMxRXgwVHpNZjU4U0UtU2M2eUNaYWk2TkwzVURpWi1mNHlIdkRLYnFGUXdLWDNwZ0l2aVE3Y05QYUpkbE9NeS1mU21GTXU3V3hlbVZYamFlTjJCMkRDazhQY0NEOVgxU2hhR3E1ZUdSSHNObVUtSDNxTG1FRGpjLWliazRHZ0RNb2lVYjQ2OGxFZHAwU2pIOXdsOUdsYTgiLCJxIjoiOW5ucXg5ZnNNY2dIZ29DemhfVjJmaDhoRUxUSUM5aFlIOVBCTG9aQjZIaE1TWG1ja1BSazVnUlpPWlFEN002TzlMaWZjNmFDVXdEbjBlQzU2YkFDNUNrcWxjODJsVDhzTWlMeWJyTjh3bWotcjNjSTBGQTlfSGQySEY1ZkgycnJmenVqd0NWM3czb09Ud3p4d1g3c2xKbklRanphel91SzEyWEtucVZZcUYwIiwiZHAiOiJxQklTUTlfVUNWaV9Ucng0UU9VYnZoVU9jc2FUWkNHajJiNzNudU9YeElnOHFuZldSSnN4RG5zd2FKaXdjNWJjYnZ3M1h0VGhRd1BNWnhpeE1UMHFGNlFGWVY5WXZibnJ6UEp4YkdNdTZqajZYc2lIUjFlbWU3U09lVDM4Xzg0aFZyOXV6UkN2RWstb0R0MHlodW9YVzFGWVFNRTE2cGtMV0ZkUjdRUERsQUUiLCJkcSI6Im5zQUp3eXZFbW8tdW5wU01qYjVBMHB6MExCRjBZNFMxeGRJYXNfLVBSYzd0dThsVFdWMl8teExEOFR6dmhqX0lmY0RJR3JJZGNKNjlzVVZnR1M3ZnZkcng3Y21uNjFyai1XcmU0UVJFRC1lV1dxZDlpc2FVRmg5UGVKZ2tCbFZVVnYtdnladVlWdFF2a1NUU05ZR3RtVXl2V2xKZDBPWEFHRm9jdGlfak9aVSIsInFpIjoib0dYaWxLQ2NKRXNFdEE1eG54WUdGQW5UUjNwdkZLUXR5S0F0UGhHaHkybm5ya2VzN1RRaEFxMGhLRWZtU1RzaE1hNFhfd05aMEstX1F0dkdoNDhpeHdTTDVLTEwxZnFsY0k2TF9XUnF0cFQxS21LRERlUHR2bDVCUzFGbjgwSGFwR215cmZRWUU4S09QR2UwUl82S1BOZE1vc3dYQ3Nfd0RYMF92ZzNoNUxRIn0=",
"pem": "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcGdJQkFBS0NBUUVBMFRqd2pPaVpXbUo0M3ZmM1RvNERvWG1YV3RKR05HeVhmaHl0dExhQmdGMStFUVdRCkRLaG9LYm9hS21xakNBc21za3V0YkxVN1BVOGRrUU5ER1p3S3VWczA4elNaNGt4aTR0RWdQUFp5dDdkWEMrbFkKUllveXJBR0Y0QVhoeTMyOWJIQ1AxSWxyQkIvQWtHZ25kTEFndW54WTByUmdjdk96aWF3NktKeEZuYzJVSzBXVQo4YjBwNEtLSEdwMUtMOWRrMFdUOGRWWXFiZVJpSmpDbFVFbWg4eXY5Q2xPVmFTNEt4aVg2eFRRNERadzZEYUpmCklWM1F0Tmd2cG1ieWxOSmFQSG5zc3JodDJHS1A5NjJlS2poUVJsaWd2SFhKTE9uSm9KZkxlSUVIWitpeFdmY1QKRE1IOTJzR3ZvdzFET2p4TGlDTjF6SEsraDdiTG9YVGlMZ2M0a3dJREFRQUJBb0lCQVFEQ0lCclNJMTlteGNkdwoycExVaUdCR0N4T3NhVDVLbGhkYUpESG9ZdzUxbEVuTWNXVGUyY01NTkdqaXdsN1NyOFlQMkxmcERaOFJtNzdMCk5rT2tGMnk3M3l5YUhFeEw5S1FyMys0Um9ubCtqTlp2YnV0QVdxSDVodEE0dER4MUd3NE85OEg4YWlTcGh1eWQKRUliTGRrQm54OGlDZUdxbFBnbHZ6Q1dLV0xVZlhGbXplMkF5UjBzaWMyYXZRLzZyclYwb3pDdGQ1T0Vod093agphaCs3N1dZV1l0bkEraDhXZVZreWcvdG44UTJJOXo5ZVJYdlZxR2sxMDZLcWRtZFdiU2tIZzA4cFRUSGhVM2paCnMvZGNjdEdOMWFFanlUQWY0QzdHT2lrcUd1MGFTaW1aeDFOM2RWQzBobngySjJtdlhNQ0VtZ0g3TjVnZUxWUFAKOWdkQjdBQkJBb0dCQU5sT2hGQVhaTHV6Y0Ftczl1K3AxM05STWRFOHpIK2ZFaFBrbk9zZ21Xb3VqUzkxQTRtZgpuK01oN3d5bTZoVU1DbDk2WUNMNGtPM0RUMmlYWlRqTXZuMHBoVEx1MXNYcGxWNDJuamRnZGd3cFBEM0FnL1Y5ClVvV2hxdVhoa1I3RFpsUGg5Nmk1aEE0M1BvbTVPQm9BektJbEcrT3ZKUkhhZEVveC9jSmZScFd2QW9HQkFQWjUKNnNmWDdESElCNEtBczRmMWRuNGZJUkMweUF2WVdCL1R3UzZHUWVoNFRFbDVuSkQwWk9ZRVdUbVVBK3pPanZTNApuM09tZ2xNQTU5SGd1ZW13QXVRcEtwWFBOcFUvTERJaThtNnpmTUpvL3E5M0NOQlFQZngzZGh4ZVh4OXE2Mzg3Cm84QWxkOE42RGs4TThjRis3SlNaeUVJODJzLzdpdGRseXA2bFdLaGRBb0dCQUtnU0VrUGYxQWxZdjA2OGVFRGwKRzc0VkRuTEdrMlFobzltKzk1N2psOFNJUEtwMzFrU2JNUTU3TUdpWXNIT1czRzc4TjE3VTRVTUR6R2NZc1RFOQpLaGVrQldGZldMMjU2OHp5Y1d4akx1bzQrbDdJaDBkWHBudTBqbms5L1AvT0lWYS9iczBRcnhKUHFBN2RNb2JxCkYxdFJXRURCTmVxWkMxaFhVZTBEdzVRQkFvR0JBSjdBQ2NNcnhKcVBycDZVakkyK1FOS2M5Q3dSZEdPRXRjWFMKR3JQL2owWE83YnZKVTFsZHYvc1N3L0U4NzRZL3lIM0F5QnF5SFhDZXZiRkZZQmt1MzczYThlM0pwK3RhNC9scQozdUVFUkEvbmxscW5mWXJHbEJZZlQzaVlKQVpWVkZiL3I4bWJtRmJVTDVFazBqV0JyWmxNcjFwU1hkRGx3QmhhCkhMWXY0em1WQW9HQkFLQmw0cFNnbkNSTEJMUU9jWjhXQmhRSjAwZDZieFNrTGNpZ0xUNFJvY3RwNTY1SHJPMDAKSVFLdElTaEg1a2s3SVRHdUYvOERXZEN2djBMYnhvZVBJc2NFaStTaXk5WDZwWENPaS8xa2FyYVU5U3BpZ3czago3YjVlUVV0UlovTkIycVJwc3EzMEdCUENqanhudEVmK2lqelhUS0xNRndyUDhBMTlQNzRONGVTMAotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
}
}
```
## Delete signing keys
`client.Stream.Keys.Delete(ctx, identifier, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/keys/{identifier}`
Deletes signing keys and revokes all signed URLs generated with the key.
### Parameters
- `identifier string`
Identifier.
- `body KeyDeleteParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type KeyDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
key, err := client.Stream.Keys.Delete(
context.TODO(),
"023e105f4ecef8ad9ca31a8372d0c353",
stream.KeyDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", key)
}
```
#### 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": "ok"
}
```
## Domain Types
### Keys
- `type Keys struct{…}`
- `ID string`
Identifier.
- `Created Time`
The date and time a signing key was created.
- `Jwk string`
The signing key in JWK format.
- `Pem string`
The signing key in PEM format.
# Live Inputs
## List live inputs
`client.Stream.LiveInputs.List(ctx, params) (*LiveInputListResponse, error)`
**get** `/accounts/{account_id}/stream/live_inputs`
Lists the live inputs created for an account. To get the credentials needed to stream to a specific live input, request a single live input.
### Parameters
- `params LiveInputListParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `IncludeCounts param.Field[bool]`
Query param: Includes the total number of videos associated with the submitted query parameters.
### Returns
- `type LiveInputListResponse struct{…}`
- `LiveInputs []LiveInputListResponseLiveInput`
- `Created Time`
The date and time the live input was created.
- `DeleteRecordingAfterDays float64`
Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled bool`
Indicates whether the live input is enabled and can accept streams.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Modified Time`
The date and time the live input was last modified.
- `UID string`
A unique identifier for a live input.
- `Range int64`
The total number of remaining live inputs based on cursor position.
- `Total int64`
The total number of live inputs that match the provided filters.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
liveInputs, err := client.Stream.LiveInputs.List(context.TODO(), stream.LiveInputListParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", liveInputs.LiveInputs)
}
```
#### 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": {
"liveInputs": [
{
"created": "2014-01-02T02:20:00Z",
"deleteRecordingAfterDays": 45,
"enabled": true,
"meta": {
"name": "test stream 1"
},
"modified": "2014-01-02T02:20:00Z",
"uid": "66be4bf738797e01e1fca35a7bdecdcd"
}
],
"range": 1000,
"total": 35586
}
}
```
## Retrieve a live input
`client.Stream.LiveInputs.Get(ctx, liveInputIdentifier, query) (*LiveInput, error)`
**get** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}`
Retrieves details of an existing live input.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `query LiveInputGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type LiveInput struct{…}`
Details about a live input.
- `Created Time`
The date and time the live input was created.
- `DeleteRecordingAfterDays float64`
Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled bool`
Indicates whether the live input is enabled and can accept streams.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Modified Time`
The date and time the live input was last modified.
- `Recording LiveInputRecording`
Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputRecordingModeOff LiveInputRecordingMode = "off"`
- `const LiveInputRecordingModeAutomatic LiveInputRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
- `Rtmps LiveInputRtmps`
Details for streaming to an live input using RTMPS.
- `StreamKey string`
The secret key to use when streaming via RTMPS to a live input.
- `URL string`
The RTMPS URL you provide to the broadcaster, which they stream live video to.
- `RtmpsPlayback LiveInputRtmpsPlayback`
Details for playback from an live input using RTMPS.
- `StreamKey string`
The secret key to use for playback via RTMPS.
- `URL string`
The URL used to play live video over RTMPS.
- `Srt LiveInputSrt`
Details for streaming to a live input using SRT.
- `Passphrase string`
The secret key to use when streaming via SRT to a live input.
- `StreamID string`
The identifier of the live input to use when streaming via SRT.
- `URL string`
The SRT URL you provide to the broadcaster, which they stream live video to.
- `SrtPlayback LiveInputSrtPlayback`
Details for playback from an live input using SRT.
- `Passphrase string`
The secret key to use for playback via SRT.
- `StreamID string`
The identifier of the live input to use for playback via SRT.
- `URL string`
The URL used to play live video over SRT.
- `Status LiveInputStatus`
The connection status of a live input.
- `const LiveInputStatusConnected LiveInputStatus = "connected"`
- `const LiveInputStatusReconnected LiveInputStatus = "reconnected"`
- `const LiveInputStatusReconnecting LiveInputStatus = "reconnecting"`
- `const LiveInputStatusClientDisconnect LiveInputStatus = "client_disconnect"`
- `const LiveInputStatusTTLExceeded LiveInputStatus = "ttl_exceeded"`
- `const LiveInputStatusFailedToConnect LiveInputStatus = "failed_to_connect"`
- `const LiveInputStatusFailedToReconnect LiveInputStatus = "failed_to_reconnect"`
- `const LiveInputStatusNewConfigurationAccepted LiveInputStatus = "new_configuration_accepted"`
- `UID string`
A unique identifier for a live input.
- `WebRtc LiveInputWebRtc`
Details for streaming to a live input using WebRTC.
- `URL string`
The WebRTC URL you provide to the broadcaster, which they stream live video to.
- `WebRtcPlayback LiveInputWebRtcPlayback`
Details for playback from a live input using WebRTC.
- `URL string`
The URL used to play live video over WebRTC.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
liveInput, err := client.Stream.LiveInputs.Get(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
stream.LiveInputGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", liveInput.UID)
}
```
#### 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": {
"created": "2014-01-02T02:20:00Z",
"deleteRecordingAfterDays": 45,
"enabled": true,
"meta": {
"name": "test stream 1"
},
"modified": "2014-01-02T02:20:00Z",
"recording": {
"allowedOrigins": [
"example.com"
],
"hideLiveViewerCount": false,
"mode": "off",
"requireSignedURLs": false,
"timeoutSeconds": 0
},
"rtmps": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"rtmpsPlayback": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"srt": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "srt://live.cloudflare.com:778"
},
"srtPlayback": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"status": "connected",
"uid": "66be4bf738797e01e1fca35a7bdecdcd",
"webRTC": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish"
},
"webRTCPlayback": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play"
}
}
}
```
## Create a live input
`client.Stream.LiveInputs.New(ctx, params) (*LiveInput, error)`
**post** `/accounts/{account_id}/stream/live_inputs`
Creates a live input, and returns credentials that you or your users can use to stream live video to Cloudflare Stream.
### Parameters
- `params LiveInputNewParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `DefaultCreator param.Field[string]`
Body param: Sets the creator ID asssociated with this live input.
- `DeleteRecordingAfterDays param.Field[float64]`
Body param: Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled param.Field[bool]`
Body param: Indicates whether the live input is enabled and can accept streams.
- `Meta param.Field[unknown]`
Body param: A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Recording param.Field[LiveInputNewParamsRecording]`
Body param: Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputNewParamsRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputNewParamsRecordingModeOff LiveInputNewParamsRecordingMode = "off"`
- `const LiveInputNewParamsRecordingModeAutomatic LiveInputNewParamsRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
### Returns
- `type LiveInput struct{…}`
Details about a live input.
- `Created Time`
The date and time the live input was created.
- `DeleteRecordingAfterDays float64`
Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled bool`
Indicates whether the live input is enabled and can accept streams.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Modified Time`
The date and time the live input was last modified.
- `Recording LiveInputRecording`
Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputRecordingModeOff LiveInputRecordingMode = "off"`
- `const LiveInputRecordingModeAutomatic LiveInputRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
- `Rtmps LiveInputRtmps`
Details for streaming to an live input using RTMPS.
- `StreamKey string`
The secret key to use when streaming via RTMPS to a live input.
- `URL string`
The RTMPS URL you provide to the broadcaster, which they stream live video to.
- `RtmpsPlayback LiveInputRtmpsPlayback`
Details for playback from an live input using RTMPS.
- `StreamKey string`
The secret key to use for playback via RTMPS.
- `URL string`
The URL used to play live video over RTMPS.
- `Srt LiveInputSrt`
Details for streaming to a live input using SRT.
- `Passphrase string`
The secret key to use when streaming via SRT to a live input.
- `StreamID string`
The identifier of the live input to use when streaming via SRT.
- `URL string`
The SRT URL you provide to the broadcaster, which they stream live video to.
- `SrtPlayback LiveInputSrtPlayback`
Details for playback from an live input using SRT.
- `Passphrase string`
The secret key to use for playback via SRT.
- `StreamID string`
The identifier of the live input to use for playback via SRT.
- `URL string`
The URL used to play live video over SRT.
- `Status LiveInputStatus`
The connection status of a live input.
- `const LiveInputStatusConnected LiveInputStatus = "connected"`
- `const LiveInputStatusReconnected LiveInputStatus = "reconnected"`
- `const LiveInputStatusReconnecting LiveInputStatus = "reconnecting"`
- `const LiveInputStatusClientDisconnect LiveInputStatus = "client_disconnect"`
- `const LiveInputStatusTTLExceeded LiveInputStatus = "ttl_exceeded"`
- `const LiveInputStatusFailedToConnect LiveInputStatus = "failed_to_connect"`
- `const LiveInputStatusFailedToReconnect LiveInputStatus = "failed_to_reconnect"`
- `const LiveInputStatusNewConfigurationAccepted LiveInputStatus = "new_configuration_accepted"`
- `UID string`
A unique identifier for a live input.
- `WebRtc LiveInputWebRtc`
Details for streaming to a live input using WebRTC.
- `URL string`
The WebRTC URL you provide to the broadcaster, which they stream live video to.
- `WebRtcPlayback LiveInputWebRtcPlayback`
Details for playback from a live input using WebRTC.
- `URL string`
The URL used to play live video over WebRTC.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
liveInput, err := client.Stream.LiveInputs.New(context.TODO(), stream.LiveInputNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", liveInput.UID)
}
```
#### 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": {
"created": "2014-01-02T02:20:00Z",
"deleteRecordingAfterDays": 45,
"enabled": true,
"meta": {
"name": "test stream 1"
},
"modified": "2014-01-02T02:20:00Z",
"recording": {
"allowedOrigins": [
"example.com"
],
"hideLiveViewerCount": false,
"mode": "off",
"requireSignedURLs": false,
"timeoutSeconds": 0
},
"rtmps": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"rtmpsPlayback": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"srt": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "srt://live.cloudflare.com:778"
},
"srtPlayback": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"status": "connected",
"uid": "66be4bf738797e01e1fca35a7bdecdcd",
"webRTC": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish"
},
"webRTCPlayback": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play"
}
}
}
```
## Update a live input
`client.Stream.LiveInputs.Update(ctx, liveInputIdentifier, params) (*LiveInput, error)`
**put** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}`
Updates a specified live input.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `params LiveInputUpdateParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `DefaultCreator param.Field[string]`
Body param: Sets the creator ID asssociated with this live input.
- `DeleteRecordingAfterDays param.Field[float64]`
Body param: Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled param.Field[bool]`
Body param: Indicates whether the live input is enabled and can accept streams.
- `Meta param.Field[unknown]`
Body param: A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Recording param.Field[LiveInputUpdateParamsRecording]`
Body param: Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputUpdateParamsRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputUpdateParamsRecordingModeOff LiveInputUpdateParamsRecordingMode = "off"`
- `const LiveInputUpdateParamsRecordingModeAutomatic LiveInputUpdateParamsRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
### Returns
- `type LiveInput struct{…}`
Details about a live input.
- `Created Time`
The date and time the live input was created.
- `DeleteRecordingAfterDays float64`
Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled bool`
Indicates whether the live input is enabled and can accept streams.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Modified Time`
The date and time the live input was last modified.
- `Recording LiveInputRecording`
Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputRecordingModeOff LiveInputRecordingMode = "off"`
- `const LiveInputRecordingModeAutomatic LiveInputRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
- `Rtmps LiveInputRtmps`
Details for streaming to an live input using RTMPS.
- `StreamKey string`
The secret key to use when streaming via RTMPS to a live input.
- `URL string`
The RTMPS URL you provide to the broadcaster, which they stream live video to.
- `RtmpsPlayback LiveInputRtmpsPlayback`
Details for playback from an live input using RTMPS.
- `StreamKey string`
The secret key to use for playback via RTMPS.
- `URL string`
The URL used to play live video over RTMPS.
- `Srt LiveInputSrt`
Details for streaming to a live input using SRT.
- `Passphrase string`
The secret key to use when streaming via SRT to a live input.
- `StreamID string`
The identifier of the live input to use when streaming via SRT.
- `URL string`
The SRT URL you provide to the broadcaster, which they stream live video to.
- `SrtPlayback LiveInputSrtPlayback`
Details for playback from an live input using SRT.
- `Passphrase string`
The secret key to use for playback via SRT.
- `StreamID string`
The identifier of the live input to use for playback via SRT.
- `URL string`
The URL used to play live video over SRT.
- `Status LiveInputStatus`
The connection status of a live input.
- `const LiveInputStatusConnected LiveInputStatus = "connected"`
- `const LiveInputStatusReconnected LiveInputStatus = "reconnected"`
- `const LiveInputStatusReconnecting LiveInputStatus = "reconnecting"`
- `const LiveInputStatusClientDisconnect LiveInputStatus = "client_disconnect"`
- `const LiveInputStatusTTLExceeded LiveInputStatus = "ttl_exceeded"`
- `const LiveInputStatusFailedToConnect LiveInputStatus = "failed_to_connect"`
- `const LiveInputStatusFailedToReconnect LiveInputStatus = "failed_to_reconnect"`
- `const LiveInputStatusNewConfigurationAccepted LiveInputStatus = "new_configuration_accepted"`
- `UID string`
A unique identifier for a live input.
- `WebRtc LiveInputWebRtc`
Details for streaming to a live input using WebRTC.
- `URL string`
The WebRTC URL you provide to the broadcaster, which they stream live video to.
- `WebRtcPlayback LiveInputWebRtcPlayback`
Details for playback from a live input using WebRTC.
- `URL string`
The URL used to play live video over WebRTC.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
liveInput, err := client.Stream.LiveInputs.Update(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
stream.LiveInputUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", liveInput.UID)
}
```
#### 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": {
"created": "2014-01-02T02:20:00Z",
"deleteRecordingAfterDays": 45,
"enabled": true,
"meta": {
"name": "test stream 1"
},
"modified": "2014-01-02T02:20:00Z",
"recording": {
"allowedOrigins": [
"example.com"
],
"hideLiveViewerCount": false,
"mode": "off",
"requireSignedURLs": false,
"timeoutSeconds": 0
},
"rtmps": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"rtmpsPlayback": {
"streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"srt": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "srt://live.cloudflare.com:778"
},
"srtPlayback": {
"passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada",
"streamId": "f256e6ea9341d51eea64c9454659e576",
"url": "rtmps://live.cloudflare.com:443/live/"
},
"status": "connected",
"uid": "66be4bf738797e01e1fca35a7bdecdcd",
"webRTC": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish"
},
"webRTCPlayback": {
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play"
}
}
}
```
## Delete a live input
`client.Stream.LiveInputs.Delete(ctx, liveInputIdentifier, body) error`
**delete** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}`
Prevents a live input from being streamed to and makes the live input inaccessible to any future API calls.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `body LiveInputDeleteParams`
- `AccountID param.Field[string]`
Identifier.
### Example
```go
package main
import (
"context"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
err := client.Stream.LiveInputs.Delete(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
stream.LiveInputDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
}
```
#### Response
```json
{}
```
## Domain Types
### Live Input
- `type LiveInput struct{…}`
Details about a live input.
- `Created Time`
The date and time the live input was created.
- `DeleteRecordingAfterDays float64`
Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion.
- `Enabled bool`
Indicates whether the live input is enabled and can accept streams.
- `Meta unknown`
A user modifiable key-value store used to reference other systems of record for managing live inputs.
- `Modified Time`
The date and time the live input was last modified.
- `Recording LiveInputRecording`
Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied.
- `AllowedOrigins []string`
Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin.
- `HideLiveViewerCount bool`
Disables reporting the number of live viewers when this property is set to `true`.
- `Mode LiveInputRecordingMode`
Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input.
- `const LiveInputRecordingModeOff LiveInputRecordingMode = "off"`
- `const LiveInputRecordingModeAutomatic LiveInputRecordingMode = "automatic"`
- `RequireSignedURLs bool`
Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input.
- `TimeoutSeconds int64`
Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used.
- `Rtmps LiveInputRtmps`
Details for streaming to an live input using RTMPS.
- `StreamKey string`
The secret key to use when streaming via RTMPS to a live input.
- `URL string`
The RTMPS URL you provide to the broadcaster, which they stream live video to.
- `RtmpsPlayback LiveInputRtmpsPlayback`
Details for playback from an live input using RTMPS.
- `StreamKey string`
The secret key to use for playback via RTMPS.
- `URL string`
The URL used to play live video over RTMPS.
- `Srt LiveInputSrt`
Details for streaming to a live input using SRT.
- `Passphrase string`
The secret key to use when streaming via SRT to a live input.
- `StreamID string`
The identifier of the live input to use when streaming via SRT.
- `URL string`
The SRT URL you provide to the broadcaster, which they stream live video to.
- `SrtPlayback LiveInputSrtPlayback`
Details for playback from an live input using SRT.
- `Passphrase string`
The secret key to use for playback via SRT.
- `StreamID string`
The identifier of the live input to use for playback via SRT.
- `URL string`
The URL used to play live video over SRT.
- `Status LiveInputStatus`
The connection status of a live input.
- `const LiveInputStatusConnected LiveInputStatus = "connected"`
- `const LiveInputStatusReconnected LiveInputStatus = "reconnected"`
- `const LiveInputStatusReconnecting LiveInputStatus = "reconnecting"`
- `const LiveInputStatusClientDisconnect LiveInputStatus = "client_disconnect"`
- `const LiveInputStatusTTLExceeded LiveInputStatus = "ttl_exceeded"`
- `const LiveInputStatusFailedToConnect LiveInputStatus = "failed_to_connect"`
- `const LiveInputStatusFailedToReconnect LiveInputStatus = "failed_to_reconnect"`
- `const LiveInputStatusNewConfigurationAccepted LiveInputStatus = "new_configuration_accepted"`
- `UID string`
A unique identifier for a live input.
- `WebRtc LiveInputWebRtc`
Details for streaming to a live input using WebRTC.
- `URL string`
The WebRTC URL you provide to the broadcaster, which they stream live video to.
- `WebRtcPlayback LiveInputWebRtcPlayback`
Details for playback from a live input using WebRTC.
- `URL string`
The URL used to play live video over WebRTC.
# Outputs
## List all outputs associated with a specified live input
`client.Stream.LiveInputs.Outputs.List(ctx, liveInputIdentifier, query) (*SinglePage[Output], error)`
**get** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs`
Retrieves all outputs associated with a specified live input.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `query LiveInputOutputListParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type Output struct{…}`
- `Enabled bool`
When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
- `StreamKey string`
The streamKey used to authenticate against an output's target.
- `UID string`
A unique identifier for the output.
- `URL string`
The URL an output uses to restream.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.LiveInputs.Outputs.List(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
stream.LiveInputOutputListParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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": [
{
"enabled": true,
"streamKey": "uzya-f19y-g2g9-a2ee-51j2",
"uid": "baea4d9c515887b80289d5c33cf01145",
"url": "rtmp://a.rtmp.youtube.com/live2"
}
]
}
```
## Create a new output, connected to a live input
`client.Stream.LiveInputs.Outputs.New(ctx, liveInputIdentifier, params) (*Output, error)`
**post** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs`
Creates a new output that can be used to simulcast or restream live video to other RTMP or SRT destinations. Outputs are always linked to a specific live input — one live input can have many outputs.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `params LiveInputOutputNewParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `StreamKey param.Field[string]`
Body param: The streamKey used to authenticate against an output's target.
- `URL param.Field[string]`
Body param: The URL an output uses to restream.
- `Enabled param.Field[bool]`
Body param: When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
### Returns
- `type Output struct{…}`
- `Enabled bool`
When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
- `StreamKey string`
The streamKey used to authenticate against an output's target.
- `UID string`
A unique identifier for the output.
- `URL string`
The URL an output uses to restream.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
output, err := client.Stream.LiveInputs.Outputs.New(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
stream.LiveInputOutputNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
StreamKey: cloudflare.F("uzya-f19y-g2g9-a2ee-51j2"),
URL: cloudflare.F("rtmp://a.rtmp.youtube.com/live2"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", output.UID)
}
```
#### 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": {
"enabled": true,
"streamKey": "uzya-f19y-g2g9-a2ee-51j2",
"uid": "baea4d9c515887b80289d5c33cf01145",
"url": "rtmp://a.rtmp.youtube.com/live2"
}
}
```
## Update an output
`client.Stream.LiveInputs.Outputs.Update(ctx, liveInputIdentifier, outputIdentifier, params) (*Output, error)`
**put** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}`
Updates the state of an output.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `outputIdentifier string`
A unique identifier for the output.
- `params LiveInputOutputUpdateParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `Enabled param.Field[bool]`
Body param: When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
### Returns
- `type Output struct{…}`
- `Enabled bool`
When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
- `StreamKey string`
The streamKey used to authenticate against an output's target.
- `UID string`
A unique identifier for the output.
- `URL string`
The URL an output uses to restream.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
output, err := client.Stream.LiveInputs.Outputs.Update(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
"baea4d9c515887b80289d5c33cf01145",
stream.LiveInputOutputUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Enabled: cloudflare.F(true),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", output.UID)
}
```
#### 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": {
"enabled": true,
"streamKey": "uzya-f19y-g2g9-a2ee-51j2",
"uid": "baea4d9c515887b80289d5c33cf01145",
"url": "rtmp://a.rtmp.youtube.com/live2"
}
}
```
## Delete an output
`client.Stream.LiveInputs.Outputs.Delete(ctx, liveInputIdentifier, outputIdentifier, body) error`
**delete** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}`
Deletes an output and removes it from the associated live input.
### Parameters
- `liveInputIdentifier string`
A unique identifier for a live input.
- `outputIdentifier string`
A unique identifier for the output.
- `body LiveInputOutputDeleteParams`
- `AccountID param.Field[string]`
Identifier.
### Example
```go
package main
import (
"context"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
err := client.Stream.LiveInputs.Outputs.Delete(
context.TODO(),
"66be4bf738797e01e1fca35a7bdecdcd",
"baea4d9c515887b80289d5c33cf01145",
stream.LiveInputOutputDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
}
```
#### Response
```json
{}
```
## Domain Types
### Output
- `type Output struct{…}`
- `Enabled bool`
When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch.
- `StreamKey string`
The streamKey used to authenticate against an output's target.
- `UID string`
A unique identifier for the output.
- `URL string`
The URL an output uses to restream.
# Watermarks
## List watermark profiles
`client.Stream.Watermarks.List(ctx, query) (*SinglePage[Watermark], error)`
**get** `/accounts/{account_id}/stream/watermarks`
Lists all watermark profiles for an account.
### Parameters
- `query WatermarkListParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type Watermark struct{…}`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.Watermarks.List(context.TODO(), stream.WatermarkListParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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": [
{
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
]
}
```
## Watermark profile details
`client.Stream.Watermarks.Get(ctx, identifier, query) (*Watermark, error)`
**get** `/accounts/{account_id}/stream/watermarks/{identifier}`
Retrieves details for a single watermark profile.
### Parameters
- `identifier string`
The unique identifier for a watermark profile.
- `query WatermarkGetParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type Watermark struct{…}`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
watermark, err := client.Stream.Watermarks.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.WatermarkGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", watermark.UID)
}
```
#### 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": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
```
## Create watermark profiles via basic upload
`client.Stream.Watermarks.New(ctx, params) (*Watermark, error)`
**post** `/accounts/{account_id}/stream/watermarks`
Creates watermark profiles using a single `HTTP POST multipart/form-data` request.
### Parameters
- `params WatermarkNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `File param.Field[string]`
Body param: The image file to upload.
- `Name param.Field[string]`
Body param: A short description of the watermark profile.
- `Opacity param.Field[float64]`
Body param: The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding param.Field[float64]`
Body param: The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position param.Field[string]`
Body param: The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale param.Field[float64]`
Body param: The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
### Returns
- `type Watermark struct{…}`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
watermark, err := client.Stream.Watermarks.New(context.TODO(), stream.WatermarkNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
File: cloudflare.F("@/Users/rchen/Downloads/watermark.png"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", watermark.UID)
}
```
#### 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": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
```
## Delete watermark profiles
`client.Stream.Watermarks.Delete(ctx, identifier, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/watermarks/{identifier}`
Deletes a watermark profile.
### Parameters
- `identifier string`
The unique identifier for a watermark profile.
- `body WatermarkDeleteParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type WatermarkDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
watermark, err := client.Stream.Watermarks.Delete(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.WatermarkDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", watermark)
}
```
#### 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": ""
}
```
## Domain Types
### Watermark
- `type Watermark struct{…}`
- `Created Time`
The date and a time a watermark profile was created.
- `DownloadedFrom string`
The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null.
- `Height int64`
The height of the image in pixels.
- `Name string`
A short description of the watermark profile.
- `Opacity float64`
The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque.
- `Padding float64`
The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm.
- `Position string`
The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter.
- `Scale float64`
The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video.
- `Size float64`
The size of the image in bytes.
- `UID string`
The unique identifier for a watermark profile.
- `Width int64`
The width of the image in pixels.
# Webhooks
## View webhooks
`client.Stream.Webhooks.Get(ctx, query) (*WebhookGetResponse, error)`
**get** `/accounts/{account_id}/stream/webhook`
Retrieves a list of webhooks.
### Parameters
- `query WebhookGetParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type WebhookGetResponse interface{…}`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
webhook, err := client.Stream.Webhooks.Get(context.TODO(), stream.WebhookGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", webhook)
}
```
#### 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": {}
}
```
## Create webhooks
`client.Stream.Webhooks.Update(ctx, params) (*WebhookUpdateResponse, error)`
**put** `/accounts/{account_id}/stream/webhook`
Creates a webhook notification.
### Parameters
- `params WebhookUpdateParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `NotificationURL param.Field[string]`
Body param: The URL where webhooks will be sent.
### Returns
- `type WebhookUpdateResponse interface{…}`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
webhook, err := client.Stream.Webhooks.Update(context.TODO(), stream.WebhookUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
NotificationURL: cloudflare.F("https://example.com"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", webhook)
}
```
#### 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": {}
}
```
## Delete webhooks
`client.Stream.Webhooks.Delete(ctx, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/webhook`
Deletes a webhook.
### Parameters
- `body WebhookDeleteParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type WebhookDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
webhook, err := client.Stream.Webhooks.Delete(context.TODO(), stream.WebhookDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", webhook)
}
```
#### 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": "ok"
}
```
# Captions
## List captions or subtitles
`client.Stream.Captions.Get(ctx, identifier, query) (*SinglePage[Caption], error)`
**get** `/accounts/{account_id}/stream/{identifier}/captions`
Lists the available captions or subtitles for a specific video.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `query CaptionGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type Caption struct{…}`
- `Generated bool`
Whether the caption was generated via AI.
- `Label string`
The language label displayed in the native language to users.
- `Language string`
The language tag in BCP 47 format.
- `Status CaptionStatus`
The status of a generated caption.
- `const CaptionStatusReady CaptionStatus = "ready"`
- `const CaptionStatusInprogress CaptionStatus = "inprogress"`
- `const CaptionStatusError CaptionStatus = "error"`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
page, err := client.Stream.Captions.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.CaptionGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
```
#### 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": [
{
"generated": true,
"label": "Türkçe",
"language": "tr",
"status": "ready"
}
]
}
```
## Domain Types
### Caption
- `type Caption struct{…}`
- `Generated bool`
Whether the caption was generated via AI.
- `Label string`
The language label displayed in the native language to users.
- `Language string`
The language tag in BCP 47 format.
- `Status CaptionStatus`
The status of a generated caption.
- `const CaptionStatusReady CaptionStatus = "ready"`
- `const CaptionStatusInprogress CaptionStatus = "inprogress"`
- `const CaptionStatusError CaptionStatus = "error"`
# Language
## List captions or subtitles for a provided language
`client.Stream.Captions.Language.Get(ctx, identifier, language, query) (*Caption, error)`
**get** `/accounts/{account_id}/stream/{identifier}/captions/{language}`
Lists the captions or subtitles for provided language.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `language string`
The language tag in BCP 47 format.
- `query CaptionLanguageGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type Caption struct{…}`
- `Generated bool`
Whether the caption was generated via AI.
- `Label string`
The language label displayed in the native language to users.
- `Language string`
The language tag in BCP 47 format.
- `Status CaptionStatus`
The status of a generated caption.
- `const CaptionStatusReady CaptionStatus = "ready"`
- `const CaptionStatusInprogress CaptionStatus = "inprogress"`
- `const CaptionStatusError CaptionStatus = "error"`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
caption, err := client.Stream.Captions.Language.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"tr",
stream.CaptionLanguageGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", caption.Generated)
}
```
#### 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": {
"generated": true,
"label": "Türkçe",
"language": "tr",
"status": "ready"
}
}
```
## Generate captions or subtitles for a provided language via AI
`client.Stream.Captions.Language.New(ctx, identifier, language, body) (*Caption, error)`
**post** `/accounts/{account_id}/stream/{identifier}/captions/{language}/generate`
Generate captions or subtitles for provided language via AI.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `language string`
The language tag in BCP 47 format.
- `body CaptionLanguageNewParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type Caption struct{…}`
- `Generated bool`
Whether the caption was generated via AI.
- `Label string`
The language label displayed in the native language to users.
- `Language string`
The language tag in BCP 47 format.
- `Status CaptionStatus`
The status of a generated caption.
- `const CaptionStatusReady CaptionStatus = "ready"`
- `const CaptionStatusInprogress CaptionStatus = "inprogress"`
- `const CaptionStatusError CaptionStatus = "error"`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
caption, err := client.Stream.Captions.Language.New(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"tr",
stream.CaptionLanguageNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", caption.Generated)
}
```
#### 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": {
"generated": true,
"label": "Türkçe",
"language": "tr",
"status": "ready"
}
}
```
## Upload captions or subtitles
`client.Stream.Captions.Language.Update(ctx, identifier, language, params) (*Caption, error)`
**put** `/accounts/{account_id}/stream/{identifier}/captions/{language}`
Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. One caption or subtitle file per language is allowed.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `language string`
The language tag in BCP 47 format.
- `params CaptionLanguageUpdateParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `File param.Field[string]`
Body param: The WebVTT file containing the caption or subtitle content.
### Returns
- `type Caption struct{…}`
- `Generated bool`
Whether the caption was generated via AI.
- `Label string`
The language label displayed in the native language to users.
- `Language string`
The language tag in BCP 47 format.
- `Status CaptionStatus`
The status of a generated caption.
- `const CaptionStatusReady CaptionStatus = "ready"`
- `const CaptionStatusInprogress CaptionStatus = "inprogress"`
- `const CaptionStatusError CaptionStatus = "error"`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
caption, err := client.Stream.Captions.Language.Update(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"tr",
stream.CaptionLanguageUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
File: cloudflare.F("@/Users/kyle/Desktop/tr.vtt"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", caption.Generated)
}
```
#### 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": {
"generated": true,
"label": "Türkçe",
"language": "tr",
"status": "ready"
}
}
```
## Delete captions or subtitles
`client.Stream.Captions.Language.Delete(ctx, identifier, language, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/{identifier}/captions/{language}`
Removes the captions or subtitles from a video.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `language string`
The language tag in BCP 47 format.
- `body CaptionLanguageDeleteParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type CaptionLanguageDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
language, err := client.Stream.Captions.Language.Delete(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"tr",
stream.CaptionLanguageDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", language)
}
```
#### 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": ""
}
```
# Vtt
## Return WebVTT captions for a provided language
`client.Stream.Captions.Language.Vtt.Get(ctx, identifier, language, query) (*string, error)`
**get** `/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt`
Return WebVTT captions for a provided language.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `language string`
The language tag in BCP 47 format.
- `query CaptionLanguageVttGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type CaptionLanguageVttGetResponse string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
vtt, err := client.Stream.Captions.Language.Vtt.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
"tr",
stream.CaptionLanguageVttGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", vtt)
}
```
# Downloads
## List downloads
`client.Stream.Downloads.Get(ctx, identifier, query) (*DownloadGetResponse, error)`
**get** `/accounts/{account_id}/stream/{identifier}/downloads`
Lists the downloads created for a video.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `query DownloadGetParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type DownloadGetResponse struct{…}`
An object with download type keys. Each key is optional and only present if that download type has been created.
- `Audio DownloadGetResponseAudio`
The audio-only download. Only present if this download type has been created.
- `PercentComplete float64`
Indicates the progress as a percentage between 0 and 100.
- `Status DownloadGetResponseAudioStatus`
The status of a generated download.
- `const DownloadGetResponseAudioStatusReady DownloadGetResponseAudioStatus = "ready"`
- `const DownloadGetResponseAudioStatusInprogress DownloadGetResponseAudioStatus = "inprogress"`
- `const DownloadGetResponseAudioStatusError DownloadGetResponseAudioStatus = "error"`
- `URL string`
The URL to access the generated download.
- `Default DownloadGetResponseDefault`
The default video download. Only present if this download type has been created.
- `PercentComplete float64`
Indicates the progress as a percentage between 0 and 100.
- `Status DownloadGetResponseDefaultStatus`
The status of a generated download.
- `const DownloadGetResponseDefaultStatusReady DownloadGetResponseDefaultStatus = "ready"`
- `const DownloadGetResponseDefaultStatusInprogress DownloadGetResponseDefaultStatus = "inprogress"`
- `const DownloadGetResponseDefaultStatusError DownloadGetResponseDefaultStatus = "error"`
- `URL string`
The URL to access the generated download.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
download, err := client.Stream.Downloads.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.DownloadGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", download.Audio)
}
```
#### 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": {
"audio": {
"percentComplete": 0,
"status": "ready",
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4"
},
"default": {
"percentComplete": 0,
"status": "ready",
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4"
}
}
}
```
## Create downloads
`client.Stream.Downloads.New(ctx, identifier, params) (*DownloadNewResponse, error)`
**post** `/accounts/{account_id}/stream/{identifier}/downloads`
Creates a download for a video when a video is ready to view. Use `/downloads/{download_type}` instead for type-specific downloads. Available types are `default` and `audio`.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `params DownloadNewParams`
- `AccountID param.Field[string]`
Path param: Identifier.
- `Body param.Field[unknown]`
Body param
### Returns
- `type DownloadNewResponse struct{…}`
- `PercentComplete float64`
Indicates the progress as a percentage between 0 and 100.
- `Status DownloadNewResponseStatus`
The status of a generated download.
- `const DownloadNewResponseStatusReady DownloadNewResponseStatus = "ready"`
- `const DownloadNewResponseStatusInprogress DownloadNewResponseStatus = "inprogress"`
- `const DownloadNewResponseStatusError DownloadNewResponseStatus = "error"`
- `URL string`
The URL to access the generated download.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
download, err := client.Stream.Downloads.New(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.DownloadNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: map[string]interface{}{
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", download.PercentComplete)
}
```
#### 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": {
"percentComplete": 0,
"status": "ready",
"url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4"
}
}
```
## Delete downloads
`client.Stream.Downloads.Delete(ctx, identifier, body) (*string, error)`
**delete** `/accounts/{account_id}/stream/{identifier}/downloads`
Delete the downloads for a video. Use `/downloads/{download_type}` instead for type-specific downloads. Available types are `default` and `audio`.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `body DownloadDeleteParams`
- `AccountID param.Field[string]`
Identifier.
### Returns
- `type DownloadDeleteResponseEnvelopeResult string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
download, err := client.Stream.Downloads.Delete(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.DownloadDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", download)
}
```
#### 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": "ok"
}
```
# Embed
## Retrieve embed Code HTML
`client.Stream.Embed.Get(ctx, identifier, query) (*string, error)`
**get** `/accounts/{account_id}/stream/{identifier}/embed`
Fetches an HTML code snippet to embed a video in a web page delivered through Cloudflare. On success, returns an HTML fragment for use on web pages to display a video. On failure, returns a JSON response body.
### Parameters
- `identifier string`
A Cloudflare-generated unique identifier for a media item.
- `query EmbedGetParams`
- `AccountID param.Field[string]`
The account identifier tag.
### Returns
- `type EmbedGetResponse string`
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
embed, err := client.Stream.Embed.Get(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.EmbedGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", embed)
}
```
#### Response
```json
""
```
# Token
## Create signed URL tokens for videos
`client.Stream.Token.New(ctx, identifier, params) (*TokenNewResponse, error)`
**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 TokenNewParams`
- `AccountID param.Field[string]`
Path param: The account identifier tag.
- `ID param.Field[string]`
Body param: The optional ID of a Stream signing key. If present, the `pem` field is also required.
- `AccessRules param.Field[[]TokenNewParamsAccessRule]`
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 TokenNewParamsAccessRulesAction`
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.
- `const TokenNewParamsAccessRulesActionAllow TokenNewParamsAccessRulesAction = "allow"`
- `const TokenNewParamsAccessRulesActionBlock TokenNewParamsAccessRulesAction = "block"`
- `Country []string`
An array of 2-letter country codes in ISO 3166-1 Alpha-2 format used to match requests.
- `IP []string`
An array of IPv4 or IPV6 addresses or CIDRs used to match requests.
- `Type TokenNewParamsAccessRulesType`
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.
- `const TokenNewParamsAccessRulesTypeAny TokenNewParamsAccessRulesType = "any"`
- `const TokenNewParamsAccessRulesTypeIPSrc TokenNewParamsAccessRulesType = "ip.src"`
- `const TokenNewParamsAccessRulesTypeIPGeoipCountry TokenNewParamsAccessRulesType = "ip.geoip.country"`
- `Downloadable param.Field[bool]`
Body param: The optional boolean value that enables using signed tokens to access MP4 download links for a video.
- `Exp param.Field[int64]`
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 param.Field[int64]`
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 param.Field[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
- `type TokenNewResponse struct{…}`
- `Token string`
The signed token used with the signed URLs feature.
### Example
```go
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/stream"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
token, err := client.Stream.Token.New(
context.TODO(),
"ea95132c15732412d22c1476fa83f27a",
stream.TokenNewParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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"
}
}
```