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

# Task Count by Categories

> Returns the number of tasks in each category (service type), sorted by count descending. Tasks with no category are grouped under "No Category". All filter fields are optional and supplied at the top level; an empty body ({}) returns counts across all categories. The underlying route requires the CAN_VIEW_REPORTING permission — the API key acts as its default user.

Returns task counts grouped by category (service type), sorted by count descending. Tasks with no category are grouped under `No Category`. Filters are optional and supplied at the top level; an empty body (`{}`) returns all categories. Requires the `CAN_VIEW_REPORTING` permission (inherited from the key's default user).


## OpenAPI

````yaml POST /api/v1/ops/reports/tasks/count-by-categories
openapi: 3.1.0
info:
  title: Xenia Team API - Task Count by Categories
  description: Returns task counts grouped by category (service type) for the workspace.
  version: 1.0.0
servers:
  - url: https://api.xenia.team
security: []
paths:
  /api/v1/ops/reports/tasks/count-by-categories:
    post:
      tags:
        - Reporting
      summary: Task Count by Categories
      description: >-
        Returns the number of tasks in each category (service type), sorted by
        count descending. Tasks with no category are grouped under "No
        Category". All filter fields are optional and supplied at the top level;
        an empty body ({}) returns counts across all categories. The underlying
        route requires the CAN_VIEW_REPORTING permission — the API key acts as
        its default user.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                fromDate:
                  type: string
                  format: date-time
                toDate:
                  type: string
                  format: date-time
                taskStatuses:
                  type: array
                  items:
                    type: string
                locations:
                  type: array
                  items:
                    type: string
                    format: uuid
                priorities:
                  type: array
                  items:
                    type: string
                categories:
                  type: array
                  items:
                    type: string
                    format: uuid
                  description: Category (ServiceType) UUIDs to include.
            example:
              taskStatuses:
                - Completed
      responses:
        '200':
          description: Task counts by category retrieved successfully.
          content:
            application/json:
              example:
                data:
                  - id: 7c1e2f34-56ab-4cd7-8e90-123456789abc
                    category: Cleaning
                    color: '#B3E5FC'
                    count: 128
                  - id: NoCategory
                    category: No Category
                    color: null
                    count: 22
                meta: {}
        '401':
          description: >-
            Unauthorized - Invalid client credentials, or client does not belong
            to this workspace.
        '403':
          description: 'Forbidden: API key not authorized for this route.'
        '500':
          description: Internal Server Error.
      security:
        - clientKey: []
          clientSecret: []
components:
  securitySchemes:
    clientKey:
      type: apiKey
      in: header
      name: x-client-key
    clientSecret:
      type: apiKey
      in: header
      name: x-client-secret

````