DownloadCampaignsByAccountIds Service Operation

 

Downloads settings and performance data for all of the account's campaigns. You can request all campaign data or only the data that has changed since the last time you downloaded the account.

System_CAPS_ICON_note.jpg Note

You must use the same user credentials for the download request operation (either DownloadCampaignsByAccountIds or DownloadCampaignsByCampaignIds) and the GetBulkDownloadStatus polling operation.

Request | Response

Error Codes

Service: BulkService.svc v11 | Namespace: https://bingads.microsoft.com/CampaignManagement/v11

Request Body

The DownloadCampaignsByAccountIdsRequest object defines the elements of the request’s body. The elements must be in the same order as shown in the SOAP Request SOAP.

ElementDescriptionData TypeRequired
AccountIdsThe identifier of the account that contains the campaign data to download. The maximum number of accounts that you can specify is one.

The size of the account that you can download is limited to four million keywords. If you try to download an account that contains more than 4 million keywords, the call will fail with error 3207 (AccountTooBigToDownload). If the call fails, please call the DownloadCampaignsByCampaignIds operation to download the account by campaigns. The Details element of the fault includes a comma-delimited list of the campaign IDs that the account owns.
long arrayYes
CompressionTypeThe compression type of the download file. For possible values, see CompressionType. The default is Zip.CompressionTypeNo
DataScopeYou may include performance data such as spend, in addition to entity data such as campaign settings. The default is EntityData which will exclude performance data from the download.

You may include multiple values as flags. How you specify multiple flags depends on the programming language that you use. For example, C# treats these values as flag values and Java treats them as an array of strings. The SOAP should include a string that contains a space-delimited list of values for example, <DataScope>EntityData EntityPerformanceData</DataScope>.

Note: If BidSuggestionsData, EntityPerformanceData, or QualityScoreData are included, you must request a full sync to get performance data. To perform a full sync, set LastSyncTimeInUTC to NULL.

Note: If EntityPerformanceData is included, you must specify the CustomerId in the service request header.
DataScopeNo
DownloadEntitiesThe entities to include in the download. For a list of entities that you can download, see the DownloadEntity value set.

Note: You must specify at least one download entity, and otherwise the operation will error.
DownloadEntity arrayYes
DownloadFileTypeThe file type of the download file. For possible values, see DownloadFileType. The default is CSV.DownloadFileTypeNo
FormatVersionThe format for records of the download file.

As a best practice you should always specify the latest format version. Currently the only supported format version for Bing Ads API Version 11 is 5.0.

You should manage records according to the Bulk File Schema for the corresponding format version.
stringYes
LastSyncTimeInUTCThe last time that you requested a download. The date and time is expressed in Coordinated Universal Time (UTC).

If you specify the last sync time, only those entities that have changed (added, updated, or deleted) since the specified date and time will be downloaded. You cannot specify a date and time older than 90 days, as otherwise an error will be returned.

Target criterion are treated slightly different from other entities, and deleted records are not returned. If any changes were made to a campaign or ad group's target, then all currently active sub target criterion records are returned.

Typically, you request a full download the first time you call the operation by setting this element to null. On all subsequent calls you set the last sync time to the time stamp of the previous download.

The download file contains the time stamp of the download in the SyncTime column of the Account record. Use the time stamp to set LastSyncTimeInUTC the next time that you request a download.

After requesting a full download, the only time that you should again request a full download would be if your account was included in a data migration (for example, the sitelink version 2 migration). If you specify a last sync time that predates the end of the migration process, the download will fail with CampaignServiceFullSyncRequired (error code 3603).
dateTimeNo
PerformanceStatsDateRangeDefines the start and end date when downloading performance data.

If the DataScope element includes EntityPerformanceData, then the start and end date must be set with this element.

The date range cannot exceed one year. For example April 1, 2015 through March 31, 2016 or April 1, 2016 through March 31, 2017 are both valid date ranges; however January 1, 2016 through April 30, 2017 is invalid.
PerformanceStatsDateRangeNo

Request Headers

Set the required header elements for each service request. New customers are required to sign up for Bing Ads with a Microsoft Account, and to manage those accounts you must use OAuth. Existing users with legacy Bing Ads credentials may continue to specify the UserName and Password header elements. In future versions of the API, Bing Ads will transition exclusively to Microsoft Account authentication. For more information, see Getting Started With the Bing Ads API.

OAuth Authentication

These request headers are required for Authentication with OAuth.

ElementDescriptionData Type
AuthenticationTokenThe OAuth access token that represents a Microsoft Account user who has permissions to Bing Ads accounts.string
CustomerAccountIdThe identifier of the account that owns the entities in the request. This header element must have the same value as the AccountId body element when both are required.

