List media planners

To view a list of all media planners that have accepted curator terms, use the mediaPlanners.list method. This method lists all media planner accounts that you have access.

Before you begin

Before you continue, you must set up authentication.

Make a request

The following example makes a GET request to the mediaPlanners.list method, which responds with the list of media planners that the caller has access:

REST

Request

curl \
'https://curationpartners.googleapis.com/v1/mediaPlanners?pageSize=2' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Accept: application/json' \
--compressed

Replace ACCESS_TOKEN with your access token.

Response

{
  "mediaPlanners": [
    {
      "accountId": "0123456789",
      "name": "mediaPlanners/0123456789",
      "displayName": "Media Planner A",
      "ancestorNames": [
        "mediaPlanners/1234567890"
      ]
    },
    {
      "accountId": "9876543210",
      "name": "mediaPlanners/9876543210",
      "displayName": "Media Planner B",
      "ancestorNames": [
        "mediaPlanners/1111111123",
        "mediaPlanners/2222222220"
      ]
    }
  ],
  "nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}

Java

/*
 * Copyright (c) 2026 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.api.services.samples.curationpartners.v1.mediaPlanners;

import com.google.api.services.curationpartners.v1.CurationPartners;
import com.google.api.services.curationpartners.v1.model.ListMediaPlannersResponse;
import com.google.api.services.samples.curationpartners.v1.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

public class ListMediaPlanners {

  private ListMediaPlanners() {}

  /**
   * Lists all media planner accounts that the caller has access to. For curators, this will return
   * all media planners that have accepted curator terms. For other accounts, attempting to list
   * media planners will return an error.
   *
   * @param curationPartnersClient the initialized Curation Partners API client.
   * @param pageSize the number of rows to return per page.
   * @throws IOException if the API returns an error.
   */
  public static void execute(
      CurationPartners curationPartnersClient, Integer pageSize, String filter)
      throws IOException {

    String pageToken = null;

    // Iterate through and print pages from the media planners list.
    do {
      ListMediaPlannersResponse response =
          curationPartnersClient
              .mediaPlanners()
              .list()
              .setFilter(filter)
              .setPageSize(pageSize)
              .setPageToken(pageToken)
              .execute();
      Utils.jsonPrettyPrint(response);
      pageToken = response.getNextPageToken();
    } while (pageToken != null);
  }

  /**
   * Creates and configures the ArgumentParser for this sample.
   *
   * @return the configured ArgumentParser.
   */
  private static ArgumentParser createArgumentParser() {
    ArgumentParser parser =
        ArgumentParsers.newFor("ListMediaPlanners")
            .build()
            .defaultHelp(true)
            .description("Lists all media planner accounts that the caller has access to.");

    // Optional arguments.
    parser
        .addArgument("-d", "--page_size")
        .help(
            "The number of rows to return per page. The server may return fewer rows than "
                + "specified.")
        .type(Integer.class);
    parser
        .addArgument("-f", "--filter")
        .help(
            "An optional parameter used the filter the media planners returned. Uses Cloud API list"
                + " filtering syntax. To learn more, see:"
                + "https://developers.google.com/authorized-buyers/apis/guides/get-started/list-filters");

    return parser;
  }

  public static void main(String[] args) {
    ArgumentParser parser = createArgumentParser();
    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException e) {
      parser.handleError(e);
      System.exit(1);
    }

    CurationPartners client = null;
    try {
      client = Utils.getCurationPartnersClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Curation Partners API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    Integer pageSize = parsedArgs.getInt("page_size");
    String filter = parsedArgs.getString("filter");

    try {
      execute(client, pageSize, filter);
    } catch (Exception e) {
      System.out.printf("Curation Partners API returned error response:%n%s", e);
      System.exit(1);
    }
  }
}