DownloadCampaignsByAccountIds Service Operation - Bulk

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.

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


The Bulk File Schema provides details about records that you can download and upload. Please adhere to the best practices to ensure fair usage for yourself and all Microsoft Advertising clients. For details please see Bulk Download Best Practices and Bulk Upload Best Practices.

Request Elements

The DownloadCampaignsByAccountIdsRequest object defines the body and header elements of the service operation request. The elements must be in the same order as shown in the Request SOAP.


Unless otherwise noted below, all request elements are required.

Request Body Elements

Element Description Data Type
AccountIds The 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 array
CompressionType The compression type of the download file. For possible values, see CompressionType. The default compression type is Zip. CompressionType
DataScope You may include quality score data such as ad relevance, in addition to entity data such as campaign settings. The default value is EntityData.

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 QualityScoreData</DataScope>.

If BidSuggestionsData or QualityScoreData are included, you must request a full sync. To perform a full sync, do not set LastSyncTimeInUTC i.e., leave it nil.
DownloadEntities The entities to include in the download. For a list of entities that you can download, see the DownloadEntity value set.

You must specify at least one download entity, and otherwise the operation will error.
DownloadEntity array
DownloadFileType The file type of the download file. For possible values, see DownloadFileType. The default is CSV. DownloadFileType
FormatVersion The 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 13 is 6.0.

You should manage records according to the Bulk File Schema for the corresponding format version.
LastSyncTimeInUTC The 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. If the parent campaign or ad group has been deleted since the specified last sync time, you will only see a deleted record for the deleted parent campaign or ad group. For example if a campaign was deleted, the bulk file will not contain deleted records for the ad groups, criterions, ads, and keywords that were in the campaign.

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 Sync Time column of the Account record. You should use the account Sync Time to set this element the next time that you request a download.

You cannot specify a date and time older than 90 days, as otherwise an error will be returned.

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 in calendar year 2017). If you specify a last sync time that predates the end of the migration process, the download will fail with CampaignServiceFullSyncRequired (error code 3603).

Request Header Elements

Element Description Data Type
AuthenticationToken The OAuth access token that represents the credentials of user who has permissions to Microsoft Advertising accounts. string
CustomerAccountId The identifier of the ad 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. This element is required for most service operations, and as a best practice you should always set it. string
CustomerId The identifier of the manager account (customer) the user is accessing or operating from. A user can have access to multiple manager accounts. This element is required for most service operations, and as a best practice you should always set it. string
DeveloperToken The developer token used to access the Bing Ads API. string
Password This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. string
UserName This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. string

Response Elements

The DownloadCampaignsByAccountIdsResponse object defines the body and header elements of the service operation response. The elements are returned in the same order as shown in the Response SOAP.

Response Body Elements

Element Description Data Type
DownloadRequestId The 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.

Response Header Elements

Element Description Data Type
TrackingId The identifier of the log entry that contains the details of the API call. string

Request SOAP

This template was generated by a tool to show the order of the body and header elements for the SOAP request. For supported types that you can use with this service operation, see the Request Body Elements reference above.

<s:Envelope xmlns:i="" xmlns:s="">
  <s:Header xmlns="">
    <Action mustUnderstand="1">DownloadCampaignsByAccountIds</Action>
    <AuthenticationToken i:nil="false">ValueHere</AuthenticationToken>
    <CustomerAccountId i:nil="false">ValueHere</CustomerAccountId>
    <CustomerId i:nil="false">ValueHere</CustomerId>
    <DeveloperToken i:nil="false">ValueHere</DeveloperToken>
    <DownloadCampaignsByAccountIdsRequest xmlns="">
      <AccountIds i:nil="false" xmlns:a1="">
      <CompressionType i:nil="false">ValueHere</CompressionType>
      <DownloadEntities i:nil="false">
      <DownloadFileType i:nil="false">ValueHere</DownloadFileType>
      <FormatVersion i:nil="false">ValueHere</FormatVersion>
      <LastSyncTimeInUTC i:nil="false">ValueHere</LastSyncTimeInUTC>

Response SOAP

This template was generated by a tool to show the order of the body and header elements for the SOAP response.

<s:Envelope xmlns:s="">
  <s:Header xmlns="">
    <TrackingId d3p1:nil="false" xmlns:d3p1="">ValueHere</TrackingId>
    <DownloadCampaignsByAccountIdsResponse xmlns="">
      <DownloadRequestId d4p1:nil="false" xmlns:d4p1="">ValueHere</DownloadRequestId>

Code Syntax

The example syntax can be used with Bing Ads SDKs. See Bing Ads API Code Examples for more examples.

public async Task<DownloadCampaignsByAccountIdsResponse> DownloadCampaignsByAccountIdsAsync(
	IList<long> accountIds,
	CompressionType? compressionType,
	DataScope dataScope,
	IList<DownloadEntity> downloadEntities,
	DownloadFileType? downloadFileType,
	string formatVersion,
	DateTime? lastSyncTimeInUTC)
	var request = new DownloadCampaignsByAccountIdsRequest
		AccountIds = accountIds,
		CompressionType = compressionType,
		DataScope = dataScope,
		DownloadEntities = downloadEntities,
		DownloadFileType = downloadFileType,
		FormatVersion = formatVersion,
		LastSyncTimeInUTC = lastSyncTimeInUTC

	return (await BulkService.CallAsync((s, r) => s.DownloadCampaignsByAccountIdsAsync(r), request));
static DownloadCampaignsByAccountIdsResponse downloadCampaignsByAccountIds(
	ArrayOflong accountIds,
	CompressionType compressionType,
	ArrayList<DataScope> dataScope,
	ArrayOfDownloadEntity downloadEntities,
	DownloadFileType downloadFileType,
	java.lang.String formatVersion,
	Calendar lastSyncTimeInUTC) throws RemoteException, Exception
	DownloadCampaignsByAccountIdsRequest request = new DownloadCampaignsByAccountIdsRequest();


	return BulkService.getService().downloadCampaignsByAccountIds(request);
static function DownloadCampaignsByAccountIds(

	$GLOBALS['Proxy'] = $GLOBALS['BulkProxy'];

	$request = new DownloadCampaignsByAccountIdsRequest();

	$request->AccountIds = $accountIds;
	$request->CompressionType = $compressionType;
	$request->DataScope = $dataScope;
	$request->DownloadEntities = $downloadEntities;
	$request->DownloadFileType = $downloadFileType;
	$request->FormatVersion = $formatVersion;
	$request->LastSyncTimeInUTC = $lastSyncTimeInUTC;

	return $GLOBALS['BulkProxy']->GetService()->DownloadCampaignsByAccountIds($request);


Service: BulkService.svc v13