API Call Structure

This guide describes the elements of an API call and demonstrates making a basic call using cURL.

If you're using a client library or a SOAP library to interact with the API, you probably won't need to worry about the underlying SOAP and XML. However, knowing a bit about them can come in handy when testing and debugging.

Making calls to the API involves sending HTTPS POST requests to a service and interpreting the response. The body of the request and response is comprised of XML defined by a WSDL. You can print the WSDL by appending a ?wsdl to the service URL:


Request headers

HTTP headers accompany the SOAP+XML body in the request:

You need to include an OAuth2 access token in the form of Authorization : Bearer YOUR_ACCESS_TOKEN that identifies either a manager account acting on behalf of a client, or an advertiser directly managing their own account. Directions for retrieving an access token can be found in the OAuth2 guide. An access token is valid for an hour after you acquire it; when it expires, refresh the access token to retrieve a new one. Note that our client libraries automatically refresh expired tokens.
A 22-character string that uniquely identifies an AdWords API developer. An example developer token string is ABcdeFGH93KL-NOPQ_STUv.
A user-specified string that defines the sender and purpose of the request. Set this to your application name and version in order to help us find your requests when diagnosing a problem, for example, example.com:ReportDownloader:V7.18.
Customer ID of the target AdWords account, typically in the form of 123-456-7890. Required for all calls to all services except CustomerService and ReportDefinitionService.
validateOnly (optional)
If set to true, the request is validated but not performed. You can use this header to validate user-provided data.
partialFailure (optional and available for only some services)
If set to true, the service will perform all operations that are free of errors, and return the errors for the failing operations. This header is ignored for non-mutate operations.

Response headers

The following headers are returned with the response XML. We recommend that you log these values for debugging purposes.

String that uniquely identifies this request.
Number of operations performed in this request.
Elapsed time in milliseconds between the web service receiving the request and sending the response.

API call example

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


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

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


    A screen appears where you grant your application access to your AdWords 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=your-authorization-code \
      -d client_id=your-client-id \
      -d client_secret=your-client-secret \
      -d redirect_uri=urn:ietf:wg:oauth:2.0:oob \
      -d grant_type=authorization_code https://accounts.google.com/o/oauth2/token

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

      "access_token" : "ya29.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "refresh_token" : "1/Ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  3. Create a SOAP request. The following XML defines a SOAP request that adds a budget. Save this XML (with your authentication token and account login replacing the placeholders) as hello_world.xml.

    <?xml version="1.0"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201609" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
        <mutate xmlns="https://adwords.google.com/api/adwords/cm/v201609">
              <name>Hello World</name>
              <settings xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201609" xsi:type="ns2:GeoTargetTypeSetting">
                <biddingScheme xmlns:ns4="https://adwords.google.com/api/adwords/cm/v201609" xsi:type="ns4:ManualCpcBiddingScheme">
  4. Send the request. Use cURL to send this SOAP request to CampaignService. You can send your access token by including it in the HTTP header like this:

    curl --header "Content-Type: application/soap+xml" \
         --header "Authorization : Bearer YOUR_ACCESS_TOKEN" \
         --data @hello_world.xml \


After the AdWords API server processes your request, it returns a response that contains the XML data representing the newly-added campaign:

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201609">
    <mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201609">
          <name>Hello World</name>
          <settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="GeoTargetTypeSetting">
            <biddingScheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ManualCpcBiddingScheme">

Send feedback about...

AdWords API
AdWords API
Need help? Visit our support page.