SearchAccounts Service Operation

 

Searches for accounts that match a specified criteria.

Request | Response

Error Codes

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

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

Request Body

ElementDescriptionData TypeRequired
IncludeTaxDetailsDetermines whether or not the returned AdvertiserAccount should include the TaxId, TaxIdStatus, and BusinessAddress elements. By default, the elements are not returned. To include the TaxId, TaxIdStatus, and BusinessAddress elements, set the value of this element to True.

Note: The TaxId, TaxIdStatus, and BusinessAddress elements were added after Customer Management Version 9 became generally available, so IncludeTaxDetails is used to gate the new elements for forward compatibility. This element will be removed in the next version of the Customer Management API, and all properties of the AdvertiserAccount will be returned by default.
booleanNo
OrderingDetermines the order of results by the specified property of an account

Note: You should only specify one OrderBy element in the array. Additional elements are not supported and will be ignored by the service.

For this service operation, the following values are supported in the Field element of a OrderBy object.

Id - The order is determined by the Idelement of the returned Account.

Name - The order is determined by the Name element of the returned Account.

Number - The order is determined by the Number element of the returned Account.
OrderBy arrayNo
PageInfoDetermines the index and size of results per page.PagingYes
PredicatesDetermines the request conditions. This operation's response will include accounts that match all of the specified predicates.

Note: With the exception of AccountLifeCycleStatus, you must specify exactly one predicate. When using the AccountLifeCycleStatus predicate field you must specify one additional predicate, for example with the Field set to UserId.

For a list of supported Field and Operator elements of a Predicate object for this service operation, see Predicate Field and Operator.
Predicate arrayYes

Predicate Field and Operator

For this service operation, the following are supported Field element and Operator elements of a Predicate object.

FieldOperatorDescription
AccountIdEquals

In
Use this field to search the Id element of the Account.
AccountLifeCycleStatusEqualsUse this field to search the AccountLifeCycleStatus element of the Account.

Possible values include any string representation of the AccountLifeCycleStatus, for example Value = AccountLifeCycleStatus.Active.ToString() or Value="Active" .
AccountNameContains

Equals
Use this field to search the Name element of the Account.
AccountNumberContains

Equals

In
Use this field to search the Number element of the Account.
CustomerIdEqualsUse this field to search the Id element of the Customer.
UserIdEqualsUse this field to search the UserId element of the User.

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 Managing User Authentication with OAuth.

ElementDescriptionData Type
AuthenticationTokenThe OAuth access token that represents a Microsoft Account user who has permissions to Bing Ads accounts.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
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/Customer/v9">
    <Action mustUnderstand="1">SearchAccounts</Action>
    <ApplicationToken i:nil="false"></ApplicationToken>
    <AuthenticationToken i:nil="false"></AuthenticationToken>
    <DeveloperToken i:nil="false"></DeveloperToken>
    <Password i:nil="false"></Password>
    <UserName i:nil="false"></UserName>
  </s:Header>
  <s:Body>
    <SearchAccountsRequest xmlns="https://bingads.microsoft.com/Customer/v9">
      <Predicates xmlns:e23="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e23:Predicate>
          <e23:Field i:nil="false"></e23:Field>
          <e23:Operator></e23:Operator>
          <e23:Value i:nil="false"></e23:Value>
        </e23:Predicate>
      </Predicates>
      <Ordering xmlns:e24="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e24:OrderBy>
          <e24:Field></e24:Field>
          <e24:Order></e24:Order>
        </e24:OrderBy>
      </Ordering>
      <PageInfo xmlns:e25="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e25:Index></e25:Index>
        <e25:Size></e25:Size>
      </PageInfo>
      <IncludeTaxDetails i:nil="false"></IncludeTaxDetails>
    </SearchAccountsRequest>
  </s:Body>
</s:Envelope>

Response Body

