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

# Update Task

> Update a task

Update a task's details. Set `is_completed` to `true` to mark a task as done — this automatically records the completion timestamp and the completing user. You can also update the linked opportunity, property, or person references.

<ParamField path="id" type="string" required>
  Task ID.
</ParamField>

<ParamField body="title" type="string">
  Task title (1-500 characters).
</ParamField>

<ParamField body="description" type="string | null">
  Task description (max 5,000 characters). Set to `null` to clear.
</ParamField>

<ParamField body="opportunity_id" type="string | null">
  Link to a CRM opportunity. Set to `null` to unlink.
</ParamField>

<ParamField body="property_id" type="string | null">
  Link to a property. Set to `null` to unlink.
</ParamField>

<ParamField body="person_id" type="string | null">
  Link to a person. Set to `null` to unlink.
</ParamField>

<ParamField body="assigned_to_user_id" type="integer | null">
  User ID to assign. Set to `null` to unassign.
</ParamField>

<ParamField body="is_completed" type="boolean">
  Set to `true` to complete, `false` to reopen.
</ParamField>

<ParamField body="due_date" type="string | null">
  Due date (ISO 8601). Set to `null` to clear.
</ParamField>

<ParamField body="sort_order" type="integer">
  Display order.
</ParamField>

<RequestExample>
  ```bash cURL — Complete a task theme={null}
  curl -X PATCH "https://api.v2.dealmachine.com/v1/tasks/task_001" \
    -H "Authorization: Bearer dm_sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{ "is_completed": true }'
  ```

  ```bash cURL — Link to property theme={null}
  curl -X PATCH "https://api.v2.dealmachine.com/v1/tasks/task_001" \
    -H "Authorization: Bearer dm_sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{ "property_id": "prop_12345" }'
  ```

  ```typescript Node.js theme={null}
  const response = await fetch(
    `https://api.v2.dealmachine.com/v1/tasks/${taskId}`,
    {
      method: "PATCH",
      headers: {
        Authorization: `Bearer ${apiKey}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ is_completed: true }),
    }
  );

  const { data } = await response.json();
  console.log(`Task "${data.title}" completed at ${data.completed_at}`);
  ```

  ```python Python theme={null}
  import requests

  response = requests.patch(
      f"https://api.v2.dealmachine.com/v1/tasks/{task_id}",
      headers={"Authorization": f"Bearer {api_key}"},
      json={"is_completed": True},
  )

  data = response.json()["data"]
  print(f"Task '{data['title']}' completed at {data['completed_at']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": {
      "id": "task_001",
      "organization_id": 1,
      "opportunity_id": "42",
      "property_id": "prop_12345",
      "person_id": null,
      "created_by_user_id": 5,
      "assigned_to_user_id": 12,
      "assigned_to_agent_id": null,
      "title": "Schedule property walkthrough",
      "description": "Contact seller to arrange a visit",
      "is_completed": true,
      "completed_at": "2026-03-05T10:30:00Z",
      "completed_by_user_id": 5,
      "due_date": "2026-03-10T00:00:00Z",
      "sort_order": 0,
      "created_at": "2026-03-01T09:00:00Z",
      "updated_at": "2026-03-05T10:30:00Z"
    }
  }
  ```

  ```json 404 theme={null}
  {
    "error": {
      "code": "task_not_found",
      "message": "Task not found"
    }
  }
  ```
</ResponseExample>
