Tracking Time

Run a new time entry

What are you waiting for? Start to track your time now!

curl -u <email>:<password> \  -H "Content-Type: application/json" \  -d '{"created_with":"API example code","description":"Hello Toggl","tags":[],"billable":false,"workspace_id":{workspace_id},"duration":-1,"start":"1984-06-08T11:02:53.000Z","stop":null}' \  -X POST https://api.track.toggl.com/api/v9/workspaces/{workspace_id}/time_entries

A new time entry will start tracking time. You can see the running time in the Toggl Track web app.

[image]

Remember to replace {workspace_id} for the corresponding one both in the URL path and in the payload field "workspace_id".

You can always ask the details about your running time entry as follows:

  curl -u <email>:<password> \    -H "Content-Type: application/json" \    -X GET https://api.track.toggl.com/api/v9/me/time_entries/current
{  "data": {    "id": 436694100,    "wid": 777,    "pid": 193791,    "billable": false,    "start": "1984-01-30T09:08:04+00:00",    "duration": -1,    "description": "Running time entry",    "at": "1984-01-30T09:08:12+00:00"  }}

About the duration field

To create a time entry that started and stopped you can provide both the start and the duration fields. Where the:

  • start field will have the format “2022-10-27T15:38:45Z”
  • duration field will have the duration in seconds, for example 120.

To create a time entry that started and continues to be running, the duration field must be negative. In UNIX environments you can create a running time entry for the current date using the following command:

curl -u <email>:<password> \  -H "Content-Type: application/json" \  -d '{"created_with":"API example code","description":"Hello Toggl","tags":[],"billable":false,"workspace_id":{workspace_id},"duration":-1,"start":"'$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)'","stop":null}' \  -X POST https://api.track.toggl.com/api/v9/workspaces/{workspace_id}/time_entries

Stop an existing time entry

Don’t forget to stop your running time entry!

curl -u <email>:<password> \  -X PATCH https://api.track.toggl.com/api/v9/workspaces/{workspace_id}/time_entries/{time_entry_id}/stop

And now, the time entry is in your history.

[image]

Manual mode

It is always possible to insert a time entry specifying the start time and the duration.

info

The stop time will be considered as the start time plus the specified duration.

curl -u <email>:<password> \  -H "Content-Type: application/json" \  -d '{"description":"Meeting with clients","tags":["billed"],"workspace_id":{workspace_id},"duration":1200,"start":"2022-03-05T07:58:58.000Z","created_with":"curl"}' \  -X POST https://api.track.toggl.com/api/v9/workspaces/{workspace_id}/time_entries

Time entry history

If you want to retrieve the list of time entries in a specific time window, you can use start_date and end_date parameters as below.

:warning: CAUTION

The limit of returned time entries is 1000. Consider using detailed reports for the whole list.

curl -u <email>:<password> \  -H "Content-Type: application/json" \  -X GET "https://api.track.toggl.com/api/v9/me/time_entries?start_date=1984-03-10&end_date=1984-03-12"

The result is an array composed of time entry objects.

Check the docs on Time Entry for further time entry operations.

1 Like