LeadSquared Developer Centre

ON THIS PAGE

User Advanced Search


Lets you set multiple condition groups and conditions to search for users. It gives you the same functionality as the user advanced search feature on the LeadSquared UI.
It is most useful when you have a large number of users and want to filter them based on multiple criteria.

 

API URL

URL
Icon
POST https://{host}/v2/UserManagement.svc/User/AdvancedSearch?accessKey=AccessKey&secretKey=SecretKey

Request

Content-Type: application/json
JSON Body/Payload Icon
{
  "Columns": {
    "Include_CSV": "UserID,FirstName,LastName"
  },
  "GroupConditions": [
    {
      "Condition": [
        {
          "LookupName": "AssociatedPhoneNumbers",
          "Operator": "lik",
          "LookupValue": "23",
          "ConditionOperator": "OR"
        },
        {
          "LookupName": "FirstName",
          "Operator": "lik",
          "LookupValue": "Bo",
          "ConditionOperator": null
        }
      ],
      "GroupOperator": null
    }
  ],
  "GroupOperator": null,
  "Sorting": [
    {
      "ColumnName": "FirstName",
      "Direction": 0
    }
  ],
  "Paging": {
    "PageIndex": 1,
    "PageSize": 5
  }
}

Request Parameters

Parameter Description
Columns

The attributes you specify here will contain values in the API response. The attributes you omit, will be returned in the response but won’t display any values.
To retrieve the values of all attributes, pass “*”.

For example, if you pass only “UserID, FirstName, LastName” your response will look like this –

“UserId”: “3b1041fb-8374-11e7-8758-0a106ee76b21”,
“FirstName”: “Vir”,
“LastName”: “Singh”,
“EmailAddress”: null,
“Role”: null,
“StatusCode”: null,
“AssociatedPhoneNumbers”: null,

GroupConditions

You can create one or more condition groups. You can set multiple conditions inside each condition group.

Condition

LookupName – The user attribute you want to search by (FirstName, LastName etc.)

Operator – The following operators are permitted –
eq – equals
neq – not equal to
lik – like
nlik – not like
lik_s – starts with
lik_e – ends with
n – null
nn – not null

LookupValue – The value of the user attribute you passed in LookupName.

ConditionOperator“AND” or “OR”You can add multiple conditions with a condition group. When you’re adding the next condition, you must specify its relationship with the previous condition here. You must use the same operator between conditions within a group (Condition 1 AND Condition to AND Condition 3 or Condition 1 OR Condition 2 OR Condition 3)

GroupOperator

If you’re including multiple condition groups in the request, you must specify a group operator to define the relationship between the groups. It could be “AND” or “OR”.

Sorting

ColumnName – The column on which results will be sorted. For example, if you want results to be shown based on creation date, pass “CreatedOn”.

Direction – Direction “1” means descending order and “0” means ascending order.

Paging

PageIndex and PageSize – The results matching your criteria may be large. You can fetch the result in blocks of “PageSize” and make multiple calls to the API with increasing values of “PageIndex”.  For example, you can specify “PageIndex”: 1, “PageSize”: 100 for the first call and specify “PageIndex”: 2, “PageSize”: 100 for second call.

Response

