> ## Documentation Index
> Fetch the complete documentation index at: https://kliio.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Time Entry

> Logs a manual time entry against a project, optionally linked to a task.

### Headers

<ParamField header="Authorization" type="string" required>
  `Bearer YOUR_API_KEY`
</ParamField>

### Body

<ParamField body="project_id" type="string" required>
  UUID of the project. Must belong to your account.
</ParamField>

<ParamField body="hours" type="number" required>
  Hours worked. Must be greater than `0`.
</ParamField>

<ParamField body="date" type="string" required>
  Date of work in `YYYY-MM-DD` format.
</ParamField>

<ParamField body="task_id" type="string">
  Optional UUID of a task within the project to link this entry to.
</ParamField>

<ParamField body="description" type="string">
  Optional description of the work done.
</ParamField>

<ParamField body="hourly_rate" type="number">
  Hourly rate to apply. Useful for billing calculations.
</ParamField>

### Response

<ResponseField name="success" type="boolean">`true` on creation.</ResponseField>
<ResponseField name="data" type="object">The newly created time entry, including an embedded `project`.</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://kliio.app/api/v1/time-entries \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "project_id": "proj-uuid-...",
      "task_id": "task-uuid-...",
      "hours": 3,
      "date": "2025-03-20",
      "description": "Wireframing",
      "hourly_rate": 120
    }'
  ```

  ```js JavaScript theme={null}
  const res = await fetch('https://kliio.app/api/v1/time-entries', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      project_id: 'proj-uuid-...',
      task_id: 'task-uuid-...',
      hours: 3,
      date: '2025-03-20',
      description: 'Wireframing',
      hourly_rate: 120
    })
  })
  const { data } = await res.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "success": true,
    "data": {
      "id": "te-uuid-...",
      "hours": 3,
      "hourly_rate": 120,
      "date": "2025-03-20",
      "description": "Wireframing",
      "task_id": "task-uuid-...",
      "project": { "id": "proj-uuid-...", "name": "Acme Rebrand" },
      "created_at": "2025-03-20T18:00:00.000Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Validation failed",
    "details": { "hours": ["hours must be positive"] }
  }
  ```

  ```json 404 theme={null}
  {
    "error": "Project not found or access denied"
  }
  ```
</ResponseExample>