ElementDescriptionData Type
AccountsA list of accounts that meet the specified criteria.Account array

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/Customer/v9">
    <TrackingId p4:nil="false" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance"></TrackingId>
  </s:Header>
  <s:Body>
    <SearchAccountsResponse xmlns="https://bingads.microsoft.com/Customer/v9">
      <Accounts xmlns:e26="https://bingads.microsoft.com/Customer/v9/Entities" p5:nil="false" xmlns:p5="http://www.w3.org/2001/XMLSchema-instance">
        <e26:Account p5:type="-- specify derived type here with the appropriate prefix --">
          <e26:AccountType></e26:AccountType>
          <e26:BillToCustomerId p5:nil="false"></e26:BillToCustomerId>
          <e26:CountryCode p5:nil="false"></e26:CountryCode>
          <e26:CurrencyType p5:nil="false"></e26:CurrencyType>
          <e26:AccountFinancialStatus p5:nil="false"></e26:AccountFinancialStatus>
          <e26:Id p5:nil="false"></e26:Id>
          <e26:Language p5:nil="false"></e26:Language>
          <ForwardCompatibilityMap xmlns:e27="http://schemas.datacontract.org/2004/07/System.Collections.Generic" p5:nil="false">
            <e27:KeyValuePairOfstringstring>
              <e27:key p5:nil="false"></e27:key>
              <e27:value p5:nil="false"></e27:value>
            </e27:KeyValuePairOfstringstring>
          </ForwardCompatibilityMap>
          <e26:LastModifiedByUserId p5:nil="false"></e26:LastModifiedByUserId>
          <e26:LastModifiedTime p5:nil="false"></e26:LastModifiedTime>
          <e26:Name p5:nil="false"></e26:Name>
          <e26:Number p5:nil="false"></e26:Number>
          <e26:ParentCustomerId></e26:ParentCustomerId>
          <e26:PaymentMethodId p5:nil="false"></e26:PaymentMethodId>
          <e26:PaymentMethodType p5:nil="false"></e26:PaymentMethodType>
          <e26:PrimaryUserId p5:nil="false"></e26:PrimaryUserId>
          <e26:AccountLifeCycleStatus p5:nil="false"></e26:AccountLifeCycleStatus>
          <e26:TimeStamp p5:nil="false"></e26:TimeStamp>
          <e26:TimeZone p5:nil="false"></e26:TimeZone>
          <e26:PauseReason p5:nil="false"></e26:PauseReason>
          <!--These fields are included if the i:type attribute is AdvertiserAccount-->
          <e26:AgencyContactName p5:nil="false"></e26:AgencyContactName>
          <e26:AgencyCustomerId p5:nil="false"></e26:AgencyCustomerId>
          <e26:SalesHouseCustomerId p5:nil="false"></e26:SalesHouseCustomerId>
          <e26:TaxId p5:nil="false"></e26:TaxId>
          <e26:TaxType p5:nil="false"></e26:TaxType>
          <e26:BackUpPaymentInstrumentId p5:nil="false"></e26:BackUpPaymentInstrumentId>
          <e26:BillingThresholdAmount p5:nil="false"></e26:BillingThresholdAmount>
          <e26:TaxIdStatus p5:nil="false"></e26:TaxIdStatus>
          <e26:BusinessAddress p5:nil="false">
            <e26:City p5:nil="false"></e26:City>
            <e26:CountryCode p5:nil="false"></e26:CountryCode>
            <e26:Id p5:nil="false"></e26:Id>
            <e26:Line1 p5:nil="false"></e26:Line1>
            <e26:Line2 p5:nil="false"></e26:Line2>
            <e26:Line3 p5:nil="false"></e26:Line3>
            <e26:Line4 p5:nil="false"></e26:Line4>
            <e26:PostalCode p5:nil="false"></e26:PostalCode>
            <e26:StateOrProvince p5:nil="false"></e26:StateOrProvince>
            <e26:TimeStamp p5:nil="false"></e26:TimeStamp>
          </e26:BusinessAddress>
        </e26:Account>
      </Accounts>
    </SearchAccountsResponse>
  </s:Body>
</s:Envelope>

If the service operation fails, it throws a FaultException, which contains one or more of the Bing Ads API error data objects. For information about the fault detail objects, see Customer Management 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

Community Additions

ADD
Show: