Here's how to install and configure a client library or REST.

## Prerequisites

Before installing a client library, complete the steps in
[Set up API access](https://developers.google.com/data-manager/api/devguides/quickstart/set-up-access), including
configuring [Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials).

## Installation steps

On your local machine, install the client library of your choice:

### REST

1. Update the placeholders in the following sample, such as <var translate="no">OPERATING_ACCOUNT_PRODUCT</var>, <var translate="no">OPERATING_ACCOUNT_ID</var>, and <var translate="no">AUDIENCE_ID</var>, with the values for your account and destination.
2. Replace <var translate="no">PROJECT_ID</var> with the ID of your Google Cloud.
3. Copy the sample to the command line to send the request. Only use the
   **Data partner** sample if you're accessing the operating account through
   a partner link. Otherwise, use the **Advertiser** sample.

   ### Advertiser

       #!/bin/bash

       # Uses gcloud to get an access token. If the Application Default
       # Credentials aren't for a service account then the command that
       # specifies --scopes fails, so this sample falls back to the command
       # without the --scopes argument.
       DATA_MANAGER_ACCESS_TOKEN="$(gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/datamanager || \
       gcloud auth application-default print-access-token)"

       # Fetches and prints the scope information for the access token. If you
       # get scope-related errors when you send the request in the next step,
       # verify that this output includes the Data Manager API scope:
       #   https://www.googleapis.com/auth/datamanager
       curl https://www.googleapis.com/oauth2/v1/tokeninfo?access_token="${DATA_MANAGER_ACCESS_TOKEN}"

       # Sends the request.
       curl -X POST "https://datamanager.googleapis.com/v1/audienceMembers:ingest" \
       --header "Authorization: Bearer ${DATA_MANAGER_ACCESS_TOKEN}" \
       --header "x-goog-user-project: PROJECT_ID" \
       --header "Content-Type: application/json" \
       --data @- <<EOF
       {
         "destinations": [
           {
             "operatingAccount": {
               "accountType": "OPERATING_ACCOUNT_TYPE",
               "accountId": "OPERATING_ACCOUNT_ID"
             },
             "loginAccount": {
               "accountType": "LOGIN_ACCOUNT_TYPE",
               "accountId": "LOGIN_ACCOUNT_ID"
             },
             "productDestinationId": "AUDIENCE_ID"
           }
         ],
         "audienceMembers": [
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3"
                   },
                   {
                     "emailAddress": "1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "2ef46c4214c3fc1b277a2d976d55194e12b899aa50d721f28da858c7689756e3"
                   },
                   {
                     "emailAddress": "54e410b14fa652a4b49b43aff6eaf92ad680d4d1e5e62ed71b86cd3188385a51"
                   },
                   {
                     "emailAddress": "e8bd3f8da6f5af73bec1ab3fbf7beb47482c4766dfdfc94e6bd89e359c139478"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "05bb62526f091b45d20e243d194766cca8869137421047dc53fa4876d111a6f0"
                   },
                   {
                     "emailAddress": "f1fcde379f31f4d446b76ee8f34860eca2288adc6b6d6c0fdc56d9eee75a2fa5"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "83a834cc5327bc4dee7c5408988040dc5813c7662611cd93b707aff72bf7d33f"
                   },
                   {
                     "emailAddress": "223ebda6f6889b1494551ba902d9d381daf2f642bae055888e96343d53e9f9c4"
                   }
                 ]
               }
             }
           }
         ],
         "consent": {
           "adUserData": "CONSENT_GRANTED",
           "adPersonalization": "CONSENT_GRANTED"
         },
         "encoding": "HEX",
         "termsOfService": {
           "customerMatchTermsOfServiceStatus": "ACCEPTED"
         },
         "validateOnly": true
       }
       EOF

   ### Data partner

       #!/bin/bash

       # Uses gcloud to get an access token. If the Application Default
       # Credentials aren't for a service account then the command that
       # specifies --scopes fails, so this sample falls back to the command
       # without the --scopes argument.
       DATA_MANAGER_ACCESS_TOKEN="$(gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/datamanager || \
       gcloud auth application-default print-access-token)"

       # Fetches and prints the scope information for the access token. If
       # you get scope-related errors when you send the request in the next
       # step, verify that this output includes the Data Manager API scope:
       #   https://www.googleapis.com/auth/datamanager
       curl https://www.googleapis.com/oauth2/v1/tokeninfo?access_token="${DATA_MANAGER_ACCESS_TOKEN}"

       # Sends the request.
       curl -X POST "https://datamanager.googleapis.com/v1/audienceMembers:ingest" \
       --header "Authorization: Bearer ${DATA_MANAGER_ACCESS_TOKEN}" \
       --header "x-goog-user-project: PROJECT_ID" \
       --header "Content-Type: application/json" \
       --data @- <<EOF
       {
         "destinations": [
           {
             "operatingAccount": {
               "accountType": "OPERATING_ACCOUNT_TYPE",
               "accountId": "OPERATING_ACCOUNT_ID"
             },
             "loginAccount": {
               "accountType": "LOGIN_ACCOUNT_TYPE",
               "accountId": "LOGIN_ACCOUNT_ID"
             },
             "linkedAccount": {
               "accountType": "LINKED_ACCOUNT_TYPE",
               "accountId": "LINKED_ACCOUNT_ID"
             },
             "productDestinationId": "AUDIENCE_ID"
           }
         ],
         "audienceMembers": [
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3"
                   },
                   {
                     "emailAddress": "1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "2ef46c4214c3fc1b277a2d976d55194e12b899aa50d721f28da858c7689756e3"
                   },
                   {
                     "emailAddress": "54e410b14fa652a4b49b43aff6eaf92ad680d4d1e5e62ed71b86cd3188385a51"
                   },
                   {
                     "emailAddress": "e8bd3f8da6f5af73bec1ab3fbf7beb47482c4766dfdfc94e6bd89e359c139478"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "05bb62526f091b45d20e243d194766cca8869137421047dc53fa4876d111a6f0"
                   },
                   {
                     "emailAddress": "f1fcde379f31f4d446b76ee8f34860eca2288adc6b6d6c0fdc56d9eee75a2fa5"
                   }
                 ]
               }
             }
           },
           {
             "compositeData": {
               "userData": {
                 "userIdentifiers": [
                   {
                     "emailAddress": "83a834cc5327bc4dee7c5408988040dc5813c7662611cd93b707aff72bf7d33f"
                   },
                   {
                     "emailAddress": "223ebda6f6889b1494551ba902d9d381daf2f642bae055888e96343d53e9f9c4"
                   }
                 ]
               }
             }
           }
         ],
         "consent": {
           "adUserData": "CONSENT_GRANTED",
           "adPersonalization": "CONSENT_GRANTED"
         },
         "encoding": "HEX",
         "termsOfService": {
           "customerMatchTermsOfServiceStatus": "ACCEPTED"
         },
         "validateOnly": true
       }
       EOF

