> For the complete documentation index, see [llms.txt](https://docs.autentique.com.br/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autentique.com.br/api/mutations/criando-pastas/sharing-a-folder.md).

# Sharing a folder

Use `shareFolder` to share a folder with users or groups. Each share can grant either view or edit permissions.

```graphql
mutation ShareFolder(
  $folderId: String!
  $shares: [ShareFolderInput]
  $emailMessage: String
) {
  shareFolder(
    folder_id: $folderId
    shares: $shares
    email_message: $emailMessage
  ) {
    id
    name
    shares {
      id
      role
      is_by_link
      user {
        id
        name
        email
      }
      group {
        id
        name
      }
    }
  }
}
```

Variables to share wih a group or user:

```json
{
  "folderId": "FOLDER_ID",
  "shares": [
    {
      "email": "user@exemple.com",
      "role": "VIEWER"
    },
    {
      "group_id": "abc123",
      "role": "EDITOR"
    }
  ],
  "emailMessage": "Now I'm sharing this folder with you!"
}
```

To share with a group, provide the `group_id`  instead of `email.`

The available values for `role` are:

<table><thead><tr><th width="194.8359375">Value</th><th>Permission</th></tr></thead><tbody><tr><td><code>VIEWER</code></td><td>Allows the user or group to view the folder’s contents. This is the default value.</td></tr><tr><td><code>EDITOR</code></td><td>Allows the user or group to edit and manage the folder’s contents.</td></tr></tbody></table>

### Updating a share

Use `updateSharing` to modify an already existing permission or configure link sharing.

```graphql
mutation UpdateFolderSharing(
  $folderId: String!
  $sharingId: String
  $role: FolderRoleEnum
  $shareByLink: Boolean
  $password: String
  $removePassword: Boolean
) {
  updateSharing(
    folder_id: $folderId
    sharing_id: $sharingId
    role: $role
    share_by_link: $shareByLink
    password: $password
    remove_password: $removePassword
  ) {
    id
    name
    link_identifier
    has_password
    shares {
      id
      role
      is_by_link
    }
  }
}
```

Variables to change a permission:

```json
{
  "folderId": "FOLDER_ID",
  "sharingId": "SHARING_ID",
  "role": "EDITOR"
}
```

Variables to activate sharing with link and password:

```json
{
  "folderId": "FOLDER_ID",
  "shareByLink": true,
  "password": "PASSWORD_LINK"
}
```

To remove the password, set `removePassword` to `true` . Do not provide `password` and `removePassword` at the same request, as they represent conflicting actions.