200 OK
Content-Type: application/json
{
    "SearchInfo": {
        "TotalUsers": 2
    },
    "Users": [
        {
            "UserId": "bfd5a6ae-9d0b-11e7-b0ab-02e89b2fb8f4",
            "FirstName": "Bob",
            "LastName": "Doe",
            "EmailAddress": null,
            "Role": null,
            "StatusCode": null,
            "AssociatedPhoneNumbers": null,
            "DateFormat": null,
            "TimeZone": null,
            "IsPhoneCallAgent": null,
            "UserType": "0",
            "CreatedBy": null,
            "CreatedOn": null,
            "ModifiedBy": null,
            "ModifiedOn": null,
            "IsBillingUser": "false",
            "ManagerUserId": null,
            "Groups": null,
            "IsEmailSender": null,
            "PhotoUrl": null,
            "Designation": null,
            "Team": null,
            "Department": null,
            "SalesRegions": null,
            "Skills": null,
            "AvailabilityStatus": null,
            "OfficeLocationName": null,
            "Address": null,
            "City": null,
            "State": null,
            "Country": null,
            "ZipCode": null,
            "TelephonyAgentId": null,
            "RoleName": null,
            "ManagerName": null,
            "IsAdministrator": "false",
            "CreatedByName": null,
            "ModifiedByName": null,
            "AutoUserId": "0",
            "PhoneMain": null,
            "PhoneMobile": null,
            "PhoneOthers": null,
            "IsCheckinEnabled": "false",
            "IsCheckedIn": "false",
            "LastCheckedOn": null,
            "LastCheckedIpAddress": null,
            "WorkDayTemplateId": null,
            "WorkDayTemplateName": null,
            "HolidayCalendarId": null,
            "HolidayCalendarName": null,
            "TeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "TeamName": "Education 101",
            "IsHolidayCalendarDerived": "True",
            "IsWorkDayTemplateDerived": "True",
            "HolidayCalendarDerivedFromTeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "HolidayCalendarDerivedFromTeamName": "Education 101",
            "WorkDayTemplateDerivedFromTeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "WorkDayTemplateDerivedFromTeamName": "Education 101"
        },
        {
            "UserId": "3b1041fb-8374-11e7-8758-0a106ee76b21",
            "FirstName": "Vir",
            "LastName": "Singh",
            "EmailAddress": null,
            "Role": null,
            "StatusCode": null,
            "AssociatedPhoneNumbers": null,
            "DateFormat": null,
            "TimeZone": null,
            "IsPhoneCallAgent": null,
            "UserType": "0",
            "CreatedBy": null,
            "CreatedOn": null,
            "ModifiedBy": null,
            "ModifiedOn": null,
            "IsBillingUser": "false",
            "ManagerUserId": null,
            "Groups": null,
            "IsEmailSender": null,
            "PhotoUrl": null,
            "Designation": null,
            "Team": null,
            "Department": null,
            "SalesRegions": null,
            "Skills": null,
            "AvailabilityStatus": null,
            "OfficeLocationName": null,
            "Address": null,
            "City": null,
            "State": null,
            "Country": null,
            "ZipCode": null,
            "TelephonyAgentId": null,
            "RoleName": null,
            "ManagerName": null,
            "IsAdministrator": "false",
            "CreatedByName": null,
            "ModifiedByName": null,
            "AutoUserId": "0",
            "PhoneMain": null,
            "PhoneMobile": null,
            "PhoneOthers": null,
            "IsCheckinEnabled": "false",
            "IsCheckedIn": "false",
            "LastCheckedOn": null,
            "LastCheckedIpAddress": null,
            "WorkDayTemplateId": null,
            "WorkDayTemplateName": null,
            "HolidayCalendarId": null,
            "HolidayCalendarName": null,
            "TeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "TeamName": "Education 101",
            "IsHolidayCalendarDerived": "True",
            "IsWorkDayTemplateDerived": "True",
            "HolidayCalendarDerivedFromTeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "HolidayCalendarDerivedFromTeamName": "Education 101",
            "WorkDayTemplateDerivedFromTeamId": "8bfc8586-0f53-11e8-871e-02bf1924461c",
            "WorkDayTemplateDerivedFromTeamName": "Education 101"
        }
    ]
}

HTTP Response Codes

Code Description
200 OK

This is the status code for successful API call.

401 Unauthorized

The API call was made with invalid access credentials. Check your AccessKey and SecretKey.

400 Bad Request

The message body on the request is not as per API specification. Make sure that content type is set to “application/json” and the JSON body has correct attribute names and structure.

404 Not Found

The API could not be found. Please check the API signature.

429 Too Many Requests

API calls exceeded the limit of 25 in 5 second(s)

500 Internal Server Error

The API called failed. There could be many reasons for it. Check the exception message to get more details.

On this page

© 2022 by MarketXpander Services Pvt Ltd. All Rights Reserved.