Hi all
Have reviewed similar tickets, and there seems to be no consensus on if this is possible with the API. The docs suggest it might be possible to put something together using the Metrics and Audit APIs, but I have poked around with the responses from these APIs and I can't construct anything that will give me the actual time logged by a user on a ticket.
To clarify, I am not looking for total time spent, which is already documented.
I need to extract from the API, the time spent by users on tickets. I am sure there is a way to construct this from the audit logs, but I can't see how!
Please advise and document this Zendesk!
Thanks again for sharing your solution within the Community. From taking a look at your initial request, if you're looking to calculate an agent's handling time per ticket, I would recommend taking a look at the Ticket Metric Events API. This actually allows you to measure the time allotments for specific ticket events such as time until fulfill, pause events (when tickets are in the On-Hold status), or update status change events. By being able to target specific events within the ticket you would be able to curate your calculation based on your specific needs. For example, if you only wanted to know how long an agent spent with a ticket in the Open status you would be able to get that from this endpoint.
The actual calculation would be very similar to how you set it up as a report in Explore. However, you would just be hitting the API directly rather than extracting the data from Explore. You could even create a webhook to externally initiate hitting the API. For example, you could begin calculating an agent's ticket handling time once it's been updated to solved status. You would create an automation that initiates the webhook once a ticket is in solved status. Through the webhook, you would send that ticket id and the assignee id. Then you would be able to hit the Ticket Metric Events API to calculate agent handling time.
Hope this helps!
Best,
Erica