> ## Documentation Index
> Fetch the complete documentation index at: https://test-8ad8522e-feat-ai-sre.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Count facet value distribution

> Return the top N values for a facet field within a time range, sorted by occurrence count descending.

## Restrictions

| Aspect      | Value                                                        |
| ----------- | ------------------------------------------------------------ |
| Rate limits | **300 requests/minute**; **100 requests/second** per account |
| Permissions | None — any valid `app_key` can call this operation           |

## Usage

* Use `POST /rum/field/list` with `is_facet: true` to discover available `facet_key` values for each scope.
* The `scope` must be one of: `session`, `view`, `action`, `error`, `resource`, `long_task`, `vital`, `issue`, `sourcemap`.
* Pass `dql` to further filter events before counting. DQL syntax follows the RUM query language.
* Pass `sql` with a WHERE-clause only (no SELECT) for SQL-style filtering.
* Default limit is 100; maximum is 100.
* Time range is required (`start_time` / `end_time` in Unix epoch **milliseconds**). Maximum span is 31 days.


## OpenAPI

````yaml /api-reference/rum.openapi.en.json post /rum/facet/count
openapi: 3.1.0
info:
  description: >-
    Public HTTP API for the Flashduty incident management platform — incidents,
    notification templates, channels, schedules, monitors, RUM, and platform
    administration. Every operation is authenticated with an `app_key` query
    parameter issued from the Flashduty console under Account → APP Keys.
    Responses follow a uniform envelope: `{ request_id, data }` on success, `{
    request_id, error }` on failure.
  title: Flashduty Open API
  version: 1.0.0
servers:
  - description: Flashduty Open API
    url: https://api.flashcat.cloud
security:
  - AppKeyAuth: []
tags:
  - description: Manage Real User Monitoring (RUM) applications.
    name: RUM/Applications
  - description: Run RUM analytics queries over event data.
    name: RUM/Data query
  - description: Query and manage RUM error tracking issues and preset severity rules.
    name: RUM/Issues
  - description: >-
      Query RUM facet fields and their value distributions for building
      analytics filters.
    name: RUM/Facets
  - description: >-
      Manage and query RUM sourcemap files for browser, Android, and iOS error
      symbolication.
    name: RUM/Sourcemaps
  - description: Retrieve session replay metadata and recorded segments for RUM sessions.
    name: RUM/Session replay
  - description: >-
      Configure and inspect the rules that decide which RUM errors get ingested
      and stored for an application, including their edit history.
    name: RUM/Error ingestion rules
  - description: >-
      Manage per-application rules that assign a severity to matching front-end
      errors, plus their evaluation order and change history.
    name: RUM/Issue preset severity rules
  - description: Query the RUM resource record and current usage for the account.
    name: RUM/Resources
