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

# Retrieve workspace compliance statistics

> Get a compliance roll-up for a workspace: how many rules exist, and how many of their results are
passing, failing, pending, or due for renewal.

Counts respect the filters you pass, so `frameworkId` gives you a single framework's overall
compliance and `projectId` gives you a single project's.




## OpenAPI

````yaml get /workspaces/{workspaceId}/rule-stats
openapi: 3.0.3
info:
  contact:
    email: support@openlayer.com
    name: Openlayer
    url: https://openlayer.com/
  description: API for interacting with the Openlayer server.
  title: Openlayer API
  version: '1.0'
  x-logo:
    url: https://logo.clearbit.com/openlayer.com
servers:
  - url: https://api.openlayer.com/v1
    description: Our prod backend
security:
  - bearerAuth: []
paths:
  /workspaces/{workspaceId}/rule-stats:
    get:
      tags:
        - Governance
      summary: Retrieve workspace compliance statistics
      description: >
        Get a compliance roll-up for a workspace: how many rules exist, and how
        many of their results are

        passing, failing, pending, or due for renewal.


        Counts respect the filters you pass, so `frameworkId` gives you a single
        framework's overall

        compliance and `projectId` gives you a single project's.
      operationId: getWorkspaceRuleStats
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - $ref: '#/components/parameters/frameworkIdFilter'
        - $ref: '#/components/parameters/projectIdFilter'
      responses:
        '200':
          description: Status OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuleStatistic'
        default:
          $ref: '#/components/responses/UnexpectedError'
      x-codeSamples:
        - lang: curl
          source: |
            curl --request GET \
              --url 'https://api.openlayer.com/v1/workspaces/3fa85f64-5717-4562-b3fc-2c963f66afa6/rule-stats?frameworkId=9f1b3c2d-4e5a-4f60-8a71-2b3c4d5e6f70' \
              --header 'Authorization: Bearer <token>'
components:
  parameters:
    workspaceId:
      name: workspaceId
      in: path
      description: The workspace id.
      required: true
      schema:
        type: string
        format: uuid
    frameworkIdFilter:
      name: frameworkId
      in: query
      description: Only include items belonging to this framework.
      required: false
      schema:
        type: string
        format: uuid
    projectIdFilter:
      name: projectId
      in: query
      description: Only include items that apply to this project.
      required: false
      schema:
        type: string
        format: uuid
  schemas:
    RuleStatistic:
      type: object
      properties:
        rules:
          type: object
          description: Counts of the rules themselves, after any filters in the request.
          properties:
            total:
              type: integer
              minimum: 0
              description: The total number of rules.
            byType:
              type: object
              description: Rule counts by type.
              properties:
                platform:
                  type: integer
                  minimum: 0
                evidence:
                  type: integer
                  minimum: 0
            byScope:
              type: object
              description: Rule counts by scope.
              properties:
                project:
                  type: integer
                  minimum: 0
                workspace:
                  type: integer
                  minimum: 0
        ruleResults:
          description: >
            Counts of rule results, after any filters in the request, with
            breakdowns by the type and scope of the rule each result belongs to.
          allOf:
            - $ref: '#/components/schemas/RuleResultStatusCounts'
            - type: object
              properties:
                byRuleType:
                  type: object
                  properties:
                    platform:
                      $ref: '#/components/schemas/RuleResultStatusCounts'
                    evidence:
                      $ref: '#/components/schemas/RuleResultStatusCounts'
                byRuleScope:
                  type: object
                  properties:
                    project:
                      $ref: '#/components/schemas/RuleResultStatusCounts'
                    workspace:
                      $ref: '#/components/schemas/RuleResultStatusCounts'
      required:
        - rules
        - ruleResults
    RuleResultStatusCounts:
      type: object
      properties:
        total:
          type: integer
          minimum: 0
          description: The total number of rule results.
        totalPassing:
          type: integer
          minimum: 0
          description: The number of passing rule results.
        totalFailing:
          type: integer
          minimum: 0
          description: The number of failing rule results.
        totalSkipped:
          type: integer
          minimum: 0
          description: The number of skipped rule results.
        totalRunning:
          type: integer
          minimum: 0
          description: The number of rule results currently being evaluated.
        totalError:
          type: integer
          minimum: 0
          description: The number of rule results that errored during evaluation.
        totalPending:
          type: integer
          minimum: 0
          description: The number of rule results that have not been satisfied yet.
        totalDueSoon:
          type: integer
          minimum: 0
          description: The number of rule results whose evidence is about to expire.
      required:
        - total
        - totalPassing
        - totalFailing
        - totalSkipped
        - totalRunning
        - totalError
        - totalPending
        - totalDueSoon
  responses:
    UnexpectedError:
      description: Unexpected error.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - error
            properties:
              code:
                type: integer
                format: int32
              error:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your workspace API key. See [Find your API
        key](https://www.openlayer.com/docs/workspace-and-projects/find-your-api-key)
        for more information.

````