searchProfiles method

Future<SearchProfilesResponse> searchProfiles({
  1. required String domainName,
  2. required String keyName,
  3. required List<String> values,
  4. List<AdditionalSearchKey>? additionalSearchKeys,
  5. LogicalOperator? logicalOperator,
  6. int? maxResults,
  7. String? nextToken,
})

Searches for profiles within a specific domain using one or more predefined search keys (e.g., _fullName, _phone, _email, _account, etc.) and/or custom-defined search keys. A search key is a data type pair that consists of a KeyName and Values list.

This operation supports searching for profiles with a minimum of 1 key-value(s) pair and up to 5 key-value(s) pairs using either AND or OR logic.

May throw AccessDeniedException. May throw BadRequestException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter domainName : The unique name of the domain.

Parameter keyName : A searchable identifier of a customer profile. The predefined keys you can use to search include: _account, _profileId, _assetId, _caseId, _orderId, _fullName, _phone, _email, _ctrContactId, _marketoLeadId, _salesforceAccountId, _salesforceContactId, _salesforceAssetId, _zendeskUserId, _zendeskExternalId, _zendeskTicketId, _serviceNowSystemId, _serviceNowIncidentId, _segmentUserId, _shopifyCustomerId, _shopifyOrderId.

Parameter values : A list of key values.

Parameter additionalSearchKeys : A list of AdditionalSearchKey objects that are each searchable identifiers of a profile. Each AdditionalSearchKey object contains a KeyName and a list of Values associated with that specific key (i.e., a key-value(s) pair). These additional search keys will be used in conjunction with the LogicalOperator and the required KeyName and Values parameters to search for profiles that satisfy the search criteria.

Parameter logicalOperator : Relationship between all specified search keys that will be used to search for profiles. This includes the required KeyName and Values parameters as well as any key-value(s) pairs specified in the AdditionalSearchKeys list.

This parameter influences which profiles will be returned in the response in the following manner:

  • AND - The response only includes profiles that match all of the search keys.
  • OR - The response includes profiles that match at least one of the search keys.
The OR relationship is the default behavior if this parameter is not included in the request.

Parameter maxResults : The maximum number of objects returned per page.

The default is 20 if this parameter is not included in the request.

Parameter nextToken : The pagination token from the previous SearchProfiles API call.

Implementation

Future<SearchProfilesResponse> searchProfiles({
  required String domainName,
  required String keyName,
  required List<String> values,
  List<AdditionalSearchKey>? additionalSearchKeys,
  LogicalOperator? logicalOperator,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $query = <String, List<String>>{
    if (maxResults != null) 'max-results': [maxResults.toString()],
    if (nextToken != null) 'next-token': [nextToken],
  };
  final $payload = <String, dynamic>{
    'KeyName': keyName,
    'Values': values,
    if (additionalSearchKeys != null)
      'AdditionalSearchKeys': additionalSearchKeys,
    if (logicalOperator != null) 'LogicalOperator': logicalOperator.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/domains/${Uri.encodeComponent(domainName)}/profiles/search',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return SearchProfilesResponse.fromJson(response);
}