Testing is an important step in building a successful Google Ads API integration,
whether you're just getting started, maintaining an app, or adding new features
to an existing integration. This guide presents some best practices for testing
your Google Ads API integration.

## Test accounts and production accounts

> [!WARNING]
> **Note on Test Account Retention:**
>
>
> Google Ads API test accounts and their associated data are subject to automatic deletion. Any test account that remains inactive (has no API activity or logins) for a continuous period of **one year** will be permanently removed.
>
>
> To prevent unintended deletion, ensure you interact with your test accounts periodically if you want to retain them.

[Test accounts](https://developers.google.com/google-ads/api/docs/best-practices/test-accounts) are available for development purposes. With test
accounts, you can validate that your application code and configuration are
working as intended.

However, [not all features](https://developers.google.com/google-ads/api/docs/best-practices/test-accounts#limitations) can be tested in a test
account.

When test account limitations prevent you from testing some features in your
integration, you can instead use a production account for development. Your
Google Cloud project must have at least the
[Explorer access level](https://developers.google.com/google-ads/api/docs/api-policy/access-levels) (Explorer, Basic, or Standard) to
call a production account. Note that Explorer access still restricts certain
services---including billing ([`BillingSetupService`](https://developers.google.com/google-ads/api/reference/rpc/v26/BillingSetupService)
and [`AccountBudgetProposalService`](https://developers.google.com/google-ads/api/reference/rpc/v26/AccountBudgetProposalService)),
planning, account creation, and user invitations (see [Explorer feature
restrictions](https://developers.google.com/google-ads/api/docs/api-policy/access-levels#explorer-feature-restrictions))---which require Basic or Standard
access. Attempting to call a production account from a
project with the Test access level returns
[`AuthorizationError.CLOUD_PROJECT_NOT_APPROVED_FOR_PRODUCTION`](https://developers.google.com/google-ads/api/reference/rpc/v26/AuthorizationErrorEnum.AuthorizationError#cloud_project_not_approved_for_production)
starting in `v25`, or
[`AuthorizationError.ACTION_NOT_PERMITTED`](https://developers.google.com/google-ads/api/reference/rpc/v26/AuthorizationErrorEnum.AuthorizationError#action_not_permitted) in `v24` and
earlier.

Production accounts for development differ from test accounts in the following
ways:

- Serve ads that can be seen by users
- Require valid URLs
- Must comply with [advertising policies](https://support.google.com/adspolicy/answer/6008942)

Because production accounts serve ads, they generate metrics letting you test
performance reports, as well as unlocking all the other features of the Google Ads API.
However, using them for development requires extra caution. We recommend taking
the following measures:

- Only grant access to users that need it for development purposes.
- Set a fixed, low daily account budget.
- Use production accounts for development only when test accounts can't be used.

Thus, to do full testing of your integration, you will likely need both test
credentials and production credentials.

## Test credentials

To minimize the risk of accidentally modifying production accounts when trying
to modify development accounts, we recommend maintaining a set of test
credentials that are separate from your production application credentials.

To create a set of test credentials, follow these steps:

1. Create an email account (for example, `api.test@example.com`) or a service account that will be used only for testing purposes.
2. Add this user or service account as a valid user in the Google Ads accounts you are running your tests against. Make sure you give appropriate [access
   levels](https://support.google.com/google-ads/answer/9978556) to this user or service account. Don't give this user or service account access to *any production accounts*.
3. If you are using the [OAuth 2.0 user authentication flow, rather than the
   service account flow](https://developers.google.com/google-ads/api/docs/oauth/overview), then generate a refresh token for your test user account.
4. Use these new credentials when testing your application. The client ID and client secret can be reused for testing purposes, since they have no effect in determining which Google Ads accounts can be accessed. Store all credentials and refresh tokens securely, and never commit them to source control.

## Request validation

If you just need to test whether a request is valid---for example, to verify
that the request is structured correctly and does not violate policies---you
can use the [`validate_only`](https://developers.google.com/google-ads/api/docs/concepts/api-structure#mutate-validation) field, which is available for
[`GoogleAdsService.Search`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/Search) requests (note that
[`GoogleAdsService.SearchStream`](https://developers.google.com/google-ads/api/reference/rpc/v26/GoogleAdsService/SearchStream) does not support
`validate_only`) and most mutate requests. Consult the
[reference documentation](https://developers.google.com/google-ads/api/reference/rpc/v26/overview) to verify whether this field is
available for a given method.

> [!NOTE]
> **Note:** Starting in `v25`, Performance Max campaign generation for Smart campaigns does not support `validate_only` mode and returns [`SmartCampaignError.VALIDATE_ONLY_GENERATE_PMAX_NOT_SUPPORTED`](https://developers.google.com/google-ads/api/reference/rpc/v26/SmartCampaignErrorEnum.SmartCampaignError#validate_only_generate_pmax_not_supported) if `validate_only` is set to `true`.

## REST API

For ad hoc testing, for example to validate that a request yields the expected
output, using the REST API is often the easiest option. Consult the [REST
examples](https://developers.google.com/google-ads/api/rest/examples) to learn how to use curl in making requests to the REST
API. Also, try testing in the [REST explorer](https://developers.google.com/google-ads/api/rest/try-it).