Note: Required for most service operations, and as a best practice you should always specify this element.
string
CustomerIdThe identifier of the customer that contains and owns the account. If you manage an account of another customer, you should use that customer ID instead of your own customer ID.

Note: This element is required.
string
DeveloperTokenThe developer token used to access the Bing Ads API.string

Password Authentication

These request headers are required for legacy username and password authentication.

ElementDescriptionData Type
CustomerAccountIdThe identifier of the account that owns the entities in the request. This header element must have the same value as the AccountId body element when both are required.

Note: Required for most service operations, and as a best practice you should always specify this element.
string
CustomerIdThe identifier of the customer that contains and owns the account. If you manage an account of another customer, you should use that customer ID instead of your own customer ID.

Note: This element is required.
string
DeveloperTokenThe developer token used to access the Bing Ads API.string
PasswordThe Bing Ads user's sign-in password.string
UserNameThe Bing Ads user's sign-in user name. You must not set this element to a Microsoft account or email address. To authenticate a Microsoft account, use the AuthenticationToken header instead of UserName and Password.string

Request SOAP

The following example shows the complete request envelope.

<s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
    <Action mustUnderstand="1">DownloadCampaignsByAccountIds</Action>
    <ApplicationToken i:nil="false"></ApplicationToken>
    <AuthenticationToken i:nil="false"></AuthenticationToken>
    <CustomerAccountId i:nil="false"></CustomerAccountId>
    <CustomerId i:nil="false"></CustomerId>
    <DeveloperToken i:nil="false"></DeveloperToken>
    <Password i:nil="false"></Password>
    <UserName i:nil="false"></UserName>
  </s:Header>
  <s:Body>
    <DownloadCampaignsByAccountIdsRequest xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
      <AccountIds i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a1:long></a1:long>
      </AccountIds>
      <CompressionType i:nil="false"></CompressionType>
      <DataScope></DataScope>
      <DownloadEntities i:nil="false">
        <DownloadEntity></DownloadEntity>
      </DownloadEntities>
      <DownloadFileType i:nil="false"></DownloadFileType>
      <FormatVersion i:nil="false"></FormatVersion>
      <LastSyncTimeInUTC i:nil="false"></LastSyncTimeInUTC>
      <PerformanceStatsDateRange i:nil="false">
        <CustomDateRangeEnd i:nil="false">
          <Day></Day>
          <Month></Month>
          <Year></Year>
        </CustomDateRangeEnd>
        <CustomDateRangeStart i:nil="false">
          <Day></Day>
          <Month></Month>
          <Year></Year>
        </CustomDateRangeStart>
        <PredefinedTime i:nil="false"></PredefinedTime>
      </PerformanceStatsDateRange>
    </DownloadCampaignsByAccountIdsRequest>
  </s:Body>
</s:Envelope>

Response Body

ElementDescriptionData Type
DownloadRequestIdThe identifier of the download request. You use the identifier to call the GetBulkDownloadStatus operation to check the status of the download. The identifier is valid for a maximum of two days. If you have not successfully downloaded the file within this period, it is removed from the download site and you will need to get a new download request identifier.

The string has a length up to 40 and can contain any character.
string

Response Header

ElementDescriptionData Type
TrackingIdThe identifier of the log entry that contains the details of the API call.string

Response SOAP

The following example shows the complete response envelope.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
    <TrackingId p4:nil="false" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance"></TrackingId>
  </s:Header>
  <s:Body>
    <DownloadCampaignsByAccountIdsResponse xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
      <DownloadRequestId p4:nil="false" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance"></DownloadRequestId>
    </DownloadCampaignsByAccountIdsResponse>
  </s:Body>
</s:Envelope>

If the service operation fails, it throws a FaultException exception, which contains one or more of the Bing Ads API error data objects. For information about the fault detail objects, see Bulk Error Data Objects and Handling Service Errors and Exceptions.The following are example error codes that the error objects can include when using this service operation. For all documented error codes, please see Bing Ads Operation Error Codes.

Error Code
InvalidCredentials
CampaignServiceCampaignsArrayShouldNotBeNullOrEmpty
CampaignServiceCampaignsArrayExceedsLimit
CampaignServiceAccountIdsLengthExceeded
CampaignServiceCampaignsContainsMultipleAccounts
CampaignServiceCampaignsContainsNullScope
CampaignServiceInvalidDownloadRequestId
CampaignServiceAccountTooBigToDownload
CampaignServiceLastSyncTimeCannotBeInTheFuture
CampaignServiceAccountIdsArrayShouldNotBeNullOrEmpty
CampaignServiceFullSyncRequired

DownloadCampaignsByCampaignIds
GetBulkDownloadStatus

Show: