I believe you are trying to pass tickets from the unassigned queue into an external system. We do have an API to filter tickets based on the agent assigned to the ticket. The article for the API can be found here :https://api.freshservice.com/#filter_tickets
You can get the list of tickets with no agent assigned using the below CURL command:
curl -v -u user@yourcompany.com:test -X GET 'https://domain.freshservice.com/api/v2/tickets/filter?query=%agent_id:null%22'
So , to filter these tickets , we will have to use the agent’s ID and pass them into the API through the query params. Since , we are trying to retrieve the unassigned tickets , we will have to set the agent ID as null and pass it into the API as shown in the below screenshot:
This will provide you all the tickets which are present in the unassigned queue at the moment.
We do not have a direct way to get the count of the unassigned tickets in the queue. The result returned from the API will be in the form of an Array with multiple object, with each object representing a single ticket. The solution for the same is to have the response collected by calling the API and iterating the response by running a loop on the array and counting the number of objects which gives the total number of unassigned tickets.