# Direct Upload ## Upload videos via direct upload URLs `stream.direct_upload.create(DirectUploadCreateParams**kwargs) -> DirectUploadCreateResponse` **post** `/accounts/{account_id}/stream/direct_upload` Creates a direct upload that allows video uploads without an API key. ### Parameters - `account_id: str` The account identifier tag. - `max_duration_seconds: int` 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. - `allowed_origins: Optional[SequenceNotStr[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. - `creator: Optional[str]` A user-defined identifier for the media creator. - `expiry: Optional[Union[str, datetime]]` The date and time after upload when videos will not be accepted. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `require_signed_urls: Optional[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. - `scheduled_deletion: Optional[Union[str, datetime]]` 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. - `thumbnail_timestamp_pct: Optional[float]` 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: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. - `upload_creator: Optional[str]` A user-defined identifier for the media creator. ### Returns - `class DirectUploadCreateResponse: …` - `scheduled_deletion: Optional[datetime]` 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: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `upload_url: Optional[str]` The URL an unauthenticated upload can use for a single `HTTP POST multipart/form-data` request. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` 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: Optional[float]` 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: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` 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: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) direct_upload = client.stream.direct_upload.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", max_duration_seconds=1, ) print(direct_upload.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 } } } ``` ## Domain Types ### Direct Upload Create Response - `class DirectUploadCreateResponse: …` - `scheduled_deletion: Optional[datetime]` 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: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `upload_url: Optional[str]` The URL an unauthenticated upload can use for a single `HTTP POST multipart/form-data` request. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` 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: Optional[float]` 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: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` 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: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels.