The Google Ads API supports linking Google Ads accounts to other product accounts.
This guide explains how to use the API to link your accounts.

## Ways to link accounts

When linking a Google Ads account to another product account, there are two
different ways in which the linking can happen.

> [!NOTE]
> **Note:** The following steps outline the general process for linking a Google Ads account to a product account. For Merchant Center accounts, new link requests must be initiated using the Merchant Center interface or the [Merchant API](https://developers.google.com/merchant/api/reference/rest/accounts_v1/accounts.services/propose). The Google Ads API can be used to manage (approve, reject, remove) and report on Merchant Center links and invitations.

### Invitation flow

Use the invitation flow when you have administrator access to the Google Ads
account, but not the product account. This flow works in two scenarios:

1. You want to link the two accounts and create an invitation for an administrator of the product account. The product account administrator accepts the invitation to complete the account linking process.
2. The product account administrator wants to link the two accounts, but doesn't have access to the Google Ads account. The product account administrator creates an invitation, and you accept the invitation and complete the linking process.

Use the following methods in this scenario:

| Scenario | Action | Remarks |
| Scenario 1 | Create an invitation | Use the [`ProductLinkInvitationService.CreateProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationService/CreateProductLinkInvitation) method to create an invitation. The [`status`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitation#status) of the [`ProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitation) shouldn't be set; the Google Ads API server will set this to `REQUESTED` upon the successful completion of the API call. When creating an invitation for an Advertising Partner ([`AdvertisingPartnerLinkInvitationIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvertisingPartnerLinkInvitationIdentifier)), [`advertising_partner_properties.allowed_domain`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvertisingPartnerLinkInvitationProperties#allowed_domain) is required starting in v25 (and optional in v24 and earlier). |
| Scenario 1 |
|---|---|---|
| Inspect the status of an invitation | Use [`GoogleAdsService.Search`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/Search) or [`GoogleAdsService.SearchStream`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/SearchStream) to query the [`product_link_invitation`](https://developers.google.com/google-ads/api/fields/v26/product_link_invitation) resource and inspect its status. |
| Accept or reject an invitation | Use the [`ProductLinkInvitationService.UpdateProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationService/UpdateProductLinkInvitation) method to update the status of the [`ProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitation) to `ACCEPTED` or `REJECTED`. |
| Revoke an invitation | Use the [`ProductLinkInvitationService.RemoveProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationService/RemoveProductLinkInvitation) method to revoke an existing [`ProductLinkInvitation`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitation). |

The following common errors can be thrown in this workflow:

| Error code | Explanation |
|---|---|
| [`ProductLinkInvitationError.PERMISSION_DENIED`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationErrorEnum.ProductLinkInvitationError#permission_denied) | The customer doesn't have the permission to perform this action. |
| [`ProductLinkInvitationError.NO_INVITATION_REQUIRED`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationErrorEnum.ProductLinkInvitationError#no_invitation_required) | An invitation couldn't be created, since the user already has administrator access to the invited account. The user should use the ProductLinkService to directly create an active link. |

### Direct linking flow

Use the direct linking flow when you have administrator access to both the
Google Ads account and the product account. In this case, directly link the
Google Ads account to the product account instead of sending an invitation.

Use the following methods in this scenario:

| Action | Remarks |
|---|---|
| Create an active link | Use [`ProductLinkService.CreateProductLink`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkService/CreateProductLink) to create a [`ProductLink`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLink). |
| Disable an active link | Use [`ProductLinkService.RemoveProductLink`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkService/RemoveProductLink) to remove an active [`ProductLink`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLink). |
| Retrieve active links | Use [`GoogleAdsService.Search`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/Search) or [`GoogleAdsService.SearchStream`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/SearchStream) to query the [`product_link`](https://developers.google.com/google-ads/api/fields/v26/product_link) resource. |

The following common errors may be thrown in this workflow:

| Error code | Explanation |
|---|---|
| [` ProductLinkError.CREATION_NOT_PERMITTED`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkErrorEnum.ProductLinkError#creation_not_permitted) | An account linking was attempted using the direct link flow, but this isn't supported due to lack of permissions. The user should use [`ProductLinkInvitationService`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkInvitationService) to do the invitation flow instead. |
| [` ProductLinkError.INVITATION_EXISTS`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkErrorEnum.ProductLinkError#invitation_exists) | A link cannot be created because a pending invitation already exists. |

## Retrieve existing product links

You can retrieve all product links associated with your Google Ads account using
a GAQL query against the [`product_link`](https://developers.google.com/google-ads/api/fields/v26/product_link) resource.

    SELECT
      product_link.product_link_id,
      product_link.type
    FROM product_link

The `product_link.type` field indicates the type of linked product or service.
Depending on the `type`, other fields within the `product_link` resource will be
populated, providing more details about the link. For example, if the type is
`DATA_PARTNER`, the `data_partner` field will contain information about the
linked data partner account.

This lets you obtain a list of external services and product accounts linked
directly to your Google Ads account, such as Merchant Center, Google Ads,
Advertising Partners, or data partners.

## Changes to `AccountLinkService`

If you use [`AccountLinkService`](https://developers.google.com/google-ads/api/reference/rpc/v26/AccountLinkService) to link a Google Ads account to another
product account, you must migrate your existing application to one of the
workflows listed earlier. For the following link types, migrate off
[`AccountLinkService`](https://developers.google.com/google-ads/api/reference/rpc/v26/AccountLinkService) and use [`ProductLinkService`](https://developers.google.com/google-ads/api/reference/rpc/v26/ProductLinkService):

- [`GoogleAdsIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsIdentifier)
- [`MerchantCenterIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/MerchantCenterIdentifier)
- [`AdvertisingPartnerIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvertisingPartnerIdentifier)
- [`DataPartnerIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/DataPartnerIdentifier)

For [`ThirdPartyAppAnalyticsLinkIdentifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/ThirdPartyAppAnalyticsLinkIdentifier), continue to use
[`AccountLinkService`](https://developers.google.com/google-ads/api/reference/rpc/v26/AccountLinkService).