> ## 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.

# Set stat view access

> Replaces all recipient grants on a saved view owned by the caller. Omitted audiences reset to no access, so include grants that should remain. Recipient access is read-only; the owner's write access is preserved. Employees and readable groups must belong to the workspace. A team grant may target only the owner's reporting team, and the owner must have a direct report. Changing workspace-wide or all-manager access, including removing it, requires permission to share analytics views workspace-wide. Supply expectedVersion for changes; a stale version returns 409. An identical sharing configuration returns the current version without incrementing it. Sharing with automations or by capability is unsupported. Requires access to Analytics in the workspace. Sharing a view shares its saved selections; each viewer can still read only the employee stats their own permissions allow.



## OpenAPI

````yaml https://api.gowindmill.com/api/v2/openapi.json put /c/{companyId}/stats/views/{id}/access
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/views/{id}/access:
    put:
      tags:
        - Stat views
      summary: Set stat view access
      description: >-
        Replaces all recipient grants on a saved view owned by the caller.
        Omitted audiences reset to no access, so include grants that should
        remain. Recipient access is read-only; the owner's write access is
        preserved. Employees and readable groups must belong to the workspace. A
        team grant may target only the owner's reporting team, and the owner
        must have a direct report. Changing workspace-wide or all-manager
        access, including removing it, requires permission to share analytics
        views workspace-wide. Supply expectedVersion for changes; a stale
        version returns 409. An identical sharing configuration returns the
        current version without incrementing it. Sharing with automations or by
        capability is unsupported. Requires access to Analytics in the
        workspace. Sharing a view shares its saved selections; each viewer can
        still read only the employee stats their own permissions allow.
      operationId: stats.views.access.set
      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
        - schema:
            type: string
            format: uuid
            description: UUID of an active saved stat view in this workspace.
            title: Stat view ID
            example: 22222222-2222-4222-8222-222222222222
          required: true
          description: UUID of an active saved stat view in this workspace.
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetStatViewAccessRequest'
      responses:
        '200':
          description: Updated stat view identity and version
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatViewMutationResponse'
        '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
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - CONFLICT
                      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
                            resourceId:
                              type: string
                          required:
                            - path
                            - message
                        description: >-
                          Request fields that caused the conflict, when the
                          operation identifies them. resourceId names the
                          existing resource that conflicts.
                    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:
    SetStatViewAccessRequest:
      type: object
      properties:
        expectedVersion:
          type: integer
          exclusiveMinimum: 0
          description: >-
            Version from the latest view response. A conflicting change returns
            409; reload the view and retry with its current version.
          title: Expected version
          example: 1
        employeeAccess:
          type: array
          items:
            type: object
            properties:
              employeeId:
                type: string
                minLength: 1
                description: >-
                  Employee ID in this workspace. For a subtree grant, identifies
                  its root employee.
                title: Employee ID
                example: employee-avery
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: >-
                  Use read to grant access or none for no grant. Write is
                  rejected for recipients.
                title: Access level
                example: read
            required:
              - employeeId
              - access
          maxItems: 250
          default: []
          description: >-
            Direct employee grants, at most 250. Omitted or empty clears
            existing grants.
          title: Employee access
          example:
            - employeeId: employee-avery
              access: read
        groupAccess:
          type: array
          items:
            type: object
            properties:
              groupId:
                type: string
                minLength: 1
                description: >-
                  ID of an employee group in this workspace that the caller can
                  read.
                title: Group ID
                example: group-engineering
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: >-
                  Use read to grant access or none for no grant. Write is
                  rejected for recipients.
                title: Access level
                example: read
            required:
              - groupId
              - access
          maxItems: 250
          default: []
          description: Group grants, at most 250. Omitted or empty clears existing grants.
          title: Group access
          example: []
        subtreeAccess:
          type: array
          items:
            type: object
            properties:
              employeeId:
                type: string
                minLength: 1
                description: >-
                  Employee ID in this workspace. For a subtree grant, identifies
                  its root employee.
                title: Employee ID
                example: employee-avery
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: >-
                  Use read to grant access or none for no grant. Write is
                  rejected for recipients.
                title: Access level
                example: read
            required:
              - employeeId
              - access
          maxItems: 1
          default: []
          description: >-
            At most one read grant for the owner's reporting team, rooted at the
            owner's employee ID. The owner must have a direct report. Omit to
            clear the team grant.
          title: Owner's reporting team access
          example: []
        allManagersAccess:
          type: string
          enum:
            - none
            - read
            - write
          default: none
          description: >-
            Read access for all managers. Defaults to none. Changing or removing
            this access requires permission to share analytics views
            workspace-wide.
          title: All managers access
          example: none
        companyAccess:
          type: string
          enum:
            - none
            - read
            - write
          default: none
          description: >-
            Read access for the whole workspace. Defaults to none. Changing or
            removing this access requires permission to share analytics views
            workspace-wide.
          title: Workspace access
          example: none
        automationAccess:
          type: array
          items:
            type: object
            properties:
              companyAutomationId:
                type: string
                minLength: 1
                description: >-
                  Workspace automation ID. Automation sharing is not supported
                  for stat views.
                title: Automation ID
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: >-
                  Sharing level: none, read, or write. Only the owner can write
                  a stat view.
                title: Access level
                example: read
            required:
              - companyAutomationId
              - access
          maxItems: 0
          default: []
          description: Unsupported audience. Omit or supply an empty array.
          title: Automation access
          example: []
        capabilitiesAccess:
          type: array
          items:
            type: object
            properties:
              capability:
                type: string
                minLength: 1
                description: >-
                  Capability name. Capability-based sharing is not supported for
                  stat views.
                title: Capability
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: >-
                  Sharing level: none, read, or write. Only the owner can write
                  a stat view.
                title: Access level
                example: read
            required:
              - capability
              - access
          maxItems: 0
          default: []
          description: Unsupported audience. Omit or supply an empty array.
          title: Capability access
          example: []
      required:
        - expectedVersion
      additionalProperties: false
      title: Replace stat view sharing request
      description: >-
        Complete replacement of recipient grants, up to 32 KiB of JSON. Omitted
        audiences reset to no access. The owner's write access is always
        preserved.
      example:
        expectedVersion: 1
        employeeAccess:
          - employeeId: employee-avery
            access: read
    StatViewMutationResponse:
      type: object
      properties:
        view:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: UUID of the created or modified view.
              title: Stat view ID
              example: 22222222-2222-4222-8222-222222222222
            version:
              type: integer
              exclusiveMinimum: 0
              description: Version to use on the next update. Creation starts at 1.
              title: Version
              example: 1
          required:
            - id
            - version
          description: >-
            Saved view identity and current version. Fetch the view for its full
            configuration.
          title: Stat view
      required:
        - view
      title: Stat view mutation response
      example:
        view:
          id: 22222222-2222-4222-8222-222222222222
          version: 1
  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.