This guide contains examples of calling the REST endpoints directly, without the
use of a client library.

## Prerequisites

All the samples below are meant to be easily copy-and-pasteable into a
[bash shell](https://www.gnu.org/software/bash/) using
[curl](https://curl.se/) command. You will need a Search Ads 360 manager account containing at least one client account.

> [!IMPORTANT]
> **Important:** In these examples, we assume that you are accessing a client account (`CUSTOMER_ID`) by a user that has administrative access to a manager account (`MANAGER_CUSTOMER_ID`) that directly manages the client account. If you are instead accessing an individual client account directly, omit the `login-customer-id` header or set it to the same value as `CUSTOMER_ID`.

### Environment variables

Enter account credentials and IDs below, and then copy-and-paste into your
terminal to configure the environment variables used in the subsequent examples.

> [!NOTE]
> **Note:** The [Authorization](https://developers.google.com/search-ads/reporting/api/reference/rest/auth) guide provides instructions for generating an OAuth 2.0 access token.

    API_VERSION="0"
    OAUTH2_ACCESS_TOKEN="OAUTH_ACCESS_TOKEN"
    MANAGER_CUSTOMER_ID="MANAGER_CUSTOMER_ID"
    CUSTOMER_ID="CUSTOMER_ID"

#### Additional optional object IDs

The following examples work on pre-existing campaigns. If you
have IDs of an existing campaign to use with these examples, enter it below.

    CAMPAIGN_ID=CAMPAIGN_ID

### Paginated search

The `search` method uses pagination, with an adjustable `pageSize` parameter
specified alongside the `query`.

### cURL

```console
#!/bin/bash
# [START curl_command]
curl -f --request POST "https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:search" \
--header "Content-Type: application/json" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data '{
"pageSize": 10,
"query": "
  SELECT campaign.name,
    campaign_budget.amount_micros,
    campaign.status,
    campaign.advertising_channel_type,
    metrics.clicks,
    metrics.impressions,
    metrics.ctr,
    metrics.average_cpc,
    metrics.cost_micros,
    campaign.bidding_strategy_type
  FROM campaign
  WHERE segments.date DURING LAST_7_DAYS
    AND campaign.status != 'REMOVED'
"
}'
# [END curl_command]
```

### SA360 Query Language

```sql
  SELECT campaign.name,
    campaign_budget.amount_micros,
    campaign.status,
    campaign.advertising_channel_type,
    metrics.clicks,
    metrics.impressions,
    metrics.ctr,
    metrics.average_cpc,
    metrics.cost_micros,
    campaign.bidding_strategy_type
  FROM campaign
  WHERE segments.date DURING LAST_7_DAYS
    AND campaign.status != 'REMOVED'
```

### Streaming

The `searchStream` method streams all results in a single response, and thus the
`pageSize` field is not supported.

### cURL

```console
#!/bin/bash
# [START curl_command]
curl -f --request POST "https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:searchStream" \
--header "Content-Type: application/json" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data '{
"query": "
  SELECT campaign.name,
    campaign_budget.amount_micros,
    campaign.status,
    campaign.advertising_channel_type,
    metrics.clicks,
    metrics.impressions,
    metrics.ctr,
    metrics.average_cpc,
    metrics.cost_micros,
    campaign.bidding_strategy_type
  FROM campaign
  WHERE segments.date DURING LAST_7_DAYS
    AND campaign.status != 'REMOVED'
"
}'
# [END curl_command]
```

### SA360 Query Language

```sql
  SELECT campaign.name,
    campaign_budget.amount_micros,
    campaign.status,
    campaign.advertising_channel_type,
    metrics.clicks,
    metrics.impressions,
    metrics.ctr,
    metrics.average_cpc,
    metrics.cost_micros,
    campaign.bidding_strategy_type
  FROM campaign
  WHERE segments.date DURING LAST_7_DAYS
    AND campaign.status != 'REMOVED'
```