{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/teamyou-com/json-schema/teamyou-com-task-schema.json",
  "title": "Task",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/teamyou-com-openapi.json#/components/schemas/Task",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "key": {
      "type": "string",
      "readOnly": true,
      "pattern": "^TASK-[1-9][0-9]*$",
      "description": "The task's numbered key, e.g. `TASK-12`: unique within the owner's account, assigned when the task is created, never reused and never changed. Accepted wherever a request takes this task's id, in a path or a field, and resolved within your own account. The `id` is still what every reference stores and what a response echoes back."
    },
    "userId": {
      "type": "string"
    },
    "topicId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Deprecated and always null: topics hold knowledge, not tasks (tasks once linked to a topic are now in projects). It will be removed in a later version; group work with projectId."
    },
    "projectId": {
      "type": [
        "string",
        "null"
      ]
    },
    "position": {
      "type": [
        "string",
        "null"
      ]
    },
    "area": {
      "oneOf": [
        {
          "$ref": "#/$defs/TaskArea"
        },
        {
          "type": "null"
        }
      ],
      "description": "The task's one area: its project's when it is in a project (via project), otherwise its own (via direct). Null when it is in none. Present on the Tasks operations' bodies (list, get, create, update, start, complete)."
    },
    "title": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 10000,
      "description": "Markdown: what done looks like, the context and the links. Present only when the body is this one task (get, create, update, complete); a list, plan or other body omits it and carries hasDescription and descriptionExcerpt, so fetch the task to read it. Null when the task has none. Before changing it, keep the task’s updatedAt: a write must send it as baseUpdatedAt."
    },
    "hasDescription": {
      "type": "boolean",
      "description": "Whether the task has a description."
    },
    "descriptionExcerpt": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 200,
      "description": "The start of the description as plain text, Markdown removed, at most 200 characters and ending in … when cut. Null when there is no description or it holds no text."
    },
    "status": {
      "type": "string",
      "enum": [
        "todo",
        "in_progress",
        "done"
      ]
    },
    "startedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true,
      "description": "When the task entered `in_progress`, and null in any other status. Set by the server."
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true,
      "description": "When the task was finished: set when its status becomes `done`, kept while it stays done, and null in any other status, so reopening a task clears it and finishing it again sets a new time. Set by the server."
    },
    "isArchived": {
      "type": "boolean"
    },
    "dueDate": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "priority": {
      "type": "string",
      "enum": [
        "high",
        "medium",
        "low",
        "none"
      ]
    },
    "assigneeAgentId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The agent whose turn this task is (an agt_ id); null = the owner's."
    },
    "assignedByApiKeyId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The API key that made the current assignment, when an agent made it; null when a person did or the task is unassigned. Custody checks it against the assignee before telling it the step is its turn."
    },
    "templateStepKey": {
      "type": [
        "string",
        "null"
      ],
      "readOnly": true,
      "description": "The template step this task was created as (`ask`, `review`, ...), when its project came from a template; null otherwise. Server-written; no request accepts it. Stable across edits to the task's title."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdBy": {
      "oneOf": [
        {
          "$ref": "#/$defs/ProvenanceActor"
        },
        {
          "type": "null"
        }
      ],
      "description": "Who created it. Null when it was created before TeamYou recorded who did."
    },
    "lastEditedBy": {
      "oneOf": [
        {
          "$ref": "#/$defs/ProvenanceActor"
        },
        {
          "type": "null"
        }
      ],
      "description": "Who last changed it. Null when nobody has changed it since history was recorded. Compare with your own agentId to see whether someone else changed it since you last read it."
    },
    "lastEditedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When lastEditedBy changed it; null alongside it."
    }
  },
  "required": [
    "id",
    "key",
    "userId",
    "title",
    "hasDescription",
    "descriptionExcerpt",
    "status",
    "startedAt",
    "completedAt",
    "isArchived",
    "priority",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "ProvenanceActor": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "agent",
            "owner"
          ],
          "description": "agent: a connected agent, through its key. owner: the account’s person, in the TeamYou app."
        },
        "agentId": {
          "type": [
            "string",
            "null"
          ],
          "description": "The agent (an agt_ id). Null for a key with no registered agent. Absent for the owner."
        },
        "name": {
          "type": "string",
          "description": "The agent’s display name, or \"An agent\" when it has none. Absent for the owner."
        },
        "via": {
          "type": "string",
          "enum": [
            "api",
            "mcp"
          ],
          "description": "How the agent made the change: the REST API or an MCP connector. Absent for the owner, and on a document change in GET /history, which records no channel."
        }
      },
      "required": [
        "type"
      ]
    },
    "TaskArea": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "via": {
          "type": "string",
          "enum": [
            "direct",
            "project"
          ],
          "description": "direct: the task is filed in the area itself. project: the task is in a project, and this is the project’s area."
        }
      },
      "required": [
        "id",
        "name",
        "via"
      ]
    }
  }
}