YouTube Content ID Service

The YouTube Content ID service allows you to use the YouTube Content ID API in Apps Script. This API lets developers interact directly with YouTube's Content ID rights management system. As a YouTube partner, you can use the API to create and manage your assets, claims and campaigns.


For detailed information on this service, see the reference documentation for the public YouTube Content ID API. Like all advanced services in Apps Script, the advanced YouTube Content ID service uses the same objects, methods, and parameters as the public API.

Sample code

The sample code below uses version 1 of the YouTube Content ID API.

Claim your video

This function creates a partner-uploaded claim on your video with the specified asset and policy rules.

function claimYourVideoWithMonetizePolicy() {
  // The ID of the content owner that you are acting on behalf of.
  var onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  // A YouTube video ID to claim. In this example, the video must be uploaded
  // to one of your onBehalfOfContentOwner's linked channels.
  var videoId = 'replaceWithYourVideoID';
  var assetId = 'replaceWithYourAssetID';
  var claimToInsert = {
    'videoId': videoId,
    'assetId': assetId,
    'contentType': 'audiovisual',
    // Set the claim policy to monetize. You can also specify a policy ID here
    // instead of policy rules.
    // For details, please refer to the YouTube Content ID API Policies
    // documentation:
    'policy': {'rules': [{'action': 'monetize'}]},
  try {
    var claimInserted = YoutubeContentId.Claims.insert(claimToInsert,
        {'onBehalfOfContentOwner': onBehalfOfContentOwner});
    Logger.log('Claim created on video %s: %s', videoId, claimInserted);
  } catch (e) {
    Logger.log('Failed to create claim on video %s, error: %s',
               videoId, e.message);

Update asset ownership

This function updates your ownership on an existing asset.

function updateAssetOwnership() {
  var onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  var assetId = 'replaceWithYourAssetID';
  // The new ownership here would replace your existing ownership on the asset.
  var myAssetOwnership = {
    'general': [
        'ratio': 100,
        'owner': onBehalfOfContentOwner,
        'type': 'include',
        'territories': [
  try {
    var updatedOwnership = YoutubeContentId.Ownership.update(myAssetOwnership,
        assetId, {'onBehalfOfContentOwner': onBehalfOfContentOwner});
    Logger.log('Ownership updated on asset %s: %s', assetId, updatedOwnership);
  } catch (e) {
    Logger.log('Ownership update failed on asset %s, error: %s',
               assetId, e.message);

Release a claim

This function releases an existing claim you have on a video.

function releaseClaim() {
  var onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  // The ID of the claim to be released.
  var claimId = 'replaceWithYourClaimID';
  // To release the claim, change the resource's status to inactive.
  var claimToBeReleased = {
    'status': 'inactive'
  try {
    var claimReleased = YoutubeContentId.Claims.patch(claimToBeReleased,
        claimId, {'onBehalfOfContentOwner': onBehalfOfContentOwner});
    Logger.log('Claim %s was released: %s', claimId, claimReleased);
  } catch (e) {
    Logger.log('Failed to release claim %s, error: %s', claimId, e.message);

Send feedback about...

Apps Script
Apps Script