How to filter Contacts by "associated Tickets data" in FilterContacts API

Hello, my name is Isaac and I’m new here.

I have a question regarding the use of the “List All Contacts” and/or the “Filter Contacts” API. I would like to know if there’s any way to filter contacts based on whether they have associated tickets which have been updated since X days ago (or since date X)? Or something similar to filter Contacts based on data of their associated Tickets?

Context:
I have a process running periodically to get Freshdesk data of “all tickets updated since 3 days ago”, through the “List all tickets” API, and bring that data into a database of my own.

In that process, I also need each ticket’s customer’s data, so this process that loads FD tickets data into my database, also includes calls to the Contacts API to get the customers’s data and fill that for each ticket. However, at present, this calling to the Contacts API, brings back ALL customers through iterations, which is inefficient. So this can happen to me today:

-Total Freshdesk history so far: 3500+ tickets, 2500+ contacts.
-Tickets updated in the last 3 days: 500+ tickets.
-Process that updates my database with tickets data: calls the tickets API 6 times (fetches 500+ tickets) and the contacts API 26 times (fetches 2500+ contacts), and then reads contacts data only for the tickets fetched (say, 400+ contacts).

In reality, it could be that I need only 400+ contacts from the full Contacts list, for the “recently updated” tickets. So my process is currently inefficient in that it clearly makes more API calls than would be ideally needed and runs longer than ideally needed.

So, is there a way to filter the Contacts list based on any field or piece of data that links each Contact with their associated Tickets?

My “plan B”, if there is no way of doing this or something similar to this, is to build a Freshdesk Contacts table in my own database, and update that just like I do with my Freshdesk Tickets table, with its own “Contacts updated in the last X days” filter using the “updated_since” filter in the “List All Contacts” API. I have a feeling this may be more efficient since I think it’s unlikely a Contact will see many updates after creation (unlike tickets), but I’d still like to know whether my plan A is feasible.

Thanks in advance!! And Best Regards from Chile,
Isaac

(PS: I didn’t attach any code/logs/etc. to this post because, IMO, the question is more conceptual than technical really.)

1 Like

Hello Isaac,

Welcome to community :slight_smile:

As far as I have understood your use case, you want to get all tickets updated X days ago with their contact details.
If that is the case, you can use “include” to embed additional details to your payload.
So now your url should look like:
https://{{domain}}.freshdesk.com/api/v2/tickets?updated_since=2021-01-19T02:00:00Z&include=requester

This will bring all tickets that were updated since the date mentioned and also includes the information of the ticket requester (contact) for each ticket object.

Hope this helps you out, if not please let us know and we will try finding the best solution for you :slight_smile:

4 Likes

Hello Yusra,

Thank you very much! That is straightforward and easier indeed :slight_smile:

Thanks again!

Best regards,
Isaac

3 Likes