> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/RafaeltiMoreira/mais-habito-api/llms.txt
> Use this file to discover all available pages before exploring further.

# Update task

> Update the fields of an existing task owned by the authenticated user.

## Path parameters

<ParamField path="taskId" type="number" required>
  ID of the task to update.
</ParamField>

## Request body

All body fields are optional. Omitting a field leaves its current value unchanged. At least one field should be provided.

<ParamField body="title" type="string">
  New display name for the task.
</ParamField>

<ParamField body="description" type="string">
  New description. Pass an explicit `null` to clear an existing description.
</ParamField>

<ParamField body="points" type="number">
  Updated points value. Must be greater than zero.
</ParamField>

<ParamField body="is_daily_routine" type="boolean">
  Updated daily routine flag.
</ParamField>

## Response

**200 OK** — Returns the updated task object.

<ResponseField name="id" type="number" required>
  Unique identifier for the task.
</ResponseField>

<ResponseField name="user_id" type="string" required>
  UUID of the user who owns the task.
</ResponseField>

<ResponseField name="challenge_template_id" type="number | null" required>
  ID of the associated challenge template, or `null`.
</ResponseField>

<ResponseField name="title" type="string" required>
  Display name of the task.
</ResponseField>

<ResponseField name="description" type="string | null" required>
  Description, or `null`.
</ResponseField>

<ResponseField name="points" type="number" required>
  Points awarded per completion.
</ResponseField>

<ResponseField name="is_daily_routine" type="boolean" required>
  Whether the task is flagged as a daily routine.
</ResponseField>

<ResponseField name="created_at" type="string" required>
  ISO 8601 creation timestamp. Unchanged by this request.
</ResponseField>

<ResponseField name="updated_at" type="string" required>
  ISO 8601 timestamp set to the time of this update.
</ResponseField>

## Errors

| Status | Condition                                        |
| ------ | ------------------------------------------------ |
| `400`  | `points` is provided but is zero or negative.    |
| `400`  | The task exists but belongs to a different user. |
| `404`  | No task found with the given `taskId`.           |
| `401`  | Missing or invalid authentication token.         |

<RequestExample>
  ```bash cURL theme={null}
  curl --request PUT \
    --url http://localhost:3000/api/tasks/42 \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "title": "Meditate for 15 minutes",
      "points": 25
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 42,
    "user_id": "a3f1c2d4-0e5b-4a7f-b891-2c3d4e5f6a7b",
    "challenge_template_id": null,
    "title": "Meditate for 15 minutes",
    "description": "Morning meditation session",
    "points": 25,
    "is_daily_routine": true,
    "created_at": "2026-03-17T08:00:00.000Z",
    "updated_at": "2026-03-17T10:45:00.000Z"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "Task not found"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Points must be greater than zero"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "User not authenticated"
  }
  ```
</ResponseExample>
