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

# Grant folder access

> Give users and user groups access to a folder, or change the permission of those who already have it, with the same rules as the app.

Gives users and user groups access to a folder, or changes the permission (`CanView`, `CanComment`, `FullAccess`) of those who already have it, with the same rules as the app. An API key acts for its workspace, so it can manage the access of any folder it can see.

Users are given by `userId`, as returned by the [list users](https://docs.claap.io/api-reference/endpoint/list_users.md) endpoint, or by `email`:

* Claap onboarding (demo) and support users are not returned by the list users endpoint, and their email fails like their `userId`: `User not found`.
* A user without a `permission` gets the strongest one for their role: `FullAccess` for members, `CanComment` for guests.
* Guests cannot get `FullAccess`. Without an active subscription, a user only gets that strongest permission. User groups take any permission on every plan.
* An email that is not an active workspace user, including a user who left, is invited to the workspace (as a guest, or as a member when its domain can join the workspace). Its `permission` follows the same rules for that role, and the entry fails when the role or plan does not allow it.
  * A person with a Claap account who was never in this workspace joins at once and gets the permission: `granted`.
  * Anyone else, a user who left included, gets a pending invite to the folder: `invited`. A pending invite stores a role, not a permission, so the person gets the strongest permission for that role once they join.
* At most 10 emails that get an invite per request without a paid subscription, 50 otherwise. Emails of active workspace users and invalid emails do not count. When the same email appears twice, only the first entry is applied.

Each user newly given access gets an invitation email, with the optional `message`, sent in the name of the person who created the API key. That person gets no email for their own access. A permission change sends nothing, and user groups are never notified.

Each entry gets its own `outcome`, so one entry that fails does not stop the others:

* `granted`: the user or user group was given access, including a Claap user of another workspace who joined at once.
* `updated`: the user or user group already had access, its permission was set.
* `invited`: a pending invite was created for an email that is not a workspace user yet.
* `failed`: the entry could not be applied, for instance the user or user group does not exist (a demo or support user included), the user is not active, a guest was given `FullAccess`, the permission is not available on the plan, or the email is not valid. `error` explains why.

API keys without access to private recordings cannot access folders whose `memberPermission` is `NoAccess`: they are reported as not found.


## OpenAPI

````yaml POST /v1/folders/{folderId}/access
openapi: 3.1.0
info:
  title: Claap API
  description: Development documentation
  version: 0.0.0
servers:
  - url: https://api.claap.io/
security:
  - ApiKey: []
paths:
  /v1/folders/{folderId}/access:
    post:
      description: >-
        Give users and user groups access to a folder, or change the permission
        of those who already have it, with the same rules as the app.
      operationId: postV1FoldersByFolderIdAccess
      parameters:
        - in: path
          name: folderId
          schema:
            type: string
            description: Folder identifier
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                users:
                  type: array
                  maxItems: 50
                  default: []
                  description: >-
                    Users to give access to. Each entry has exactly one of
                    `userId` or `email`.
                  items:
                    type: object
                    properties:
                      userId:
                        type: string
                        description: >-
                          User identifier, as the `id` returned by the list
                          users endpoint.
                      email:
                        type: string
                        description: >-
                          Email of the person. An active workspace user is
                          resolved by email; the email of a Claap onboarding
                          (demo) or support user fails with `User not found`, as
                          by `userId`. Another email, including one of a user
                          who left the workspace, is invited to the workspace
                          (as a guest, or as a member when its domain can join
                          the workspace): a person with a Claap account who was
                          never in this workspace joins at once and gets access
                          (`granted`), anyone else, a user who left included,
                          gets a pending invite to the folder (`invited`).
                      permission:
                        type: string
                        enum:
                          - CanView
                          - CanComment
                          - FullAccess
                        description: >-
                          Defaults to the strongest permission for the role:
                          `FullAccess` for members, `CanComment` for guests.
                          Guests cannot get `FullAccess`. Without an active
                          subscription only the default is accepted. For an
                          email that is not a workspace user yet, the rules
                          apply to the role it is invited with; a pending invite
                          stores a role, not a permission, so that person gets
                          the default once they join.
                userGroups:
                  type: array
                  maxItems: 50
                  default: []
                  description: >-
                    User groups to give access to. A group gives nothing to its
                    guests.
                  items:
                    type: object
                    properties:
                      userGroupId:
                        type: string
                        description: >-
                          User group identifier, as returned by the list user
                          groups endpoint.
                      permission:
                        type: string
                        enum:
                          - CanView
                          - CanComment
                          - FullAccess
                        description: >-
                          Permission of the members of the group on the folder.
                          Any permission is accepted on every plan.
                    required:
                      - userGroupId
                      - permission
                message:
                  type: string
                  description: Message included in the invitation emails.
      responses:
        '200':
          description: Access was processed, see the outcome of each entry
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      results:
                        type: array
                        description: >-
                          One outcome per entry, in the order users, user
                          groups, then emails for a revoke.
                        items:
                          $ref: '#/components/schemas/ApiAccessOutcome'
                    required:
                      - results
                required:
                  - result
        '400':
          description: >-
            The request is not valid. For instance a user entry has both or
            neither of `userId` and `email`, or a list has more than 50 entries.
        '403':
          description: >-
            Too many emails: at most 10 emails that get an invite per request
            without a paid subscription, 50 otherwise. Emails of active
            workspace users and invalid emails do not count.
        '404':
          description: >-
            Folder was not found. Note that API keys without access to private
            recordings cannot access folders whose `memberPermission` is
            `NoAccess`, which are reported as not found.
components:
  schemas:
    ApiAccessOutcome:
      type: object
      properties:
        userId:
          type: string
          description: Set when the entry resolved to a workspace user.
        email:
          type: string
          description: Email of the entry, when it has one.
        userGroupId:
          type: string
          description: Set for a user group entry.
        outcome:
          type: string
          enum:
            - granted
            - updated
            - invited
            - revoked
            - failed
          description: >-
            `granted` when access was added, `updated` when the permission of an
            existing access was set, `invited` when a pending invite was created
            for an email that is not a workspace user yet, `revoked` when access
            was removed, `failed` when this entry could not be applied.
        error:
          type: string
          description: Why the entry failed, set only when the outcome is `failed`.
      required:
        - outcome
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Claap-Key

````

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