Filter contacts based on custom fields

Hi team,

I have a requirement to filter contacts from freshdesk based on custom field values which are of field types number and date field.

Had been trying with few combinations but unable to fetch the contacts getting invalid_field. Here are a couple of sample queries which i had tried with but unsuccessful.

https://domain.freshdesk.com/api/v2/search/contacts?query="test_field_2:2423"

https://domain.freshdesk.com/api/v2/search/contacts?query="custom_text:test"

Custom field names in the portal

"custom_fields": {
  "test_field_2": "12345",  // type : custom_phone_number
  "test_field_3": "2022-02-09", // type : custom_date
  "test_field_1": "test"  // type : custom_text,
}

Kindly let me know if my format used is incorrect and an example of the actual query will be helpful.
Thanks in advance.

1 Like

Hi mohammed
Good day!

Welcome to Freshworks Developer Community :smiley:

I tried the same API and it seems to work for me. Can you please try this

Check if the custom field is returning in the response -
curl -v -u <API_KEY>:X -X GET https://<domain>.freshdesk.com/api/v2/contact_fields

Then try using the query API with the same custom field name (case sensitive)-
curl -v -u <API_KEY>:X -X GET 'https://<domain>.freshdesk.com/api/v2/search/contacts?query="your_custom_field_name:value"'

2 Likes

Hi Banupriya,

Ya now it works. A bit weird why it didn’t work for the fields i had created earlier.
If you can try to create a field with name Test field 1 and see if the API works.

Thanks for taking the time.
Good day

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.