SearchAccounts Service Operation - Customer Management

Searches for accounts that match the request criteria.

For example you can search for accounts that the current authenticated user can access.

Tip

Please see the Account Hierchy and User Permissions guide for an overview with examples.

Request Elements

The SearchAccountsRequest 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.

Note

Unless otherwise noted below, all request elements are required.

Request Body Elements

Element Description Data Type
Ordering Determines the order of results by the specified property of an account.

This request element is optional. You can specify up to one OrderBy element in the array. Additional elements are not supported and will be ignored by the service.

If you set the Field element of the OrderBy object to "Id", "Name", or "Number", the returned Accounts will be ordered by the account identifiers, names, or numbers accordingly.

This request element is optional.
OrderBy array
PageInfo Determines the index and size of results per page. Paging
Predicates Determines the conditions that all must be met to return accounts.

You must include exactly one predicate. If the predicate Field is set to "AccountLifeCycleStatus", then you must specify one additional predicate with the Field set to another value such as UserId.

For details about each supported predicate Field value see Predicate Remarks.
Predicate array

Request Header Elements

Element Description Data Type
AuthenticationToken The OAuth access token that represents a Microsoft Account user who has permissions to Microsoft Advertising accounts. 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 SearchAccountsResponse 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
Accounts A list of accounts that meet the request criteria. AdvertiserAccount array

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="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/Customer/v13">
    <Action mustUnderstand="1">SearchAccounts</Action>
    <AuthenticationToken i:nil="false">ValueHere</AuthenticationToken>
    <DeveloperToken i:nil="false">ValueHere</DeveloperToken>
  </s:Header>
  <s:Body>
    <SearchAccountsRequest xmlns="https://bingads.microsoft.com/Customer/v13">
      <Predicates xmlns:e160="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="false">
        <e160:Predicate>
          <e160:Field i:nil="false">ValueHere</e160:Field>
          <e160:Operator>ValueHere</e160:Operator>
          <e160:Value i:nil="false">ValueHere</e160:Value>
        </e160:Predicate>
      </Predicates>
      <Ordering xmlns:e161="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="false">
        <e161:OrderBy>
          <e161:Field>ValueHere</e161:Field>
          <e161:Order>ValueHere</e161:Order>
        </e161:OrderBy>
      </Ordering>
      <PageInfo xmlns:e162="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="false">
        <e162:Index>ValueHere</e162:Index>
        <e162:Size>ValueHere</e162:Size>
      </PageInfo>
    </SearchAccountsRequest>
  </s:Body>
