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

# Query tasks

> Query the project's tasks. view='list' returns a cursor page of task list items (filter/sort/pagination); view='counts' returns totals grouped by group_by (status/priority/assignee_id/creator_id).



## OpenAPI

````yaml https://mcp.agent.writesonic.com/openapi.json post /api/v1/business/tasks/query
openapi: 3.1.0
info:
  title: hq-backend — Business API
  description: Public business tool endpoints (API-key auth).
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/business/tasks/query:
    post:
      tags:
        - business
      summary: Query tasks
      description: >-
        Query the project's tasks. view='list' returns a cursor page of task
        list items (filter/sort/pagination); view='counts' returns totals
        grouped by group_by (status/priority/assignee_id/creator_id).
      operationId: query_tasks_api_v1_business_tasks_query_post
      parameters:
        - name: x-project-id
          in: header
          required: true
          schema:
            type: string
            format: uuid
            description: Project ID for tenant scoping
            title: X-Project-Id
          description: Project ID for tenant scoping
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
                format: uuid
              - type: 'null'
            description: Overrides the key's workspace
            title: X-Workspace-Id
          description: Overrides the key's workspace
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: User API key
            title: X-Api-Key
          description: User API key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskQueryArgs'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/TaskQueryPage'
                  - $ref: '#/components/schemas/TaskCounts'
                title: Response Query Tasks Api V1 Business Tasks Query Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    TaskQueryArgs:
      properties:
        view:
          $ref: '#/components/schemas/TaskQueryView'
          description: >-
            'list' for a cursor page of task list items, 'counts' for grouped
            totals.
          default: list
        query:
          $ref: '#/components/schemas/TaskFilterQuery'
          description: Filter, sort, and pagination. `filter` is shared by both views.
        group_by:
          anyOf:
            - $ref: '#/components/schemas/TaskGroupByField'
            - type: 'null'
          description: >-
            Group field for view='counts'
            (status/priority/assignee_id/creator_id). Required for counts.
      type: object
      title: TaskQueryArgs
    TaskQueryPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/TaskListItem'
          type: array
          title: Items
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Cursor
        has_more:
          type: boolean
          title: Has More
        parents:
          items:
            $ref: '#/components/schemas/TaskListItem'
          type: array
          title: Parents
      type: object
      required:
        - items
        - has_more
      title: TaskQueryPage
      description: >-
        `items` plus, when `include_parents` is requested, the immediate parents
        of this

        page's items that are not already in `items`. Parents are page-local
        context, not

        part of the paginated sequence.
    TaskCounts:
      properties:
        group_by:
          $ref: '#/components/schemas/TaskGroupByField'
        total:
          type: integer
          title: Total
        counts:
          additionalProperties:
            type: integer
          type: object
          title: Counts
      type: object
      required:
        - group_by
        - total
        - counts
      title: TaskCounts
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskQueryView:
      type: string
      enum:
        - list
        - counts
      title: TaskQueryView
    TaskFilterQuery:
      properties:
        filter:
          anyOf:
            - $ref: '#/components/schemas/Condition'
            - $ref: '#/components/schemas/And'
            - $ref: '#/components/schemas/Or'
            - type: 'null'
          title: Filter
        sort:
          $ref: '#/components/schemas/SortSpec'
        pagination:
          $ref: '#/components/schemas/PageSpec'
        include_parents:
          type: boolean
          title: Include Parents
          description: >-
            Return the immediate parents of this page's items in the separate
            `parents` field, even when a parent does not match the filter.
            Parents that are themselves page items are not repeated. Pagination
            applies to matched tasks only.
          default: false
      additionalProperties: false
      type: object
      title: TaskFilterQuery
    TaskGroupByField:
      type: string
      enum:
        - status
        - priority
        - assignee_id
        - creator_id
        - page_id
      title: TaskGroupByField
    TaskListItem:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        project_id:
          type: string
          format: uuid
          title: Project Id
        identifier:
          type: string
          title: Identifier
        title:
          type: string
          title: Title
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        status:
          $ref: '#/components/schemas/TaskStatus'
        priority:
          $ref: '#/components/schemas/TaskPriority'
        creator_type:
          $ref: '#/components/schemas/ActorType'
        creator_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Creator Id
        assignee_type:
          $ref: '#/components/schemas/ActorType'
        assignee_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Assignee Id
        parent_task_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Task Id
        page_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Page Id
        schedule_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Schedule Id
        due_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Due Date
        sort_order:
          type: number
          title: Sort Order
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Started At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        comment_count:
          type: integer
          title: Comment Count
        last_comment_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Comment At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        label_ids:
          items:
            type: string
            format: uuid
          type: array
          title: Label Ids
        relation_ids:
          additionalProperties:
            additionalProperties:
              items:
                type: string
                format: uuid
              type: array
            propertyNames:
              $ref: '#/components/schemas/RelationDirection'
            type: object
          propertyNames:
            $ref: '#/components/schemas/TaskRelationType'
          type: object
          title: Relation Ids
        subtask_count:
          $ref: '#/components/schemas/SubtaskCount'
      type: object
      required:
        - id
        - project_id
        - identifier
        - title
        - description
        - status
        - priority
        - creator_type
        - creator_id
        - assignee_type
        - assignee_id
        - parent_task_id
        - page_id
        - schedule_id
        - due_date
        - sort_order
        - started_at
        - completed_at
        - comment_count
        - last_comment_at
        - created_at
        - updated_at
        - subtask_count
      title: TaskListItem
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    Condition:
      properties:
        field:
          $ref: '#/components/schemas/FilterField'
        op:
          $ref: '#/components/schemas/FilterOp'
        value:
          title: Value
          description: >-
            Comparison value(s): shape depends on `op` (scalar for most ops,
            [low, high] for between, non-empty list for in/not_in/has_*); scalar
            format depends on `field` (FILTER_FIELD_SPECS) - plain string for
            text, UUID string for id fields. due_date is date-only (YYYY-MM-DD;
            a full timestamp is rejected). created_at/completed_at are datetime
            (full ISO-8601, or bare YYYY-MM-DD defaulting to midnight).
      additionalProperties: false
      type: object
      required:
        - field
        - op
      title: Condition
    And:
      properties:
        and:
          items:
            anyOf:
              - $ref: '#/components/schemas/Condition'
              - $ref: '#/components/schemas/And'
              - $ref: '#/components/schemas/Or'
          type: array
          minItems: 1
          title: And
      additionalProperties: false
      type: object
      required:
        - and
      title: And
    Or:
      properties:
        or:
          items:
            anyOf:
              - $ref: '#/components/schemas/Condition'
              - $ref: '#/components/schemas/And'
              - $ref: '#/components/schemas/Or'
          type: array
          minItems: 1
          title: Or
      additionalProperties: false
      type: object
      required:
        - or
      title: Or
    SortSpec:
      properties:
        sort_by:
          $ref: '#/components/schemas/TaskSortField'
          default: created_at
        sort_order:
          $ref: '#/components/schemas/SortOrder'
          default: desc
      additionalProperties: false
      type: object
      title: SortSpec
    PageSpec:
      properties:
        cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Cursor
        page_size:
          type: integer
          maximum: 100
          minimum: 1
          title: Page Size
          default: 50
      additionalProperties: false
      type: object
      title: PageSpec
    TaskStatus:
      type: string
      enum:
        - backlog
        - todo
        - in_progress
        - pending_human_approval
        - in_review
        - done
        - cancelled
      title: TaskStatus
    TaskPriority:
      type: string
      enum:
        - urgent
        - high
        - medium
        - low
        - none
      title: TaskPriority
    ActorType:
      type: string
      enum:
        - human
        - ai_agent
        - system
      title: ActorType
    SubtaskCount:
      properties:
        total:
          type: integer
          title: Total
          default: 0
        completed:
          type: integer
          title: Completed
          default: 0
      type: object
      title: SubtaskCount
    FilterField:
      type: string
      enum:
        - id
        - status
        - priority
        - assignee_type
        - assignee_id
        - creator_type
        - creator_id
        - due_date
        - created_at
        - completed_at
        - parent_task_id
        - page_id
        - title
        - identifier
        - label
      title: FilterField
    FilterOp:
      type: string
      enum:
        - eq
        - neq
        - in
        - not_in
        - gt
        - gte
        - lt
        - lte
        - between
        - is_null
        - contains
        - has_any
        - has_all
        - has_none
      title: FilterOp
    TaskSortField:
      type: string
      enum:
        - created_at
        - updated_at
        - due_date
        - priority
        - sort_order
        - completed_at
      title: TaskSortField
    SortOrder:
      type: string
      enum:
        - asc
        - desc
      title: SortOrder

````