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

# Count employees matching stat totals

> Counts employees matching the supplied date range, stat selection, employee filter, search text, and conditions on stat totals. Employees with no data count when their zero totals satisfy the conditions. The count is independent of pagination. Viewing stats for all employees requires workspace-wide analytics access. Other callers can read their own stats and those of their direct and indirect reports, plus employees covered by delegated reporting access. Employee filters only narrow that access.



## OpenAPI

````yaml https://api.gowindmill.com/api/v2/openapi.json post /c/{companyId}/stats/employees/count
openapi: 3.1.0
info:
  title: Windmill API
  version: 2.0.0
  description: >-
    Use the Windmill API to integrate your systems, automate workflows, and
    build applications on your organization's data. Authenticate with an API key
    or OAuth access token. Each request uses the authenticated user's
    permissions within the selected workspace.
servers:
  - url: https://api.gowindmill.com/api/v2
security:
  - bearerAuth: []
paths:
  /c/{companyId}/stats/employees/count:
    post:
      tags:
        - Stats
      summary: Count employees matching stat totals
      description: >-
        Counts employees matching the supplied date range, stat selection,
        employee filter, search text, and conditions on stat totals. Employees
        with no data count when their zero totals satisfy the conditions. The
        count is independent of pagination. Viewing stats for all employees
        requires workspace-wide analytics access. Other callers can read their
        own stats and those of their direct and indirect reports, plus employees
        covered by delegated reporting access. Employee filters only narrow that
        access.
      operationId: stats.employees.count
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 128
            description: >-
              Company ID. A URL slug is also accepted. The caller must have
              access to this company.
            title: Company ID
            example: company-acme
          required: true
          description: >-
            Company ID. A URL slug is also accepted. The caller must have access
            to this company.
          name: companyId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CountEmployeeStatTotalsRequest'
      responses:
        '200':
          description: Number of matching employees
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CountResponse'
        '400':
          description: Bad request or request validation failed
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - BAD_REQUEST
                          message:
                            type: string
                          requestId:
                            type: string
                        required:
                          - code
                          - message
                          - requestId
                    required:
                      - error
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - VALIDATION_ERROR
                          message:
                            type: string
                          requestId:
                            type: string
                          details:
                            type: array
                            items:
                              type: object
                              properties:
                                path:
                                  type: array
                                  items:
                                    anyOf:
                                      - type: string
                                      - type: number
                                message:
                                  type: string
                              required:
                                - path
                                - message
                        required:
                          - code
                          - message
                          - requestId
                          - details
                    required:
                      - error
        '401':
          description: >-
            Authentication is missing or invalid. Send a valid API key or OAuth
            access token in the Authorization: Bearer <TOKEN> header before
            retrying.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - UNAUTHORIZED
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - FORBIDDEN
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - NOT_FOUND
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '429':
          description: >-
            The API-client request budget is exhausted. API keys allow 500
            requests per minute per key; OAuth clients allow 500 per minute per
            client and workspace. Reads and writes share the budget. One HTTP
            request counts once, including bulk requests. Wait for the
            Retry-After delay before retrying.
          headers:
            Retry-After:
              description: Number of seconds to wait before retrying the request.
              required: true
              schema:
                type: integer
                minimum: 0
                example: 42
            RateLimit:
              description: >-
                Current request budget: limit is the maximum count, remaining is
                the unused count, and reset is seconds until the window resets,
                not a timestamp.
              required: true
              schema:
                type: string
                example: limit=500, remaining=0, reset=42
            RateLimit-Policy:
              description: >-
                Request limit and window length in seconds, formatted as
                <limit>;w=<seconds>.
              required: true
              schema:
                type: string
                example: 500;w=60
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - RATE_LIMITED
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
      security:
        - bearerAuth: []
