# Search Ads 360 Reporting API call structure

Calls to the Search Ads 360 Reporting API are typically made through your
[client library](https://developers.google.com/search-ads/reporting/client-libraries/client-libraries). See
[Client libraries explained](https://cloud.google.com/apis/docs/client-libraries-explained) for more
information. However, knowledge about the structure of the underlying request
details can be useful when testing and debugging.

Search Ads 360 Reporting API is a [gRPC API](https://grpc.io/docs/guides/) with REST
bindings. This means that you can make calls to the API in two alternative ways:

Preferred method
:   Use a [client library](https://developers.google.com/search-ads/reporting/client-libraries/client-libraries):

    - Create the body of the request as a [protocol buffer](https://developers.google.com/protocol-buffers).
    - Send the request to the server using [HTTP/2](https://http2.github.io/).
    - Deserialize the response to a protocol buffer.
    - Interpret the results.

Optional alternative method
:   Use [REST](https://developers.google.com/search-ads/reporting/api/reference/rest):

    - Create the body of request as a [JSON](https://www.json.org/) object.
    - Send the request to the server using HTTP 1.1.
    - Deserialize the response as a JSON object.
    - Interpret the results.

See [Google Cloud APIs](https://cloud.google.com/apis/docs/overview) for more
information.

The following sections apply to both gRPC and REST protocols.

## Resource names

Most objects in the API are identified by their resource name strings. These
strings also serve as URLs when using the REST interface.

See [Reference \> REST](https://developers.google.com/search-ads/reporting/api/reference/rest) for more
information about supported resources and their path representation.
The same format is used for other services.

## Composite IDs

If the ID of an object is not [globally unique](https://developers.google.com/search-ads/reporting/concepts/api-structure#object_ids), a composite ID for
that object is constructed by prepending its parent ID and a tilde (\~).

For example, because an ad group ad ID is not globally unique, the parent object
(ad group) ID is prepended to it resulting in a unique composite ID.

Example: `AdGroupId` of **`123`** + `~` + `AdGroupAdId` of **`45678`**
= composite ad group ad ID of **`123~45678`**.

## Request headers

The HTTP headers (or [gRPC metadata](https://grpc.io/docs/what-is-grpc/core-concepts/#metadata)) in the following sections
should be included in the body of the request.

### Authorization

You need to include an OAuth2 access token in the form:

```
Authorization: Bearer [OAUTH_2.0_ACCESS_TOKEN]
```

The token should identify either a manager account acting on behalf of a
client or an advertiser directly managing their own sub-manager or client
account. See [About Search Ads 360 manager accounts](https://support.google.com/sa360/answer/9158072) and [Authentication](https://cloud.google.com/docs/authentication) to learn more.

### Login customer ID header

The [`login-customer-id`](https://developers.google.com/search-ads/reporting/concepts/login-customer-id) header is required when using a manager account to
access a sub-manager or client account. It is not required when accessing a
sub-manager or client account directly. Although not strictly necessary, we
recommend always specifying the [`login-customer-id`](https://developers.google.com/search-ads/reporting/concepts/login-customer-id) for authenticated users who
have access to more than one account. This avoids ambiguity and prevents
unintentionally setting the context to the incorrect account.

The request should include the customer ID of the authorized user, without
hyphens (`-`), for example:

```
https://searchads360.googleapis.com/VERSION_NUMBER/customers/CUSTOMER_ID/campaignBudgets
```

Setting the `login-customer-id` is equivalent to choosing an account in the
Search Ads 360 UI after signing in or clicking on your profile image at the top
right.

## Response headers

The following headers (or
[gRPC trailing-metadata](https://grpc.io/docs/what-is-grpc/core-concepts/#metadata))
are returned with the response body. We recommend that you log these values for
debugging purposes.

### Request ID

The `request-id` header is a string that uniquely identifies the request.