paths:
  /rum/facet/count:
    post:
      tags:
        - RUM/Facets
      summary: Count facet value distribution
      description: >-
        Return the top N values for a facet field within a time range, sorted by
        occurrence count descending.
      operationId: rum-read-facet-count
      requestBody:
        content:
          application/json:
            example:
              end_time: 1712707200000
              facet_key: error.type
              limit: 10
              scope: error
              start_time: 1712620800000
            schema:
              $ref: '#/components/schemas/RumFacetCountRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              example:
                data:
                  items:
                    - count: 1523
                      facet_value: TypeError
                    - count: 342
                      facet_value: ReferenceError
                    - count: 89
                      facet_value: SyntaxError
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/RumFacetCountResponse'
                    type: object
          description: Success
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    RumFacetCountRequest:
      description: Parameters for counting facet value distribution.
      properties:
        dql:
          description: RUM DQL filter expression applied before counting.
          type: string
        end_time:
          description: End of the time range, Unix epoch milliseconds. Maximum 31-day span.
          example: 1712707200000
          format: int64
          type: integer
        facet_key:
          description: >-
            Field key whose value distribution to count; must be a registered
            field of the given `scope`. List available fields via `POST
            /rum/field/list`.
          type: string
        facet_value:
          description: >-
            When set, filter events where `facet_key` equals this value before
            counting. Accepts string, number, or boolean.
        kind:
          description: >-
            Symbol kind, used only when `scope` is `sourcemap` and only
            meaningful for `android`/`harmony`: `mapping` (default) selects
            ProGuard/R8 mappings or ArkTS sourcemaps, `native` selects native
            .so symbols.
          enum:
            - mapping
            - native
          type: string
        limit:
          default: 100
          description: Maximum number of top values to return. Default 100, maximum 100.
          maximum: 100
          type: integer
        scope:
          description: |-
            RUM data scope to query. One of:

            | Value | Meaning |
            |---|---|
            | `session` | User sessions |
            | `view` | Page views |
            | `action` | User actions |
            | `error` | Error events |
            | `resource` | Resource loads |
            | `long_task` | Long tasks |
            | `vital` | Performance vitals (Web Vitals, etc.) |
            | `issue` | Aggregated error-tracking issues |
            | `sourcemap` | Sourcemap / symbol files |
          enum:
            - session
            - view
            - action
            - error
            - resource
            - long_task
            - vital
            - issue
            - sourcemap
          type: string
        sql:
          description: SQL WHERE clause (no SELECT) for additional filtering.
          type: string
        start_time:
          description: Start of the time range, Unix epoch milliseconds.
          example: 1712620800000
          format: int64
          type: integer
        type:
          description: >-
            Symbol-store platform, used only when `scope` is `sourcemap`.
            Defaults to `browser` when omitted; `web` and `javascript` are
            accepted aliases of `browser`.


            | Value | Store queried |

            |---|---|

            | `browser` / `web` / `javascript` | JavaScript sourcemaps
            (excluding HarmonyOS ArkTS and React Native rows) |

            | `android` | Android ProGuard/R8 mappings; with `kind=native`,
            Android NDK .so symbols |

            | `ios` | iOS dSYM symbols |

            | `miniprogram` | WeChat mini program sourcemaps |

            | `harmony` | HarmonyOS ArkTS sourcemaps; with `kind=native`,
            HarmonyOS .so symbols |

            | `flutter` | Flutter Dart AOT symbols |

            | `electron` | Electron Breakpad symbols |

            | `react-native` | React Native JS sourcemaps |
          enum:
            - browser
            - web
            - javascript
            - android
            - ios
            - miniprogram
            - harmony
            - flutter
            - electron
            - react-native
          type: string
      required:
        - scope
        - facet_key
        - start_time
        - end_time
      type: object
    SuccessEnvelope:
      description: >-
        Success response envelope. On every 2xx response, `request_id`
        identifies the call (also mirrored in the `Flashcat-Request-Id` header)
        and `data` holds the endpoint-specific payload. Failure responses use a
        different shape — see `ErrorResponse`.
      properties:
        data:
          description: Endpoint-specific payload. See each operation's 200 response schema.
        request_id:
          description: >-
            Unique ID for this request. Mirrored in the Flashcat-Request-Id
            response header. Include it when reporting issues.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          type: string
      required:
        - request_id
        - data
      type: object
    RumFacetCountResponse:
      description: Top N facet values sorted by count descending.
      properties:
        items:
          description: >-
            Facet values with their occurrence counts, sorted by count
            descending, capped at `limit` (max 100).
          items:
            $ref: '#/components/schemas/FacetCountItem'
          type: array
      required:
        - items
      type: object
    FacetCountItem:
      description: A facet value and its occurrence count.
      properties:
        count:
          description: Number of events with this facet value in the time range.
          example: 1523
          format: int64
          type: integer
        facet_value:
          description: The facet value. Type matches the field's `value_type`.
      required:
        - facet_value
        - count
      type: object
    ErrorResponse:
      description: Response envelope for errors. `error` is required; `data` is absent.
      properties:
        error:
          $ref: '#/components/schemas/DutyError'
        request_id:
          description: >-
            Unique trace ID of this request; include it when reporting issues so
            logs can be located.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          type: string
      required:
        - request_id
        - error
      type: object
    DutyError:
      description: >-
        Error payload inside the response envelope. Present only on non-2xx
        responses.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          description: >-
            Human-readable error message, localized by the caller's
            Accept-Language. May contain field names, IDs, or other context from
            the failing request.
          example: The specified parameter template_id is not valid.
          type: string
      required:
        - code
        - message
      type: object
    ErrorCode:
      description: >-
        Flashduty error code enum. Every failed API response sets `error.code`
        to one of these stable wire strings. HTTP status is informational — the
        authoritative signal is the enum value.


        | Code | HTTP | Meaning |

        |---|---|---|

        | `OK` | 200 | Reserved — not returned on real errors. |

        | `InvalidParameter` | 400 | A required parameter is missing or failed
        validation. |

        | `BadRequest` | 400 | Generic 400 used when no more specific code fits.
        |

        | `InvalidContentType` | 400 | The `Content-Type` header is not
        `application/json`. |

        | `ResourceNotFound` | 400 | The referenced resource does not exist.
        Note: returned as HTTP 400, not 404 (historical choice). |

        | `NoLicense` | 400 | The feature is license-gated and no active license
        was found. |

        | `ReferenceExist` | 400 | Deletion blocked — other entities still
        reference this resource. |

        | `Unauthorized` | 401 | `app_key` is missing, invalid, or expired. |

        | `BalanceNotEnough` | 402 | Billing-gated operation with insufficient
        account balance. |

        | `AccessDenied` | 403 | Authenticated but lacking the permission
        required for this operation. |

        | `RouteNotFound` | 404 | The request URL path is not a known route. |

        | `MethodNotAllowed` | 405 | The HTTP method is not allowed on this
        otherwise-known path. |

        | `UndonedOrderExist` | 409 | An outstanding billing order blocks this
        new one. Wait and retry. |

        | `RequestLocked` | 423 | Operation temporarily locked due to repeated
        failures. |

        | `EntityTooLarge` | 413 | Request body exceeds the configured max size.
        |

        | `RequestTooFrequently` | 429 | Rate limit hit — API-global,
        per-account, or per-integration. |

        | `RequestVerifyRequired` | 428 | Second-factor verification required
        but not supplied. |

        | `DangerousOperation` | 428 | High-risk operation requires MFA
        verification. |

        | `InternalError` | 500 | Unhandled server-side error. Include
        `request_id` in the bug report. |

        | `ServiceUnavailable` | 503 | A backend dependency is unavailable. Try
        again later. |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
      example: InvalidParameter
      type: string
      x-enumDescriptions:
        AccessDenied: Authenticated but lacking the permission required for this operation.
        BadRequest: Generic 400 used when no more specific code fits.
        BalanceNotEnough: Billing-gated operation with insufficient account balance.
        DangerousOperation: High-risk operation requires MFA verification.
        EntityTooLarge: Request body exceeds the configured max size.
        InternalError: Unhandled server-side error. Include `request_id` in the bug report.
        InvalidContentType: The `Content-Type` header is not `application/json`.
        InvalidParameter: A required parameter is missing or failed validation.
        MethodNotAllowed: The HTTP method is not allowed on this otherwise-known path.
        NoLicense: The feature is license-gated and no active license was found.
        OK: Reserved — not returned on real errors.
        ReferenceExist: Deletion blocked — other entities still reference this resource.
        RequestLocked: Operation temporarily locked due to repeated failures.
        RequestTooFrequently: Rate limit hit — API-global, per-account, or per-integration.
        RequestVerifyRequired: Second-factor verification required but not supplied.
        ResourceNotFound: >-
          The referenced resource does not exist. Note: returned as HTTP 400,
          not 404 (historical choice).
        RouteNotFound: The request URL path is not a known route.
        ServiceUnavailable: A backend dependency is unavailable. Try again later.
        Unauthorized: '`app_key` is missing, invalid, or expired.'
        UndonedOrderExist: An outstanding billing order blocks this new one. Wait and retry.
  responses:
    BadRequest:
      content:
        application/json:
          examples:
            missingParameter:
              value:
                error:
                  code: InvalidParameter
                  message: The specified parameter is not valid.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Invalid request — usually a missing or malformed parameter.
    Unauthorized:
      content:
        application/json:
          examples:
            missingAppKey:
              value:
                error:
                  code: Unauthorized
                  message: You are unauthorized.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Missing or invalid app_key.
    TooManyRequests:
      content:
        application/json:
          examples:
            rateLimited:
              value:
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: >-
        Rate limit hit. Either the global API limit, a per-account limit, or a
        per-integration limit.
    ServerError:
      content:
        application/json:
          examples:
            internal:
              value:
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Unexpected server-side error. Include the request_id when reporting.
  securitySchemes:
    AppKeyAuth:
      description: >-
        App key issued from the Flashduty console under Account → APP Keys.
        Required on every public API call. Keep it secret — it grants the same
        access as the owning account.
      in: query
      name: app_key
      type: apiKey

````