How to get tickets from past month?

Hello,

I’m trying to get all closed tickets from the past month but I can’t figure out if this is possible. I know you can filter on a certain date but I don’t want to change the endpoint everytime.

Hi @tychopycho,

I could suggest two ways to do it.

1. List All Tickets API with an existing filtered view

If it’s for a custom app for your own account. A specific filter view can List All Tickets API can be used with an existing filtered view to get the tickets listed for the specified filtered view.

For example,

curl -v -u user@yourcompany.com:test -X GET 'https://domain.freshdesk.com/api/v2/tickets?filter=new_and_my_open'

2. Filter Tickets API with date range filter

This is an option that you mentioned to search based on a specific date range filter. The URL can be dynamically built to fetch the last month’s tickets.

For example,

Last month’s date range can be fetched with the following code.

const prevMonthStartDate = new Date(this.date.getFullYear(), this.date.getMonth() - 1, 1);
const prevMonthEndDate = new Date(this.date.getFullYear(), this.date.getMonth() - 1 + 1, 0);
curl -v -u user@yourcompany.com:test -X GET 'https://domain.freshdesk.com/api/v2/search/tickets?query="created_at:>%272020-12-31%27%20AND%20created_at:<%272020-12-01%27"'
2 Likes

Hi @Raviraj

Unfortunately the second method is not possible because I’m working with Oracle APEX.
Could you tell me some more about the first method because I don’t quite understand it.

@tychopycho Fine. About this first option,

In the Freshdesk portal, an agent can go to the Tickets page and add some filters and save this current filtered view as a new view. Then the same view can be used in the API to apply all the filters that are saved with the view.

The instructions are available here on how to save a new filtered view.

How to use this filtered view is available in the List All Tickets API documentation as I mentioned in the previous message.

2 Likes

Hi @Raviraj

Thanks for helping me, you reallly helped me out here!

1 Like

Hi!
I am using the Power BI platform to get tickets on created data range. I think that the form how the code is written can be diferente. Do you have anything in you pipeline to solve this?

I want use like the example below:

https://domain.freshdesk.com/api/v2/search/tickets?include=stats%20AND%20per_page=100%20AND%20query=created_at:>%272022-01-01%27%20AND%20created_at:<%272022-03-31”

Thanks!