Click here to see your recently viewed pages and most viewed pages.
Hide

PlaylistItems: insert

Adds a resource to a playlist. Try it now.

Quota impact: A call to this method has a quota cost of 50 units in addition to the costs of the specified resource parts.

Request

HTTP request

POST https://www.googleapis.com/youtube/v3/playlistItems

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
https://www.googleapis.com/auth/youtube.force-ssl

Parameters

The table below lists the parameters that this query supports. All of the parameters listed are query parameters.

Parameter name Value Description
Required parameters
part string The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include.

The list below contains the part names that you can include in the parameter value and the quota cost for each part:
  • contentDetails: 2
  • id: 0
  • snippet: 2
  • status: 2
Optional parameters
onBehalfOfContentOwner string This parameter can only be used in a properly authorized request. Note: This parameter is intended exclusively for YouTube content partners.

The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.

Request body

Provide a playlistItem resource in the request body. For that resource:

  • You must specify a value for these properties:

    • snippet.playlistId
    • snippet.resourceId

  • You can set values for these properties:

    • snippet.playlistId
    • snippet.position
    • snippet.resourceId
    • contentDetails.note
    • contentDetails.startAt
    • contentDetails.endAt

Response

If successful, this method returns a playlistItem resource in the response body.

Errors

The table below identifies error messages that the API could return in response to a call to this method. Please see the error message documentation for more detail.

Error type Error detail Description
duplicate videoAlreadyInPlaylist The video that you are trying to add to the playlist is already in the playlist.
forbidden (403) playlistContainsMaximumNumberOfVideos The playlist already contains the maximum allowed number of items.
invalidValue (400) invalidPlaylistItemPosition The request attempts to set the playlist item's position to an invalid or unsupported value. Check the value of the position property in the resource's snippet.
invalidValue (400) invalidResourceType The type specified for the resource ID is not supported for this operation. The resource ID identifies the item being added to the playlist – e.g. youtube#video.
invalidValue (400) manualSortRequired The request attempts to set the playlist item's position, but the playlist does not use manual sorting. (For example, playlist items might be sorted by date or popularity.) You can address the error by removing the snippet.position element from the resource that the request is inserting. If you want the playlist item to have a particular position in the list, you need to first update the playlist's Ordering option to Manual in the playlist's settings. This settings can be adjusted in the YouTube Video Manager.
notFound (404) playlistNotFound The playlist identified with the request's playlistId parameter cannot be found.
notFound (404) videoNotFound The video that you are trying to add to the playlist cannot be found. Check the value of the videoId property to ensure that it is correct.
required (400) channelIdRequired The request does not specify a value for the required channelId property.
required (400) playlistIdRequired The request does not specify a value for the required playlistId property.
required (400) resourceIdRequired The request must contain a resource in which the snippet object specifies a resourceId.

Try it!

Use the API Explorer to call this method on live data and see the API request and response.