How to get user's time logs from API


  • Ross Edwards

    For the benefit of future people, I have worked around this by building a Report in Explore with the calculated metric as documented here:

    I put this in a Dashboard, scheduled it to deliver as CSV to me, setup an Outlook rule to forward this to Zapier, extracted the rows into SQL server, then did my thing (send them to our time tracking system).

    Very messy, but work.  Would be much nicer to call the API.

  • Nicole Saunders
    Zendesk Community Manager

    Thanks for sharing that workaround for others, Ross. Our Developer Support team should be along soon to respond further to your original post. 

  • Erica Girges
    Zendesk Developer Advocacy
    Hi Ross, 
    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!
  • Ross Edwards

    Hi Erica

    Thanks for your message, this makes sense, however I can't find the equivalent values in the Ticket Metric Events API that match the working example as documented for Explore.

    Note I am only interested in the time logs submitted by users using the time tracking feature.

    In order to create the "update handling time" metric, these docs refer to Changes - Previous value and Changes - New value attributes.

    However there is no mention of these values in the API.  Also I can't see any mention of the agent ID in the responses from this API, so how could I measure time longs for users?

    Please can I ask for an example of how to recreate the Explore example using the API.  For example, starting with the output of the Ticket Metrics Events API:


    This returns a whole bunch of metrics, but nothing I can see would be useful, or relates to the Explore example.  Would be really helpful if you can say exactly what metrics I need to reference in my calculation, and how I can relate this to an agent, as above.



  • Ross Edwards

    OK feel free to correct me - I think we should actually be looking at the Ticket Audit Events API.  

    The documentation is wrong in saying that Ticket Metric Events can be used to measure agent performance, "You can use the ticket metric events API to track reply times, agent work times, and requester wait times."  I don't see how this is possible.

    I believe the actual data we need to calculate agent work time is in the Audit Events API.

    I can call this for a ticket, and I there is a custom field with a numerica field name, which I believe is tracking the agent time logs:


    "events": [
                        "id": 6201053196817,
                        "type": "Comment",
                        "author_id": 367200842778,

                    "id": 6201053197201,

                        "type": "Change",
                        "value": "5820",
                        "field_name": "360006218897",
                        "previous_value": "4320"
    I think this is telling me that there was an update, against the named agent, where the  agent logged 25 mins on the ticket (5820-4320)/60).
    It would be sooo much nicer if the API just exposed the actual work times, but at least I can now get to them from the API.  I do think the documentation on this needs correcting and an example adding such as above, this will help other users who want to get agent work time from the API.
  • Erica Girges
    Zendesk Developer Advocacy
    Hey Ross, 
    Thanks for following up and pointing this out. I took a further look into the Ticket Audit Change Event and the specific metric calculations provided in the above article. It does appear that specific field value change is where the calculation is coming from for that specific example. 
    I'm definitely going to get in touch with our team to make sure there's more clarity in our docs and walkthrough articles. 
    I also truly appreciate your feedback on wanting easier access to agent work times via API. We're all for wanting to make the process as smooth as possible so I know the team will love to get this input. 

Please sign in to leave a comment.

Powered by Zendesk