API call example

This example demonstrates how to interact with the API using cURL. Although cURL and HTTP + JSON would be impractical for building a real-world application, the example demonstrates how the Google Ads API functions at the lowest level.

We now go step-by-step, from getting auth tokens to making the call with cURL, in creating a new campaign budget. These steps are handled automatically in our client libraries.

  1. Get your OAuth2 client ID and client secret (if you haven't done so already). Follow the instructions in the OAuth2 guide.

  2. Enable Google Ads API in your Google Cloud project. Follow the instructions in the OAuth2 guide.

  3. Get an OAuth2 access token. To request your access token from OAuth2, enter your OAuth2 client ID in the following URL, and paste it into your browser:


    A screen appears where you grant your application access to your Google Ads data:

    After you accept the request, you'll receive an authorization code that can be exchanged for an access token.

    Finally, make the request to exchange the authorization code for an access token:

    curl \
      -d code=AUTHORIZATION CODE \
      -d client_id=CLIENT ID \
      -d client_secret=CLIENT SECRET \
      -d redirect_uri=urn:ietf:wg:oauth:2.0:oob \
      -d grant_type=authorization_code https://accounts.google.com/o/oauth2/auth

    If you've made a proper request, Google returns your OAuth2 access token. The access token (shown in bold after "access_token" :) is what you need when sending requests to Google Ads API services.

      "access_token" : "ya29.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "refresh_token" : "1/Ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  4. Create a file containing the request. The following JSON snippet defines a request that adds a budget. Copy this snippet to a file called create_budget.json. You will need it in the next step.

            name: "new budget 234",
            amount_micros: "60000000"
  5. Use cURL to send this request to CampaignBudgetService. Replace 1234567890 with your Google Ads advertiser account's customer ID, without the hyphens.

    curl --request POST \
         --header "Content-Type: application/json" \
         --header "Authorization: Bearer ACCESS TOKEN" \
         --header "developer-token: DEVELOPER TOKEN" \
         --data @create_budget.json \


After the Google Ads API server processes your request, it returns a response that contains the JSON data representing the newly added budget.

  "results": [
      "resourceName": "customers/1234567890/campaignBudgets/1xxxxxxxx1"