Click here to see your recently viewed pages and most viewed pages.
AdWords API

SOAP Primer

We introduce you to the parameters in the AdWords API SOAP request and response headers, then show you an example of making a SOAP call using cURL.

Request Headers

HTTP Headers

You need to include an OAuth2 access token in the form of Authorization : Bearer YOUR_ACCESS_TOKEN that identifies either an MCC manager 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. (Our client libraries automatically refresh expired tokens.)

Soap Headers

When sending a request to any of the AdWords API web services, you must provide the following headers with your request:

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. Example:
When acting on behalf of a client, this header specifies that client's customer ID. Customer IDs are typically of the form 123-456-7890.
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; AdGroupAdService, AdGroupBidModifierService, AdGroupCriterionService, AdGroupService, BudgetService, CampaignCriterionService, CampaignService, FeedItemService, OfflineConversionFeedService)
If set to true, the service will perform error-free operations and return the failing operations' errors. This header is ignored for non-mutate operations.

Response Headers

The following headers are returned with the response XML. For support and debugging purposes, we recommend that you log these values.

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.

Sending SOAP example

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

  1. 0. Get your access token.

    First you need to register your application using the Google Developers Console and create a Client ID as an Installed application. Google then provides information you'll need later, such as a client ID and a client secret.

    To request your authentication token from OAuth2, paste the following URL in your browser

    You will then see a screen to grant your application access to your AdWords data:

    After you accept the request, you will get an authorization code that can be exchanged for an access token.

    Finally, you can 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

    If you've made a proper request, Google will return your OAuth2 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"
  2. 1. 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. If you need to identify the clientCustomerId, refer to these instructions.

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">
        <ns1:RequestHeader soapenv:actor="" soapenv:mustUnderstand="0" xmlns:ns1="">
        <mutate xmlns="">
              <name>Hello World</name>
              <settings xsi:type="ns2:GeoTargetTypeSetting" xmlns:ns2="">
              <settings xsi:type="ns3:KeywordMatchSetting" xmlns:ns3="">
                <biddingScheme xsi:type="ns4:ManualCpcBiddingScheme" xmlns:ns4="">
  3. 2. 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" encoding="UTF-8"?>
      <soap:Envelope xmlns:soap="">
          <ResponseHeader xmlns="">
          <mutateResponse xmlns="">
                <name>Hello World</name>
                <settings xsi:type="GeoTargetTypeSetting" xmlns:xsi="">
                  <biddingScheme xsi:type="ManualCpcBiddingScheme" xmlns:xsi="">