### .NET

### Install the client library

Follow the instructions in the [.NET client library installation
guide](https://www.nuget.org/packages/Google.Ads.DataManager.V1#package-manager) to add a dependency to the client library in your
project.

### Optional: Get the utility library and code samples.

1. Clone the [GitHub
   repository](https://github.com/googleads/data-manager-dotnet).

       git clone https://github.com/googleads/data-manager-dotnet.git

2. In your .NET project, declare a `ProjectReference` dependency on the
   utility library. Replace <var translate="no">PATH_TO_UTILITY_LIBRARY</var> with the
   location where you cloned the `data-manager-dotnet` repository.

       <ProjectReference Include="PATH_TO_UTILITY_LIBRARY\Google.Ads.DataManager.Util\src\Google.Ads.DataManager.Util.csproj" />

3. To format data, use the `Formatter` utility in your .NET project.

4. Browse code samples in the `samples` subdirectory or [on
   GitHub](https://github.com/googleads/data-manager-dotnet/tree/main/samples).

   Change to the `samples` directory and use `dotnet run` to get the list
   of available samples.

       dotnet run

   Pass the `--help` argument when running a sample to print a usage
   statement with expected parameters.

       dotnet run -- ingest-audience-members --help

   To help you get started with some sample data, use the file at
   [`samples/sampledata/audience_members_1.json`](https://github.com/googleads/data-manager-dotnet/blob/main/samples/sampledata/audience_members_1.json).

### Go

### Install the client library

    go get cloud.google.com/go/datamanager/apiv1@latest

Follow the instructions in the [Go client library guide](https://pkg.go.dev/cloud.google.com/go/datamanager/apiv1) for more
information.

### Java

### Install the client library

Follow the instructions in the [Java client library installation
guide](https://github.com/googleapis/google-cloud-java/tree/main/java-datamanager#quickstart) to add a dependency to the client library in your
project.

### Optional: Get the utility library and code samples.

1. Clone the [GitHub
   repository](https://github.com/googleads/data-manager-java).

       git clone https://github.com/googleads/data-manager-java.git

2. Navigate to the `data-manager-java` directory.

3. Build and publish the utility library to your local Maven repository.

       ./gradlew data-manager-util:install

4. In your Java project, declare a dependency on the utility library.

   Gradle:

       implementation 'com.google.api-ads:data-manager-util:0.2.0'

   Maven:

       <dependency>
          <groupId>com.google.api-ads</groupId>
          <artifactId>data-manager-util</artifactId>
          <version>0.2.0</version>
       </dependency>

5. To format and encrypt the data, use the `UserDataFormatter` and
   `Encrypter` utilities in your Java
   project.

6. Browse code samples in the `data-manager-samples` subdirectory or [on
   GitHub](https://github.com/googleads/data-manager-java/tree/main/data-manager-samples).
   To run a sample from the command line, use the Gradle `run` task.

   For example, the following command runs the `IngestAudienceMembers`
   sample and prints a usage statement:

       ./gradlew data-manager-samples:run \
          --args='IngestAudienceMembers --help'

   To help you get started with some sample data, use the file at
   [`data-manager-samples/src/main/resources/sampledata/audience_members_1.json`](https://github.com/googleads/data-manager-java/blob/main/data-manager-samples/src/main/resources/sampledata/audience_members_1.json).

### Node.js

### Install the client library

Follow the instructions in the [Node.js client library installation
guide](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-ads-datamanager#quickstart) to add a dependency to the
[`@google-ads/datamanager`](https://www.npmjs.com/package/@google-ads/datamanager) client library in your project.

### Optional: Get the utility library and code samples.

1. Clone the [GitHub
   repository](https://github.com/googleads/data-manager-node).

       git clone https://github.com/googleads/data-manager-node.git

2. Navigate to the `data-manager-node` directory.

3. Run the following command to install dependencies.

       npm install

4. Change to the `util` directory.

       cd util

5. Run the following command to compile and pack the utility library into
   a `.tgz` file for use with `npm`.

       npm pack

   The command generates an archive named
   `google-ads-datamanager-util-0.2.0.tgz`.
   Take note of the file location so you can use it in the next steps.
6. In your Node.js project, declare a dependency on the Data Manager API
   utility library by adding a `dependencies` entry for the full path and
   filename of the
   `google-ads-datamanager-util-0.2.0.tgz`
   file.

       {
          "dependencies": {
             ...
             "@google-ads/data-manager-util": "file:PATH_TO_UTILITY_LIBRARY/google-ads-datamanager-util-0.2.0.tgz",
             ...
          }
       }

   To format data, use the `UserDataFormatter` utility in your Node.js
   project.
7. Browse code samples in the `samples` subdirectory or [on
   GitHub](https://github.com/googleads/data-manager-node/tree/main/samples).
   Run the samples using the following steps:

   1. Navigate to the `data-manager-node` directory.

   2. Run the samples, passing any required arguments. Pass the `--help`
      argument when running a sample to print a usage statement with
      expected parameters.

      For example, the following command runs the
      `ingest_audience_members` sample and prints a usage statement:

          npm run ingest-audience-members -w samples -- --help

   To help you get started with some sample data, use the file at
   [`samples/sampledata/audience_members_1.json`](https://github.com/googleads/data-manager-node/blob/main/samples/sampledata/audience_members_1.json)

### PHP

### Install the client library

Follow the instructions in the [PHP client library installation
guide](https://github.com/googleapis/php-ads-data-manager#installation) to add a dependency to the
[`googleads/data-manager`](https://packagist.org/packages/googleads/data-manager) client library in your project.

### Optional: Get the utility library and code samples.

1. Clone the [GitHub
   repository](https://github.com/googleads/data-manager-php).

       git clone https://github.com/googleads/data-manager-php.git

2. Navigate to the `data-manager-php` directory.

3. Run the following command to resolve dependencies for the library:

       composer update --prefer-dist

4. In the `composer.json` file of your PHP project on the same host,
   declare a dependency on the utility library using the following steps:

   <br />

   1. Add an entry in the `repositories` section that points to the
      location of the `data-manager-php` directory.

          "repositories" : [
             {
                "type" : "path",
                "url" : "PATH_TO_UTILITY_LIBRARY"
             }
          ]

   2. Declare a dependency on the utility library.

          "require": {
             "googleads/data-manager-util": "@dev"
          }

   To format data, use the `Formatter` utility in your PHP project.
5. Browse code samples in the `samples` subdirectory or [on
   GitHub](https://github.com/googleads/data-manager-php/tree/main/samples). Run
   the samples using the following steps:

   1. Navigate to the `samples` directory.

   2. Run the following command to resolve dependencies for the library:

          composer update --prefer-dist

   3. Run the samples, passing any required arguments. Pass the `--help`
      argument when running a sample to print a usage statement with
      expected parameters.

   To help you get started with some sample data, use the file at
   [`samples/sampledata/audience_members_1.json`](https://github.com/googleads/data-manager-php/blob/main/samples/sampledata/audience_members_1.json)

### Python

### Install the client library

Follow the instructions in the [Python client library installation
guide](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-ads-datamanager/README.rst#installation) to add a dependency to the
[`google-ads-datamanager`](https://pypi.org/project/google-ads-datamanager) client library in your project.

### Optional: Get the utility library and code samples.

1. In your Python project, declare a dependency on the
   [`google-ads-datamanager-util`](https://pypi.org/project/google-ads-datamanager-util) utility library.

   For example, if using a `requirements.txt` file in your project, add
   the following line to the file:

       google-ads-datamanager-util==0.4.0

   Or install the utility library directly:

       pip install google-ads-datamanager-util==0.4.0

2. To format and encrypt the data, use the `Formatter` and
   `Encrypter` utilities in your Python project.

3. Browse code samples in the `samples` subdirectory or [on
   GitHub](https://github.com/googleads/data-manager-python/tree/main/samples). To
   run samples, install the sample dependencies:

   1. Clone the [GitHub
      repository](https://github.com/googleads/data-manager-python) at the
      `v0.4.0` tag:

          git clone --branch v0.4.0 https://github.com/googleads/data-manager-python.git

   2. Navigate to the `data-manager-python` directory.

   3. Install the dependencies for running the samples:

          pip install -r samples/requirements.txt

   4. Run the samples from the `samples` directory, passing any required
      arguments. Pass the `--help` argument when running a sample to print
      a usage statement with expected parameters.

      For example, the following command runs the `ingest_events` sample
      and prints a usage statement:

          python3 samples/events/ingest_events.py --help

   To help you get started with some sample data, use the file at
   [`samples/sampledata/audience_members_1.json`](https://github.com/googleads/data-manager-python/blob/main/samples/sampledata/audience_members_1.json).

### Ruby

### Install the client library

Follow the instructions in the [Ruby client library installation
guide](https://github.com/googleapis/google-cloud-ruby/tree/main/google-ads-data_manager-v1#installation) to add a dependency to the client library in your
project.

## Next steps

- Learn more about [sending audience data](https://developers.google.com/data-manager/api/devguides/audiences).
- Learn more about [sending events](https://developers.google.com/data-manager/api/devguides/events).
- Browse the [REST](https://developers.google.com/data-manager/api/reference/rest) or [RPC](https://developers.google.com/data-manager/api/reference/rpc) reference documentation.

> [!TIP]
> **Tip:** To try out any method, visit the [REST
> reference](https://developers.google.com/data-manager/api/reference/rest) and click the **API** button in the toolbar on the method's page. Read more at [Display
> the APIs Explorer and execute a method](https://developers.google.com/explorer-help/execute-method).