Freshsales lookup, or filtered_search do not work on phone numbers, all contacts are returned

Hi all, I’m trying to search for a Contact in Freshsales based on their phone number. I have tried the three search methods, “lookup”, and “filtered_search”. None of them work given a phone number, and, to make matters worse, return all contacts. One would expect that a search failure (e.g. no matches, etc.) would return NO records, never mind all of them.
In addition, the only time I can get a Contact match returned via the /search endpoint requires an exact match, there is no way to include a wildcard.

Someone please help!

1 Like

Hello @mother, Welcome to the Developer Community! :tada:

To be able to search and retrieve a Contact in Freshsales using their phone number, you can use the Freshsales Search API

Here are a couple of sample requests and responses

1. Fetching Contact for an Exact Match of a Phone number

Request:

curl --location --request GET 'https://testdomain.freshsales.io/api/search?q=4129512057&include=contact&per_page=25' \
--header 'Authorization: Token token=<YOUR-API-TOKEN>' \
--header 'Content-Type: application/json'

Response:

[
    {
        "id": "70000714691",
        "name": "Matthew Perry",
        "owner": {
            "id": 70000009543,
            "name": "Anand Chandran"
        },
        "updated_at": "2021-08-26T17:02:37Z",
        "primary_sales_account_name": "qwer",
        "type": "contact",
        "more_match": {
            "field_name": "Mobile",
            "field_value": "4129512057"
        }
    }
]

2. Fetching Contact for a Partial Match of a Phone Number
Here any Phone number that begins with “12345” are included as part of the results

Request:

curl --location --request GET 'https://testdomain.freshsales.io/api/search?q=12345&include=contact&per_page=25' \
--header 'Authorization: Token token=<YOUR-API-TOKEN>' \
--header 'Content-Type: application/json'

Response:

[
    {
        "id": "70001247341",
        "name": "Agatha Christie",
        "owner": {
            "id": 70000009543,
            "name": "Anand Chandran"
        },
        "updated_at": "2021-08-26T16:48:26Z",
        "type": "contact",
        "more_match": {
            "field_name": "Mobile",
            "field_value": "123456789"
        }
    },
    {
        "id": "70000063617",
        "name": "sam curran",
        "email": "lead@testemail.com",
        "updated_at": "2020-10-09T15:49:40Z",
        "type": "contact",
        "more_match": {
            "field_name": "Mobile",
            "field_value": "1234567890"
        }
    }
]

Please note that in order to make sure that you are fetching results based on the Mobile number in this case, you need to parse the results array and ensure that you are filtering for more_match.field name equal to “Mobile” as the results can also contain objects that have other fields that contain the same numeric for example an email id like somtestmail1234@gmail.com.
Hope this helps!

Could you share a sample request that was unexpectedly returning all contacts?