AI-generated Key Takeaways
- 
          The Google Ads API supports linking YouTube videos to your Google Ads account. 
- 
          Videos can be linked to your account either by you requesting a link from a creator or by a creator requesting a link to your account. 
- 
          Specific API methods are used for actions like creating, inspecting, revoking, removing, accepting, or rejecting video link requests. 
- 
          Common errors in this workflow include permission denied and invalid YouTube video ID. 
The Google Ads API supports linking YouTube videos to your Google Ads account. This guide explains how to use the API to add and remove links to your account.
Link videos
Videos can be linked to your account in one of two ways, depending on who starts the process, either:
- You request that a video is linked to your account. In this scenario, you send a request to a creator, which they must accept in order to establish the link to their video. You can revoke a request that has been extended before it's accepted, and also remove a linked video after it's accepted.
- The creator of the video requests that their video is linked to your Google Ads account. You can then choose to accept or reject their request.
The following methods are used in each scenario:
| Scenario | Action | Remarks | 
|---|---|---|
| Scenario 1 | Get the video information from the YouTube API | Use the YouTube API
    to get the channel_idto send the video link request to, or thevideo_idof the video you want to link. Thevideo_idcan also be pulled
    from the URL of a video by pulling the 11 characters after"v=". | 
| Create a link request | Use the DataLinkService.CreateDataLinkmethod
    to create a link request. Thestatusof theDataLinkshouldn't
    be set; the Google Ads API server will set this toREQUESTEDupon the
    successful completion of the API call. | |
| Inspect the status of a request | Use GoogleAdsService.SearchStreamorGoogleAdsService.Searchto query thedata_linkresource and inspect itsstatus. | |
| Revoke a request | Use the DataLinkService.UpdateDataLinkmethod
    to revoke a link request by changing thestatusof theDataLinkfromREQUESTEDtoREVOKED. | |
| Remove a link | Use DataLinkService.RemoveDataLinkto remove a linked video. | |
| Scenario 2 | Retrieve an invitation | Use GoogleAdsService.SearchorGoogleAdsService.SearchStreamto query thedata_linkresource. Filter forstatus = PENDING_APPROVALto find link requests
    to accept or reject. | 
| Accept or reject a link request | Use the DataLinkService.UpdateDataLinkmethod to update the status
    of theDataLinktoENABLEDto accept orREJECTEDto reject the
    request. | 
The following common errors can be thrown in this workflow:
| Error code | Explanation | 
|---|---|
| DataLinkError.PERMISSION_DENIED | The customer doesn't have the permission to perform this action. | 
| DataLinkError.YOUTUBE_VIDEO_ID_INVALID | A video link couldn't be created, since the video ID is invalid. |