> ## 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.

# Create Task

> Create a new task

Create a new task. Optionally link it to an opportunity, property, or person as a reference.

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

<ParamField body="description" type="string">
  Task description (max 5,000 characters).
</ParamField>

<ParamField body="opportunity_id" type="string">
  Link to a CRM opportunity (numeric or UUID).
</ParamField>

<ParamField body="property_id" type="string">
  Link to a property (e.g., `prop_12345`).
</ParamField>

<ParamField body="person_id" type="string">
  Link to a person (e.g., `per_67890`).
</ParamField>

<ParamField body="assigned_to_user_id" type="integer">
  User ID to assign the task to.
</ParamField>

<ParamField body="due_date" type="string">
  Due date in ISO 8601 format.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.v2.dealmachine.com/v1/tasks" \
    -H "Authorization: Bearer dm_sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "title": "Schedule property walkthrough",
      "description": "Contact seller to arrange a visit",
      "property_id": "prop_12345",
      "assigned_to_user_id": 12,
      "due_date": "2026-03-10T00:00:00Z"
    }'
  ```

  ```bash cURL — with opportunity theme={null}
  curl -X POST "https://api.v2.dealmachine.com/v1/tasks" \
    -H "Authorization: Bearer dm_sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "title": "Run comps analysis",
      "opportunity_id": "42",
      "property_id": "prop_12345",
      "due_date": "2026-03-15T00:00:00Z"
    }'
  ```

  ```typescript Node.js theme={null}
  const response = await fetch("https://api.v2.dealmachine.com/v1/tasks", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      title: "Schedule property walkthrough",
      property_id: "prop_12345",
      person_id: "per_67890",
      assigned_to_user_id: 12,
      due_date: "2026-03-10T00:00:00Z",
    }),
  });

  const { data } = await response.json();
  console.log(`Created task: ${data.title}`);
  ```

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

  response = requests.post(
      "https://api.v2.dealmachine.com/v1/tasks",
      headers={"Authorization": f"Bearer {api_key}"},
      json={
          "title": "Schedule property walkthrough",
          "property_id": "prop_12345",
          "assigned_to_user_id": 12,
          "due_date": "2026-03-10T00:00:00Z",
      },
  )

  print(response.json()["data"]["title"])
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "data": {
      "id": "task_003",
      "organization_id": 1,
      "opportunity_id": null,
      "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": null,
      "is_completed": false,
      "completed_at": null,
      "completed_by_user_id": null,
      "due_date": "2026-03-10T00:00:00Z",
      "sort_order": 0,
      "created_at": "2026-03-05T09:00:00Z",
      "updated_at": "2026-03-05T09:00:00Z"
    }
  }
  ```

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