</s:Envelope>

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="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/Customer/v13">
    <TrackingId d3p1:nil="false" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance">ValueHere</TrackingId>
  </s:Header>
  <s:Body>
    <SearchAccountsResponse xmlns="https://bingads.microsoft.com/Customer/v13">
      <Accounts xmlns:e163="https://bingads.microsoft.com/Customer/v13/Entities" d4p1:nil="false" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">
        <e163:AdvertiserAccount>
          <e163:BillToCustomerId d4p1:nil="false">ValueHere</e163:BillToCustomerId>
          <e163:CurrencyCode d4p1:nil="false">ValueHere</e163:CurrencyCode>
          <e163:AccountFinancialStatus d4p1:nil="false">ValueHere</e163:AccountFinancialStatus>
          <e163:Id d4p1:nil="false">ValueHere</e163:Id>
          <e163:Language d4p1:nil="false">ValueHere</e163:Language>
          <e163:LastModifiedByUserId d4p1:nil="false">ValueHere</e163:LastModifiedByUserId>
          <e163:LastModifiedTime d4p1:nil="false">ValueHere</e163:LastModifiedTime>
          <e163:Name d4p1:nil="false">ValueHere</e163:Name>
          <e163:Number d4p1:nil="false">ValueHere</e163:Number>
          <e163:ParentCustomerId>ValueHere</e163:ParentCustomerId>
          <e163:PaymentMethodId d4p1:nil="false">ValueHere</e163:PaymentMethodId>
          <e163:PaymentMethodType d4p1:nil="false">ValueHere</e163:PaymentMethodType>
          <e163:PrimaryUserId d4p1:nil="false">ValueHere</e163:PrimaryUserId>
          <e163:AccountLifeCycleStatus d4p1:nil="false">ValueHere</e163:AccountLifeCycleStatus>
          <e163:TimeStamp d4p1:nil="false">ValueHere</e163:TimeStamp>
          <e163:TimeZone d4p1:nil="false">ValueHere</e163:TimeZone>
          <e163:PauseReason d4p1:nil="false">ValueHere</e163:PauseReason>
          <e163:ForwardCompatibilityMap xmlns:e164="http://schemas.datacontract.org/2004/07/System.Collections.Generic" d4p1:nil="false">
            <e164:KeyValuePairOfstringstring>
              <e164:key d4p1:nil="false">ValueHere</e164:key>
              <e164:value d4p1:nil="false">ValueHere</e164:value>
            </e164:KeyValuePairOfstringstring>
          </e163:ForwardCompatibilityMap>
          <e163:LinkedAgencies d4p1:nil="false">
            <e163:CustomerInfo>
              <e163:Id d4p1:nil="false">ValueHere</e163:Id>
              <e163:Name d4p1:nil="false">ValueHere</e163:Name>
            </e163:CustomerInfo>
          </e163:LinkedAgencies>
          <e163:SalesHouseCustomerId d4p1:nil="false">ValueHere</e163:SalesHouseCustomerId>
          <e163:TaxInformation xmlns:e165="http://schemas.datacontract.org/2004/07/System.Collections.Generic" d4p1:nil="false">
            <e165:KeyValuePairOfstringstring>
              <e165:key d4p1:nil="false">ValueHere</e165:key>
              <e165:value d4p1:nil="false">ValueHere</e165:value>
            </e165:KeyValuePairOfstringstring>
          </e163:TaxInformation>
          <e163:BackUpPaymentInstrumentId d4p1:nil="false">ValueHere</e163:BackUpPaymentInstrumentId>
          <e163:BillingThresholdAmount d4p1:nil="false">ValueHere</e163:BillingThresholdAmount>
          <e163:BusinessAddress d4p1:nil="false">
            <e163:City d4p1:nil="false">ValueHere</e163:City>
            <e163:CountryCode d4p1:nil="false">ValueHere</e163:CountryCode>
            <e163:Id d4p1:nil="false">ValueHere</e163:Id>
            <e163:Line1 d4p1:nil="false">ValueHere</e163:Line1>
            <e163:Line2 d4p1:nil="false">ValueHere</e163:Line2>
            <e163:Line3 d4p1:nil="false">ValueHere</e163:Line3>
            <e163:Line4 d4p1:nil="false">ValueHere</e163:Line4>
            <e163:PostalCode d4p1:nil="false">ValueHere</e163:PostalCode>
            <e163:StateOrProvince d4p1:nil="false">ValueHere</e163:StateOrProvince>
            <e163:TimeStamp d4p1:nil="false">ValueHere</e163:TimeStamp>
            <e163:BusinessName d4p1:nil="false">ValueHere</e163:BusinessName>
          </e163:BusinessAddress>
          <e163:AutoTagType d4p1:nil="false">ValueHere</e163:AutoTagType>
          <e163:SoldToPaymentInstrumentId d4p1:nil="false">ValueHere</e163:SoldToPaymentInstrumentId>
        </e163:AdvertiserAccount>
      </Accounts>
    </SearchAccountsResponse>
  </s:Body>
</s:Envelope>

Code Syntax

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

public async Task<SearchAccountsResponse> SearchAccountsAsync(
	IList<Predicate> predicates,
	IList<OrderBy> ordering,
	Paging pageInfo)
{
	var request = new SearchAccountsRequest
	{
		Predicates = predicates,
		Ordering = ordering,
		PageInfo = pageInfo
	};

	return (await CustomerManagementService.CallAsync((s, r) => s.SearchAccountsAsync(r), request));
}
static SearchAccountsResponse searchAccounts(
	ArrayOfPredicate predicates,
	ArrayOfOrderBy ordering,
	Paging pageInfo) throws RemoteException, Exception
{
	SearchAccountsRequest request = new SearchAccountsRequest();

	request.setPredicates(predicates);
	request.setOrdering(ordering);
	request.setPageInfo(pageInfo);

	return CustomerManagementService.getService().searchAccounts(request);
}
static function SearchAccounts(
	$predicates,
	$ordering,
	$pageInfo)
{

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

	$request = new SearchAccountsRequest();

	$request->Predicates = $predicates;
	$request->Ordering = $ordering;
	$request->PageInfo = $pageInfo;

	return $GLOBALS['CustomerManagementProxy']->GetService()->SearchAccounts($request);
}
response=customermanagement_service.SearchAccounts(
	Predicates=Predicates,
	Ordering=Ordering,
	PageInfo=PageInfo)

Requirements

Service: CustomerManagementService.svc v13
Namespace: https://bingads.microsoft.com/Customer/v13