Query Tracked time using API

hi all,

Is there a way to get the tracked time on a ticket using rest API?
I did not see any entry reg. this in the API documentation.

Thanks a lot in advance

Yes there is: [GET] /api/v1/ticket_history/{Ticket-ID}
This will return tons of information, have fun fiddling around. :slight_smile:

Thanks a lot for your answer :slight_smile:
I’ll check that out!

I’ve searched APIs doc and couldn’t find this endpoint, is it missing?

Also, I cannot find how to add spent time to a ticket. According to your reply one would suppose to add time_spent to a ticket update, or time_unit, but it’s just a guess. Could you please share how to exactly add spent time to a ticket? thank you

This is currently not documented, correct.
It’s quite hard keeping up with the endpoints… :smiley:

I had to cheat here to.
You ship this information with adding an article (according to our WebApp), payload can look like this:

URL [PUTS] /api/v1/tickets/29

{
   "number":"93029",
   "title":"magic",
   "group_id":"1",
   "owner_id":"3",
   "customer_id":20,
   "state_id":"1",
   "priority_id":"2",
   "article":{
      "from":"Marcel Herrguth",
      "to":"",
      "cc":"",
      "subject":"",
      "body":"Can you hear it, the wayne train? <br/>Where does it go to ?!<br/>To Mount Whateverest!",
      "content_type":"text/html",
      "ticket_id":"29",
      "type_id":10,
      "sender_id":1,
      "internal":true,
      "in_reply_to":"",
      "form_id":"107591673",
      "subtype":"",
      "time_unit":"2"},
   "updated_at":"2019-06-21T08:58:38.617Z",
   "preferences":{},
   "pending_time":null,
   "id":29
}

Those are time accounting specific routes:

                                                    GET                  /api/v1/time_accounting/log/by_ticket/:year/:month(.:format)                            time_accountings#by_ticket
                                                    GET                  /api/v1/time_accounting/log/by_customer/:year/:month(.:format)                          time_accountings#by_customer
                                                    GET                  /api/v1/time_accounting/log/by_organization/:year/:month(.:format)                      time_accountings#by_organization

You can get all routes by running: zammad run rake routes

2 Likes