# Log Work

> Record time spent on a LemuTickets ticket

URL: https://docs.lemuai.com/tickets-api/tickets/log-work

Records time someone spent on a ticket. Logged time adds up in the ticket's `time_spent_minutes` and appears in reports, separately from how long the ticket was open.

**Endpoint:** `POST /v1/tickets/{ref}/worklogs`

Use a key with the `tickets.write` scope.

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `ref` | string | Yes | The ticket key (`SUP-1042`) or id. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `minutes` | integer | Yes | Time spent, `1` to `1440` (24 hours). |
| `started_at` | string (date-time) | No | When the work started. Defaults to now. |
| `note` | string | No | What was done. |
| `billable` | boolean | No | Whether the time can be billed to the customer. Default `false`. |
| `user_id` | string (UUID) | No | The team member who did the work. Defaults to the caller: for an API key, the key's own user. Required with a client credentials token. |

**Example request:**
```bash
curl -X POST https://api.tickets.lemuai.com/v1/tickets/SUP-1042/worklogs \
  -H "Authorization: Bearer ltk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "minutes": 45,
    "started_at": "2026-11-25T08:30:00+05:30",
    "note": "Checked the payment gateway logs and raised the refund.",
    "billable": false,
    "user_id": "0e2a4c6b-8d1f-4a3e-9b5c-7d9f1a3c5e7b"
  }'
```

This endpoint does not use idempotency keys. If you retry after a timeout, check the ticket's `time_spent_minutes` first so the time is not logged twice.

## Response

**`201`**
```json
{
  "id": "b3d5f7a9-c1e2-4b6d-8f0a-2c4e6a8b0d2f",
  "minutes": 45,
  "total_minutes": 105
}
```

| Field | Type | Description |
|---|---|---|
| `id` | string | The worklog's id. |
| `minutes` | integer | The minutes logged by this request. |
| `total_minutes` | integer | All time logged on the ticket so far. |

This fires the `worklog.created` [webhook](https://docs.lemuai.com/tickets-api/webhooks).

## Errors

| Status | `code` | When |
|---|---|---|
| `404` | `ticket_not_found` | No ticket with this key or id, or you cannot see it |
| `422` | `invalid_fields` | `minutes` is missing or not between `1` and `1440` |
| `422` | `missing_user` | The caller is not a user and no `user_id` was sent |
