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

# Count Log Entries by Level

> Counts [log entries](https://docs.cognigy.com/ai/agents/test/logs) in a Project per log level (`fatal`, `error`, `warn`, `info`, `debug` — `trace` is not counted), using the same `userId`, `flowName` and `sessionId` filters as the tail endpoint, so a count can be rendered alongside a filtered tail without the two disagreeing. Note that on this endpoint all three are matched exactly.

Counting is deliberately bounded. Each level is counted up to a server-side ceiling, returned as `cap`; a level whose true total exceeds it comes back with `capped: true` and `count` equal to `cap`, meaning "at least this many" rather than an exact total. This keeps the endpoint predictable on Projects holding tens of millions of entries.

Requires the log entries v2 model, so the `x-cognigy-log-model-version: v2` header is mandatory unless the service has the v2 model enabled cluster-wide. Requests on the v1 model are rejected with a 400 rather than served a different-shaped count.




## OpenAPI

````yaml https://api-trial.cognigy.ai/logs/openapi/openapi-viewer.json get /v2.1/projects/{projectId}/logs/count
openapi: 3.0.0
info:
  title: Cognigy.AI REST-ful-API Reference
  version: 2026.19.0
  description: >

    ### Introduction

    This is the [OpenAPI 3.0](https://swagger.io/specification/) documentation
    of the
    [REST](https://en.wikipedia.org/wiki/Representational_state_transfer)-ful
    Cognigy.AI API.


    ### Cross-Origin Resource Sharing

    This API features Cross-Origin Resource Sharing (CORS) implemented in
    compliance with [W3C spec](https://www.w3.org/TR/cors/), which allows
    cross-domain communication from the browser. All responses include a
    wildcard same-origin header, making the API fully accessible.


    ### Authentication

    Cognigy.AI offers four forms of authentication:

    - API Key

    - CXone Token

    - OAuth2

    - BasicAuth


    An API Key is a security token. You can use API Keys in your path or HTTP
    header. Never expose your API Key and keep it safe and secure. Revoke the
    API Key if it got exposed or stolen.


    OAuth2 is an open protocol to allow secure authorization by web, mobile and
    desktop applications. For further information see [RFC 6749 - "The OAuth 2.0
    Authorization Framework"](https://tools.ietf.org/html/rfc6749) and [RFC 6750
    - "The OAuth 2.0 Authorization Framework: Bearer Token
    Usage"](https://tools.ietf.org/html/rfc6750).


    Basic Auth is only used for API calls regarding the Management-UI.


    ### Error Handling

    This API uses HTTP status codes equal or above 400 to indicate errors. Error
    details are generated in compliance with [RFC 7807 - "Problem Details for
    HTTP APIs"](https://tools.ietf.org/html/rfc7807).


    Every error response contains a traceId, which should be provided to the
    Cognigy.AI Technical Support when reporting an error.
  contact:
    name: Cognigy Technical Support
    url: https://www.cognigy.com
    email: support@cognigy.com
servers:
  - url: https://api-trial.cognigy.ai/new/
    description: Cognigy.AI API
security:
  - APIKeyHeader: []
  - APIKeyQueryParam: []
  - CXoneTokenHeader: []
  - OAuth2: []
  - BasicAuth: []
tags:
  - name: Cognigy.AI REST-ful API
    description: The Cognigy.AI REST-ful API
externalDocs:
  description: Cognigy.AI Documentation
  url: https://docs.cognigy.com/docs/
paths:
  /v2.1/projects/{projectId}/logs/count:
    get:
      tags:
        - Logs v2.1
      summary: Count Log Entries by Level
      description: >
        Counts [log entries](https://docs.cognigy.com/ai/agents/test/logs) in a
        Project per log level (`fatal`, `error`, `warn`, `info`, `debug` —
        `trace` is not counted), using the same `userId`, `flowName` and
        `sessionId` filters as the tail endpoint, so a count can be rendered
        alongside a filtered tail without the two disagreeing. Note that on this
        endpoint all three are matched exactly.


        Counting is deliberately bounded. Each level is counted up to a
        server-side ceiling, returned as `cap`; a level whose true total exceeds
        it comes back with `capped: true` and `count` equal to `cap`, meaning
        "at least this many" rather than an exact total. This keeps the endpoint
        predictable on Projects holding tens of millions of entries.


        Requires the log entries v2 model, so the `x-cognigy-log-model-version:
        v2` header is mandatory unless the service has the v2 model enabled
        cluster-wide. Requests on the v1 model are rejected with a 400 rather
        than served a different-shaped count.
      operationId: countTypeLogs_2_1
      parameters:
        - in: path
          name: projectId
          description: The unique identifier for the Project.
          required: true
          schema:
            type: string
            pattern: ^[a-z0-9]{24}$
            minLength: 24
            maxLength: 24
        - in: query
          name: userId
          required: false
          description: The ID of the user to filter log entries by.
          schema:
            type: string
        - in: query
          name: flowName
          required: false
          description: The name of the Flow to filter log entries by.
          schema:
            type: string
        - in: query
          name: sessionId
          required: false
          description: >
            The ID of the session to filter log entries by. Matched exactly and
            case-sensitively; a partial value returns no results.
          schema:
            type: string
            maxLength: 1024
        - in: query
          name: lastTimeWindow
          required: false
          description: >
            How many hours back the query should read, counted from now.
            Overrides the cluster's configured tail cutoff for this request
            only. Omit it to keep the configured cutoff, except on count: when
            the cutoff feature is off and this parameter is omitted, count
            substitutes a one-hour safety floor rather than scanning unbounded
            (tail may still be unbounded because it stops after one page). Every
            cluster accepts 1, 6 and 12, and each also accepts its own
            configured cutoff value (for example 24 on a cluster configured with
            a 24-hour cutoff); any other value is rejected with a 400 that lists
            the accepted set, which is why no enum is published here. Requires
            the log entries v2 model. Send it together with the
            `x-cognigy-log-model-version: v2` header, unless the service has the
            v2 model enabled cluster-wide, in which case the header is not
            needed; the 400 is returned only when the request would otherwise
            route to the v1 model.
          schema:
            type: integer
            minimum: 1
            example: 6
        - in: header
          name: x-cognigy-log-model-version
          required: false
          schema:
            type: string
            enum:
              - v1
              - v2
          description: Must be "v2" — countTypeLogs reads the V2 time-series collection.
      responses:
        '200':
          description: Returns the entry count for each log level.
          content:
            application/json:
              schema:
                type: object
                required:
                  - counts
                  - cap
                  - window
                properties:
                  counts:
                    type: object
                    description: >-
                      Exactly one entry for each counted level. `trace` is
                      deliberately omitted, even though untyped tail responses
                      may contain trace entries.
                    required:
                      - fatal
                      - error
                      - warn
                      - info
                      - debug
                    additionalProperties: false
                    properties:
                      fatal:
                        type: object
                        required:
                          - count
                          - capped
                        properties:
                          count:
                            type: integer
                            description: >-
                              Entries counted. A lower bound when `capped` is
                              true.
                            example: 0
                          capped:
                            type: boolean
                            description: >-
                              True when the level hit `cap` and the true total
                              is higher.
                            example: false
                      error:
                        type: object
                        required:
                          - count
                          - capped
                        properties:
                          count:
                            type: integer
                            description: >-
                              Entries counted. A lower bound when `capped` is
                              true.
                            example: 0
                          capped:
                            type: boolean
                            description: >-
                              True when the level hit `cap` and the true total
                              is higher.
                            example: false
                      warn:
                        type: object
                        required:
                          - count
                          - capped
                        properties:
                          count:
                            type: integer
                            description: >-
                              Entries counted. A lower bound when `capped` is
                              true.
                            example: 0
                          capped:
                            type: boolean
                            description: >-
                              True when the level hit `cap` and the true total
                              is higher.
                            example: false
                      info:
                        type: object
                        required:
                          - count
                          - capped
                        properties:
                          count:
                            type: integer
                            description: >-
                              Entries counted. A lower bound when `capped` is
                              true.
                            example: 0
                          capped:
                            type: boolean
                            description: >-
                              True when the level hit `cap` and the true total
                              is higher.
                            example: false
                      debug:
                        type: object
                        required:
                          - count
                          - capped
                        properties:
                          count:
                            type: integer
                            description: >-
                              Entries counted. A lower bound when `capped` is
                              true.
                            example: 0
                          capped:
                            type: boolean
                            description: >-
                              True when the level hit `cap` and the true total
                              is higher.
                            example: false
                  cap:
                    type: integer
                    description: The per-level ceiling applied to this request.
                    example: 50000
                  window:
                    type: object
                    description: The time window the counts cover.
                    required:
                      - hours
                      - from
                    properties:
                      hours:
                        type: integer
                        description: >-
                          Window size in hours. When the cutoff feature is
                          disabled and no override is supplied, count uses a
                          one-hour safety floor.
                        example: 6
                      from:
                        type: string
                        format: date-time
                        description: Oldest timestamp included.
        '400':
          description: >
            Bad request. Returned when `lastTimeWindow` is not one of the
            accepted values, or when the request is not on the v2 log entries
            model.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  code:
                    type: integer
                  type:
                    type: string
                  detail:
                    type: string
                    example: lastTimeWindow must be one of 1, 2, 6, 12
        '401':
          description: >-
            The request has not been applied because it lacks valid
            authentication credentials for the target resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Unauthorized
                  title:
                    type: string
                    example: Unauthorized Error
                  status:
                    type: number
                    example: 401
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 401
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '402':
          description: Upgrade your Plan to increase your Quota.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Payment Required
                  title:
                    type: string
                    example: Payment Required Error
                  status:
                    type: number
                    example: 402
                  detail:
                    type: string
                    example: Validation failed. Missing payload.
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 402
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '403':
          description: The server understood the request but refuses to authorize it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Forbidden
                  title:
                    type: string
                    example: Forbidden Error
                  status:
                    type: number
                    example: 403
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '404':
          description: >-
            The origin server did not find a current representation for the
            target resource or is not willing to disclose that one exists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Not Found
                  title:
                    type: string
                    example: Not Found Error
                  status:
                    type: number
                    example: 404
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
                  logLevel:
                    type: string
                    example: error
        '405':
          description: >-
            The method received in the request-line is known by the origin
            server but not supported by the target resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Method Not Allowed
                  title:
                    type: string
                    example: Method Not Allowed Error
                  status:
                    type: number
                    example: 405
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '409':
          description: The request conflicts with current state of the server.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Conflict
                  title:
                    type: string
                    example: Conflict Error
                  status:
                    type: number
                    example: 409
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1004
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '413':
          description: The request entity is larger than limits defined by server.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Payload Too Large
                  title:
                    type: string
                    example: Payload Too Large Error
                  status:
                    type: number
                    example: 413
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '429':
          description: >
            Too many requests. The log query rate limit for this project was
            exceeded. Count bills one token per counted level (currently five),
            so it exhausts the bucket faster than a tail of the same project.
            The response may include `Retry-After` sized to the tokens that were
            charged, not a single token.
        '500':
          description: >-
            The server encountered an unexpected condition that prevented it
            from fulfilling the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Internal Server Error
                  title:
                    type: string
                    example: Internal Server Error
                  status:
                    type: number
                    example: 500
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '501':
          description: >-
            The server does not support the functionality required to fulfill
            the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Not Implemented
                  title:
                    type: string
                    example: Not Implemented Error
                  status:
                    type: number
                    example: 501
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1009
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '502':
          description: >-
            The server, while acting as a gateway or proxy, received an invalid
            response from an inbound server it accessed while attempting to
            fulfill the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Bad Gateway
                  title:
                    type: string
                    example: Bad Gateway Error
                  status:
                    type: number
                    example: 502
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '503':
          description: The server is not ready to handle the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Service Unavailable
                  title:
                    type: string
                    example: Service Unavailable Error
                  status:
                    type: number
                    example: 503
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 503
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
        '504':
          description: >-
            The server, while acting as a gateway or proxy, did not receive a
            timely response from an upstream server it needed to access in order
            to complete the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: Gateway Timeout
                  title:
                    type: string
                    example: Gateway Timeout Error
                  status:
                    type: number
                    example: 504
                  detail:
                    type: string
                  instance:
                    type: string
                    example: /v2.0/flows/5ce7c2d833ea1e04d7e6c432
                  code:
                    type: string
                    example: 1000
                  traceId:
                    type: string
                    example: api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f
                  details:
                    type: object
                    example: {}
      security:
        - APIKeyHeader: []
        - APIKeyQueryParam: []
        - CXoneTokenHeader: []
        - OAuth2: []
components:
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: Supply the API Key in the HTTP-Header
    APIKeyQueryParam:
      type: apiKey
      in: query
      name: api_key
      description: Supply the API Key in the Url-Query
    CXoneTokenHeader:
      type: apiKey
      in: header
      name: x-cxone-authorization
      description: >-
        Supply the CXone Token in the HTTP-Header containing the word "Bearer"
        followed by a space and a Token String. Applicable only in CXone
        integrated environments.
    OAuth2:
      type: oauth2
      flows:
        password:
          tokenUrl: /auth/oauth2/token
          refreshUrl: /auth/oauth2/token
          scopes: {}
        authorizationCode:
          authorizationUrl: /auth/oauth2/authorize
          tokenUrl: /auth/oauth2/token
          scopes: {}
    BasicAuth:
      type: http
      scheme: basic
      description: Basic Authentication used by routes designed for the Management-UI.

````