# Time tracking

> How an AI agent logs finished work in Klarity, reads time entries, and how timers and unbilled time behave before an invoice is drafted.

Use this when the user says what they worked on, asks where their time went, or prepares to bill.

## Log time

`log_time` records finished work. Give one of:
- `started_at` and `ended_at`;
- `started_at` and `duration_minutes`;
- only `duration_minutes`, which ends the entry now.

Attach it to a `task_id` (the client and project come from the task) or, for work outside a task, to an `organization_id`. Add a short `description`. Entries are billable by default; pass `is_billable: false` for internal work. One entry can be at most 24 hours.

Example: "I spent 90 minutes on the Acme report this morning" becomes `list_tasks` with `search: "Acme report"`, then `log_time` with that `task_id`, `started_at: "2026-11-26T09:00"`, `duration_minutes: 90`.

## Read time

`list_time_entries` filters by `organization_id`, `task_id`, `user_id`, `is_billable`, and a `started_after` / `started_before` range. Use it for weekly reviews or to answer "how much did I work on X".

## Timers

There is no tool to start or stop a timer. A running timer shows as an entry without an end. Setting a task to `done` or `canceled` with `update_task` stops any timer running on it.

## Unbilled time

Billable, finished time is unbilled until an invoice covers it. `list_unbilled_time` lists it per client. See the `billing` guide.

## Pitfalls

- Times without an offset are wall time in the user's zone. Do not convert them to UTC yourself.
- Do not log time the user did not state. Confirm durations you inferred.
- Check for an existing entry in the same range before logging, so you do not double count.