components:
  schemas:
    CountEmployeeStatTotalsRequest:
      type: object
      properties:
        dateRange:
          anyOf:
            - type: object
              properties:
                range:
                  type: string
              required:
                - range
            - type: object
              properties:
                from:
                  type: string
                to:
                  type: string
              required:
                - from
                - to
        timezone:
          type: string
          description: >-
            IANA timezone used to resolve the date range (e.g.
            "America/New_York"). Defaults to UTC.
          title: Timezone
          example: America/New_York
        statTypes:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
            pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
            description: >-
              Kebab-case identifier of a global Windmill stat or a workspace
              custom stat. Discover identifiers with POST
              /c/{companyId}/stats/metadata/search.
            title: Stat identifier
            example: code-prs-merged
          minItems: 1
          maxItems: 50
          description: >-
            Stat identifiers to total, global or workspace custom. Each row
            returns its stats in this order. Unknown identifiers total 0.
          title: Stat identifiers
          example:
            - code-prs-merged
        employee:
          type: object
          properties:
            hasDirectReports:
              type:
                - boolean
                - 'null'
            hasManager:
              type:
                - boolean
                - 'null'
            employeeGroupId:
              type:
                - string
                - 'null'
            employeeGroupIds:
              type:
                - array
                - 'null'
              items:
                type: string
            employeeGroupIdSets:
              type:
                - array
                - 'null'
              items:
                type: array
                items:
                  type: string
                minItems: 1
            jobTitle:
              type:
                - string
                - 'null'
            jobTitles:
              type:
                - array
                - 'null'
              items:
                type: string
            countries:
              type:
                - array
                - 'null'
              items:
                type: string
            emails:
              type:
                - array
                - 'null'
              items:
                type: string
            emailDomains:
              type:
                - array
                - 'null'
              items:
                type: string
            employeeId:
              type:
                - string
                - 'null'
            employeeIds:
              type:
                - array
                - 'null'
              items:
                type: string
            excludedEmployeeId:
              type:
                - string
                - 'null'
            excludedEmployeeIds:
              type:
                - array
                - 'null'
              items:
                type: string
            managerId:
              type:
                - string
                - 'null'
            managerIds:
              type:
                - array
                - 'null'
              items:
                type: string
            ancestorManagerId:
              type:
                - string
                - 'null'
            ancestorManagerIds:
              type:
                - array
                - 'null'
              items:
                type: string
            indirectManagerId:
              type:
                - string
                - 'null'
            indirectManagerIds:
              type:
                - array
                - 'null'
              items:
                type: string
            isMember:
              type:
                - boolean
                - 'null'
            memberRole:
              type:
                - string
                - 'null'
              enum:
                - admin
                - hr-admin
                - integration-manager
                - data-analyst
                - team-member
                - null
            query:
              type:
                - string
                - 'null'
            includeArchived:
              type:
                - boolean
                - 'null'
            onlyArchived:
              type:
                - boolean
                - 'null'
            includeExternalOrgs:
              type:
                - boolean
                - 'null'
            platformAccess:
              type:
                - string
                - 'null'
              enum:
                - HAS_ACCESS
                - INVITE_PENDING
                - NO_ACCESS
                - null
            startDate:
              anyOf:
                - type: object
                  properties:
                    range:
                      type: string
                  required:
                    - range
                - type: object
                  properties:
                    from:
                      type: string
                    to:
                      type: string
                  required:
                    - from
                    - to
                - type: 'null'
            isAccountAdmin:
              type:
                - boolean
                - 'null'
            hasIntegrationIds:
              type:
                - array
                - 'null'
              items:
                type: string
            lacksIntegrationIds:
              type:
                - array
                - 'null'
              items:
                type: string
            and:
              type: array
              items:
                $ref: '#/components/schemas/CoreEmployeeFilter'
            or:
              type: array
              items:
                $ref: '#/components/schemas/CoreEmployeeFilter'
          description: >-
            Limits which employees are returned within the set the caller can
            access. This filter never grants access to more employees.
          title: Employee filter
          example:
            query: Avery
        search:
          type: string
          maxLength: 200
          description: >-
            Text that matches the employee name, preferred name, or email
            username.
          title: Employee search text
          example: Avery
        where:
          type: array
          items:
            type: object
            properties:
              stat:
                type: string
                minLength: 1
                maxLength: 100
                pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
                description: Stat to compare. It must be one of statTypes.
                title: Stat identifier
                example: code-prs-merged
              operator:
                type: string
                enum:
                  - lt
                  - lte
                  - eq
                  - gt
                  - gte
                description: Numeric comparison to apply to the range value.
                title: Comparison operator
                example: gte
              value:
                type: number
                description: Value to compare the stat total with.
                title: Comparison value
                example: 1
            required:
              - stat
              - operator
              - value
          maxItems: 10
          description: >-
            Conditions on stat totals. An employee matches only when every
            condition is true. Each condition compares the value that a row
            returns: the weighted average for AVERAGE stats, and 0 for an
            employee with no data.
          title: Stat total conditions
          example:
            - stat: code-prs-merged
              operator: gte
              value: 1
      required:
        - dateRange
        - statTypes
      additionalProperties: false
      title: Employee stat totals count request
      example:
        dateRange:
          from: '2026-01-01'
          to: '2026-01-31'
        statTypes:
          - code-prs-merged
        where:
          - stat: code-prs-merged
            operator: gte
            value: 1
    CountResponse:
      type: object
      properties:
        total:
          type: integer
          minimum: 0
          description: >-
            Total matching items, independent of pagination. The route
            determines the item type.
          title: Total matches
          example: 1
      required:
        - total
    CoreEmployeeFilter:
      type: object
      properties:
        hasDirectReports:
          type:
            - boolean
            - 'null'
        hasManager:
          type:
            - boolean
            - 'null'
        employeeGroupId:
          type:
            - string
            - 'null'
        employeeGroupIds:
          type:
            - array
            - 'null'
          items:
            type: string
        employeeGroupIdSets:
          type:
            - array
            - 'null'
          items:
            type: array
            items:
              type: string
            minItems: 1
        jobTitle:
          type:
            - string
            - 'null'
        jobTitles:
          type:
            - array
            - 'null'
          items:
            type: string
        countries:
          type:
            - array
            - 'null'
          items:
            type: string
        emails:
          type:
            - array
            - 'null'
          items:
            type: string
        emailDomains:
          type:
            - array
            - 'null'
          items:
            type: string
        employeeId:
          type:
            - string
            - 'null'
        employeeIds:
          type:
            - array
            - 'null'
          items:
            type: string
        excludedEmployeeId:
          type:
            - string
            - 'null'
        excludedEmployeeIds:
          type:
            - array
            - 'null'
          items:
            type: string
        managerId:
          type:
            - string
            - 'null'
        managerIds:
          type:
            - array
            - 'null'
          items:
            type: string
        ancestorManagerId:
          type:
            - string
            - 'null'
        ancestorManagerIds:
          type:
            - array
            - 'null'
          items:
            type: string
        indirectManagerId:
          type:
            - string
            - 'null'
        indirectManagerIds:
          type:
            - array
            - 'null'
          items:
            type: string
        isMember:
          type:
            - boolean
            - 'null'
        memberRole:
          type:
            - string
            - 'null'
          enum:
            - admin
            - hr-admin
            - integration-manager
            - data-analyst
            - team-member
            - null
        query:
          type:
            - string
            - 'null'
        includeArchived:
          type:
            - boolean
            - 'null'
        onlyArchived:
          type:
            - boolean
            - 'null'
        includeExternalOrgs:
          type:
            - boolean
            - 'null'
        platformAccess:
          type:
            - string
            - 'null'
          enum:
            - HAS_ACCESS
            - INVITE_PENDING
            - NO_ACCESS
            - null
        startDate:
          anyOf:
            - type: object
              properties:
                range:
                  type: string
              required:
                - range
            - type: object
              properties:
                from:
                  type: string
                to:
                  type: string
              required:
                - from
                - to
            - type: 'null'
        isAccountAdmin:
          type:
            - boolean
            - 'null'
        hasIntegrationIds:
          type:
            - array
            - 'null'
          items:
            type: string
        lacksIntegrationIds:
          type:
            - array
            - 'null'
          items:
            type: string
        and:
          type: array
          items:
            $ref: '#/components/schemas/CoreEmployeeFilter'
        or:
          type: array
          items:
            $ref: '#/components/schemas/CoreEmployeeFilter'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use an API key or OAuth access token. Enter only the token in the
        authorization dialog; requests send it as `Authorization: Bearer
        <TOKEN>`.


        Create an API key in your workspace's **Settings → API keys**. Keys
        start with `wm_api_` and only work in the workspace where they were
        created. Read-only keys can read data; creating, updating, or deleting
        data requires a read-write key.


        ```http

        Authorization: Bearer wm_api_example

        ```


        OAuth access tokens are issued for connected Windmill applications.


        ```http

        Authorization: Bearer <OAUTH_ACCESS_TOKEN>

        ```


        Both token types use the authenticated user's workspace permissions.
        Each endpoint's permission requirements and the sharing settings of the
        requested items still apply.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.