SearchCustomers Service Operation

 

Searches for customers that match a specified criteria.

Request | Response

Error Codes

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

The SearchCustomersRequest 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
ApplicationScopeA value that determines whether to return results for advertising customers or publishing customers. If you do not specify the scope, the list may include both types of customers.ApplicationTypeNo
DateRangeDetermines the minimum and maximum customer creation date range.DateRangeNo
OrderingDetermines the order of results by the specified property of a customer. 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 Customer.

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

Number - The order is determined by the Number element of the returned Customer.
OrderBy arrayNo
PageInfoDetermines the index and size of results per page.PagingYes
PredicatesDetermines the request conditions. This operation's response will include customers that match all of the specified predicates. Note: You may specify up to 10 predicates. You may use the CreatedDate predicate field twice to specify a created date range, and otherwise may only use each predicate field once.

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
AccountIdEqualsUse this field to search the Id element of the Account.
AccountNameContains

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

Equals
Use this field to search the Number element of the Account.
ApplicationScopeEqualsFor internal use only.
CreatedDateGreaterThanEquals

LessThanEquals
Use this field to search the date when the customer was created or signed up. Note: The date is stored in Coordinated Universal Time (UTC). Only the month, day, and year of the specified string are used for search. If you specify the hour, minutes, and seconds of a date they will be ignored.

For information about the format of the date and time, see the dateTime entry in Primitive XML Data Types.
CustomerIdEquals

In
Use this field to search the Id element of the Customer.
CustomerNameContains

Equals
Use this field to search the Name element of the Customer.
CustomerNumberContains

Equals
Use this field to search the Number element of the Customer.
EmailContains

Equals
Use this field to search the Email element of the ContactInfo within a User.
MarketCountryEqualsUse this field to search the MarketCountry element of the Customer. Note: The MarketCountry and MarketLanguage predicate fields are not required; however, if either is specified then both are required.
MarketLanguageEqualsUse this field to search the MarketLanguage element of the Customer. Note: The MarketCountry and MarketLanguage predicate fields are not required; however, if either is specified then both are required.
PersonNameContains

Equals
Use this field to search the combined FirstName, MiddleInitial, and LastName elements of the PersonName within a User.

The string value corresponding to elements within PersonName should be separated by spaces in the order of FirstName, MiddleInitial, and LastName.
UserNameContains

Equals
Use this field to search the UserName element of the User.
TaxIdContains

Equals
For internal use only.

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">SearchCustomers</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>
    <SearchCustomersRequest xmlns="https://bingads.microsoft.com/Customer/v9">
      <ApplicationScope></ApplicationScope>
      <Predicates xmlns:e19="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e19:Predicate>
          <e19:Field i:nil="false"></e19:Field>
          <e19:Operator></e19:Operator>
          <e19:Value i:nil="false"></e19:Value>
        </e19:Predicate>
      </Predicates>
      <DateRange xmlns:e20="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e20:MinDate i:nil="false"></e20:MinDate>
        <e20:MaxDate i:nil="false"></e20:MaxDate>
      </DateRange>
      <Ordering xmlns:e21="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e21:OrderBy>
          <e21:Field></e21:Field>
          <e21:Order></e21:Order>
        </e21:OrderBy>
      </Ordering>
      <PageInfo xmlns:e22="https://bingads.microsoft.com/Customer/v9/Entities" i:nil="false">
        <e22:Index></e22:Index>
        <e22:Size></e22:Size>
      </PageInfo>
    </SearchCustomersRequest>
  </s:Body>
</s:Envelope>

Response Body

ElementDescriptionData Type
CustomersA list of customers that meet the specified criteria.Customer 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>
    <SearchCustomersResponse xmlns="https://bingads.microsoft.com/Customer/v9">
      <Customers xmlns:e23="https://bingads.microsoft.com/Customer/v9/Entities" p5:nil="false" xmlns:p5="http://www.w3.org/2001/XMLSchema-instance">
        <e23:Customer>
          <e23:CustomerAddress p5:nil="false">
            <e23:City p5:nil="false"></e23:City>
            <e23:CountryCode p5:nil="false"></e23:CountryCode>
            <e23:Id p5:nil="false"></e23:Id>
            <e23:Line1 p5:nil="false"></e23:Line1>
            <e23:Line2 p5:nil="false"></e23:Line2>
            <e23:Line3 p5:nil="false"></e23:Line3>
            <e23:Line4 p5:nil="false"></e23:Line4>
            <e23:PostalCode p5:nil="false"></e23:PostalCode>
            <e23:StateOrProvince p5:nil="false"></e23:StateOrProvince>
            <e23:TimeStamp p5:nil="false"></e23:TimeStamp>
          </e23:CustomerAddress>
          <e23:CustomerFinancialStatus p5:nil="false"></e23:CustomerFinancialStatus>
          <e23:Id p5:nil="false"></e23:Id>
          <e23:Industry p5:nil="false"></e23:Industry>
          <e23:LastModifiedByUserId p5:nil="false"></e23:LastModifiedByUserId>
          <e23:LastModifiedTime p5:nil="false"></e23:LastModifiedTime>
          <e23:MarketCountry p5:nil="false"></e23:MarketCountry>
          <ForwardCompatibilityMap xmlns:e24="http://schemas.datacontract.org/2004/07/System.Collections.Generic" p5:nil="false">
            <e24:KeyValuePairOfstringstring>
              <e24:key p5:nil="false"></e24:key>
              <e24:value p5:nil="false"></e24:value>
            </e24:KeyValuePairOfstringstring>
          </ForwardCompatibilityMap>
          <e23:MarketLanguage p5:nil="false"></e23:MarketLanguage>
          <e23:Name p5:nil="false"></e23:Name>
          <e23:ServiceLevel p5:nil="false"></e23:ServiceLevel>
          <e23:CustomerLifeCycleStatus p5:nil="false"></e23:CustomerLifeCycleStatus>
          <e23:TimeStamp p5:nil="false"></e23:TimeStamp>
          <e23:Number p5:nil="false"></e23:Number>
        </e23:Customer>
      </Customers>
    </SearchCustomersResponse>
  </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
Show: