Uploads an image for a post and returns an upload token. To attach the image to a post, set the token as an attachments.imageAttachments[].uploadToken value when you call the posts.insert method.
This method supports media upload. Uploaded files must conform to these constraints:
- Maximum file size: 16MB
- Accepted Media MIME types:
image/jpeg,image/png,image/gif,image/webp,application/octet-stream - Image formats: JPEG, PNG, GIF, or WebP. YouTube checks the format from the file contents.
- Aspect ratio: Between 2:5 and 5:2 (width to height), inclusive.
Quota impact: A call to this method has a quota cost of 1 unit. The cost counts against the Post Modifications and Image Uploads quota, which is separate from the default YouTube Data API quota.
Request
HTTP request
POST https://www.googleapis.com/upload/youtube/v3/posts/image
Authorization
This request requires authorization with at least one of the following scopes (read more about authentication and authorization).
| Scope |
|---|
https://www.googleapis.com/auth/youtubepartner |
https://www.googleapis.com/auth/youtube.upload |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
The authorized user must own the channel or have permission to create posts for it.
Parameters
The following table lists the parameters that this query supports. All of the parameters listed are query parameters.
| Parameters | |
|---|---|
| Required parameters | |
channelId |
stringThe channelId parameter specifies the ID of the channel that publishes the post that uses this image.The returned upload token works only in posts for this channel. |
Request body
The body of the request contains the binary image payload that you are uploading. It doesn't contain a post resource.
Response
If successful, this method returns a response body with the following structure:
{
"imageUploadToken": string
}Properties
The following table defines the properties that appear in this resource:
| Properties | |
|---|---|
imageUploadToken |
stringThe token that identifies the uploaded image. Set this value as an attachments.imageAttachments[].uploadToken value when you call the posts.insert method for the same channel. |
Errors
The following table identifies error messages that the API could return in response to a call to this method. For more detail, see the error message documentation.
| Error type | Error detail | Description |
|---|---|---|
invalidValue (400) |
invalidMetadata |
The request contains invalid metadata values. |
forbidden (403) |
forbidden |
The request is not properly authorized. |
internalError (500) |
internalError |
Internal error encountered. |