# Overview

You can create and manage data segments using the [Authorized Buyers
Marketplace API](https://developers.google.com/authorized-buyers/apis/marketplace/reference/rest), which
exposes a
[`curators.dataSegments`](https://developers.google.com/authorized-buyers/apis/marketplace/reference/rest/v1beta/curators.dataSegments)
resource. This is a REST API with [generated client
libraries](https://developers.google.com/api-client-library) that you can use for
your integration.

> [!TIP]
> **Tip:** To learn how to make API calls using the generated client libraries, reference existing [Marketplace API
> samples](https://github.com/googleads/authorized-buyers-marketplace-api-samples).

## Set up authentication

Google APIs use the [OAuth 2.0
protocol](https://developers.google.com/identity/protocols/oauth2) for authentication
and authorization. Here's how to set up a [Service
Account](https://developers.google.com/identity/protocols/oauth2/service-account) to
access Marketplace API.

1. If you have not done so already, [create a Google Cloud
   Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
   that hosts your credentials used to access the API.

   > [!IMPORTANT]
   > **Important:** We recommend that multiple members of your organization are granted access to this project. This process avoids interruptions to your integration from lost access to the project.

2. Go to the [Google Cloud Console Enabled APIs
   page](https://console.cloud.google.com/apis/enabled?project=_). Select the project
   you created earlier.

3. You see a list of enabled APIs and services. To access Marketplace API, you
   must enable it. If Marketplace API isn't enabled, click **+Enable APIs and
   services** and step through the following instructions:

   1. You are directed to a page with a search box. Search for **Authorized
      Buyers Marketplace API**.
   2. Select **Authorized Buyers Marketplace API** in the results page.
   3. Click **Enable**.
4. On the navigation menu, select **Credentials**.

5. Click **+Create credentials** , and in the resulting drop-down menu select
   **Service account**.

6. Enter a **Name** for the service account. The **Service account ID** is
   created automatically upon creation -- note this value because it will be
   needed later in step 14. Optionally enter a description. Click **Create and
   continue**.

7. Optionally configure permissions for the service account and click
   **Continue**.

8. Optionally configure users or groups that can perform actions as the service
   account and click **Done**.

9. Your new service account is listed under **Service Accounts**. Find and
   click the service account ID you just created.

10. Click the **Keys** tab.

11. In the **Add key** drop-down menu, select **Create new key**.

12. Select **JSON** as the **Key type** , and click **Create**.

13. Download the key to your working directory. For more information about
    storing your key securely, see [Managing service account
    keys](https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys).
    The key is used by your application to make API calls.

14. Share the service account ID with your Technical Account Manager to link the
    service account with your account.

### API scopes

When stepping through the OAuth 2.0 flow to receive an access token used to make
an API call, you must specify the APIs that can be accessed using that token.
For the Authorized Buyers Marketplace API, that scope is
`https://www.googleapis.com/auth/authorized-buyers-marketplace`.

## How to identify data segments in the API versus Real-time Curation

In Marketplace API, data segments are identified with an API-specific resource
[name](https://developers.google.com/authorized-buyers/apis/marketplace/reference/rest/v1beta/curators.dataSegments#DataSegment.FIELDS.name)
such as:

    "curators/[YOUR_ACCOUNT_ID]/dataSegments/[DATA_SEGMENT_ID]".

When [identifying the data segments relevant for an ad opportunity in Real-time
Curation](https://developers.google.com/authorized-buyers/curation/realtime-curation/build-response),
specify the value for the `DATA_SEGMENT_ID` resource ID rather than the full
resource `name` used by the API.

## Next Steps

- Learn how to [create and manage data
  segments](https://developers.google.com/authorized-buyers/curation/apis/marketplace/datasegments/create-modify) with Marketplace API.
- Learn how to [activate and deactivate data
  segments](https://developers.google.com/authorized-buyers/curation/apis/marketplace/datasegments/activate-deactivate) with Marketplace API.
- Learn how to [view your data
  segments](https://developers.google.com/authorized-buyers/curation/apis/marketplace/datasegments/view) with Marketplace API.