# Record Share Command

### Overview

The following actions are supported by the share-record command

1. [grant](#share-record-share-command) - grants and changes permissions of a given record to given user.
2. [revoke](#share-record-revoke-command) - revoke current record share.
3. [transfer-ownership](#share-record-transfer-ownership-command) - transfers ownership to a given user.
4. [cancel](#share-cancel-command) - revoke all shares with user.

### Share Record - Share Command

This command can be used to grant access of a record to a user. The user can be given sharing and editing permissions. The access can be limited for a time duration or upto a specific date to be automatically revoked.

<details>

<summary>DotNet CLI</summary>

**Command**: `share-record`

**Action:**

* `share`  : Share a record with a user

**Flags**:

* **`-s, --share`** *(bool, optional)*
  * Allows the recipient to re-share the record with others.
  * Example: `--share true`
* **`-w, --write`** *(bool, optional)*
  * Allows the recipient to modify the record.
  * Example: `--write true`
* **`--expire-at`** *(string, optional)*
  * Sets a specific date/time when the share will expire.
  * Format: `YYYY-MM-DD HH:mm:SS` (ISO).
  * Example: c&#x20;
* **`--expire-in`** *(string, optional)*
  * Sets a relative expiration period for the share.
  * *Format*: `mi|h|d|mo|y`
    * `mi` = minutes
    * `h` = hours
    * `d` = days
    * `mo` = months
    * `y` = years
  * Example: `--expire-in 7d` (expires in 7 days)
* **`-e, --email`** *(string, required)*
  * Email address of the recipient (peer account).
  * Example: `--email user@example.com`
* **`record`** *(positional, required)*
  * Record path or UID to be shared.
  * Example: `MyPasswords/Bank` or `9xL2c6aBc1234`

**Example:**

```shell
My Vault> share-record share <uidaaabbcc11221uuuid> --write=true --share=true --expire-at "2025-09-30
 23:59:00" --email="user@email.com"
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
public async Task ShareRecordWithUser(
    string recordUid, 
    string username, 
    IRecordShareOptions options)
```

**Arguments:**

* `recordUid` - This is UID of the record which is to be shared with user
* `username`   - Email of the user with whom we are sharing the record
* `IRecordShareOptions` - Sharing options/permissions&#x20;
* **IRecordShareOptions**
  * `CanEdit`  - ***Boolean*** - whether the user with whom we are sharing can edit the record we are sharing with them
  * `CanShare`  - ***Boolean*** - whether the user with whom we are sharing can re-share the record we are sharing with them
  * `Expiration`  - ***DateTimeOffset*** -   Share duration for which the user will have access to the record. after the expiration is hit, the shared record will no longer be shared with the user.

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Grant-KeeperRecordAccess`&#x20;

**Aliases:** `kshr`

**Flags:**

* `-Record` : Record Uid which needs to be shared.
* `-User` : Email ID of user to be shared
* `-CanEdit` :  Use to grant permission of **Can Manage Records** to the user.
* `-CanShare` : Use to grant permission of **Can Manage Users** to the user
* `-ExpireIn` : 5&#x20;
* `-ExpireAt` : Date Object&#x20;

**Example:**

```powershell
PS > Grant-KeeperRecordAccess -Record record_uid -User "user@example.com" -CanShare -ExpireIn 5
Record "Example Record" was shared with user@example.com
```

</details>

<details>

<summary>Python CLI</summary>

**Command**: `share-record --action=<> --email=<email>`   &#x20;

**Parameters:**

* `record` : \<RECORD\_UID> of record to be shared
* `-e, --email` : Email of user to give access to
* `-a, --action` : Grant, revoke, owner and cancel - permission set for record

**Options**:

* `-s, --share` : Allow user to share record
* `-w, --write` : Allow user to edit record
* `-R, --recursive` : Apply command to the shared folder hierarchy
* `--expire-at` : Share expiration: "never" or ISO date-time "YYYY-MM-DD hh:mm:ss"
* `--expire-in` : Share expiration: "never" or period \<NUMBER>\[(m)inutes | (h)ours | (d)ays | (y)ears]
* `--dry-run` : Show the permission changes without applying them
* `--contact-only` : Share with known contacts only, prompts for matching contacts with other domains
* `-f, --force` : Skip asking prompts

**Example:**

```sh
My Vault> share-record -a='grant' -e='abc@email.com' -s -w --expire-in=30d af9ed1c8_d2b4_43a3_a459
Record "af9ed1c8_d2b4_43a3_a459" access permissions has been granted to user 'abc@email.com'
```

</details>

<details>

<summary>Python SDK</summary>

**Command** :&#x20;

```python
request = shares_management.RecordShares.prep_request(
    vault=vault,
    emails=[user_email],
    action=shares_management.ShareAction.GRANT.value,
    uid_or_name=record_uid,
    share_expiration=share_expiration,
    dry_run=False,
    enterprise=enterprise_data,
    enterprise_access=False,
    recursive=False,
    can_edit=can_edit,
    can_share=can_share,
)

# Send the request
shares_management.RecordShares.send_requests(vault, [request])
```

</details>

### Share Record- Cancel Command

This command can be used to remove all shares with the given user

<details>

<summary>DotNet CLI</summary>

**Command**: `share-record`

**Action:**

* `cancel`  : cancel a record share with user

**Flags**:

* **`-e, --email`** *(string, required)*
  * Email address of the recipient (peer account).
  * Example: `--email user@example.com`

**Example:**

```shell
Vault> share-record cancel user@email.com
Do you want to cancel all shares with user "user@email.com"? (Yes/No) : yes
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
Task CancelSharesWithUser(string username);
```

**Arguments:**

`username` - username of user with whom we will cancel all shares

**Exception:**

```csharp
Authentication.KeeperApiException
```

</details>

<details>

<summary>Power Commander</summary>

**Command** :  `Revoke-KeeperSharesWithUser -User [-Confirm]`

&#x20;**Alias:** `kcancelshare`

**Parameters:**

<table><thead><tr><th width="146.9921875">Parameter</th><th width="106.076171875">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>User</code></td><td>Yes</td><td>Email address of the user with whom to cancel all shares.</td></tr><tr><td><code>Confirm</code></td><td>No</td><td>By default, PowerShell prompts for confirmation (high impact). Use <code>-Confirm:$false</code> to skip the prompt.</td></tr></tbody></table>

**Example:**

```powershell
PowerCommander> Revoke-KeeperSharesWithUser -User am@ml.com
Confirm
Are you sure you want to perform this action?
Performing the operation "Cancel" on target "all record shares with user"am@ml.com"".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
All record shares with user "am@ml.com" have been cancelled.
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `share-record`

**Parameters:**

* `record` : \<RECORD\_UID> of record to be shared
* `-e, --email` : Email of user to give access to
* `-a, --action` : Grant, revoke, owner and cancel - permission set for record

**Example:**

```sh
Vault> share-record --action=cancel --email=user@email.com <record_uid>
```

</details>

<details>

<summary>Python SDK</summary>

**Command** : &#x20;

```python
request = shares_management.RecordShares.prep_request(
    vault=vault,
    emails=[user_email],
    action=shares_management.ShareAction.CANCEL.value,
    uid_or_name=record_uid,
    share_expiration=share_expiration,
    dry_run=False,
    enterprise=enterprise_data,
    enterprise_access=False,
    recursive=False,
    can_edit=can_edit,
    can_share=can_share,
)

# Send the request
shares_management.RecordShares.send_requests(vault, [request])
```

</details>

### Share Record - Revoke Command

This command can be used to revoke access of a record to a user.

<details>

<summary>DotNet CLI</summary>

**Command**: `share-record`

**Action:**

* `revoke`  : revoke a record share access from user

**Flags**:

* **`-e, --email`** *(string, required)*
  * Email address of the recipient (peer account).
  * Example: `--email user@example.com`
* **`record`** *(positional, required)*
  * Record path or UID to be shared.
  * Example: `MyPasswords/Bank` or `9xL2c6aBc1234`&#x20;

**Example:**

```shell
My Vault> share-record revoke uidaabbcc22556tbuid --email="user@email.com"
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
Task RevokeShareFromUser(string recordUid, string username);
```

**Arguments:**

* `recordUid` - This is UID of the record which is to be revoked from user
* `username`   - Email of the user from whom we are revoking the share

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Revoke-KeeperRecordAccess`

**Flags:**

* `-Record`  : Record Uid&#x20;
* `-User`  : Email ID of user to be shared

**Example:**

```powershell
PS > Revoke-KeeperRecordAccess adscsvv1314dca -User user@email.com                    
Record "some_record" share has been removed from <user>
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `share-record`

**Parameters:**

* `record` : \<RECORD\_UID> of record to be shared
* `-e, --email` : Email of user to give access to
* `-a, --action` : Grant, revoke, owner and cancel - permission set for record

**Options**:

* `-s, --share` : Allow user to share record
* `-w, --write` : Allow user to edit record
* `-R, --recursive` : Apply command to the shared folder hierarchy
* `--expire-at` : Share expiration: "never" or ISO date-time "YYYY-MM-DD hh:mm:ss"
* `--expire-in` : Share expiration: "never" or period \<NUMBER>\[(m)inutes | (h)ours | (d)ays | (y)ears]
* `--dry-run` : Show the permission changes without applying them
* `--contact-only` : Share with known contacts only, prompts for matching contacts with other domains
* `-f, --force` : Skip asking prompts

**Example:**

```sh
My Vault> share-record -a='revoke' -e='abc@email.com' <record_uid>
access permissions has been revoked from user 'abc@email.com'
```

</details>

<details>

<summary>Python SDK</summary>

**Command** :&#x20;

```python
request = shares_management.RecordShares.prep_request(
    vault=vault,
    emails=[user_email],
    action=shares_management.ShareAction.REVOKE.value,
    uid_or_name=record_uid,
    share_expiration=share_expiration,
    dry_run=False,
    enterprise=enterprise_data,
    enterprise_access=False,
    recursive=False,
    can_edit=can_edit,
    can_share=can_share,
)

# Send the request
shares_management.RecordShares.send_requests(vault, [request])
```

</details>

### Share Record - Transfer Ownership Command

This command can be used to grant owner access of a record to a user.

<details>

<summary>DotNet CLI</summary>

**Command**: `share-record`

**Action:**

* `transfer`  : Transfer a record / change record ownership.

**Flags**:

* **`-e, --email`** *(string, required)*
  * Email address of the recipient (peer account).
  * Example: `--email user@example.com`
* **`record`** *(positional, required)*
  * Record path or UID to be shared.
  * Example: `MyPasswords/Bank` or `9xL2c6aBc1234`

**Example:**

```shell
My Vault> share-record transfer aabbcc2266hyy --email="user@email.com"
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
Task TransferRecordToUser(string recordUid, string username)
```

**Arguments:**

* `recordUid` - This is UID of the record which is to be shared with user.
* `username`   - Email of the user with whom we are sharing the record.

**Exception:**

```csharp
KeeperApiException
```

</details>

<details>

<summary>Power Commander</summary>

**Command**:  `Move-KeeperRecordOwnership`

**Flags:**

* `-Record` : Record Uid which needs to be shared.
* `-User` : Email ID of user to be shared

**Example:**

```powershell
PS > Move-KeeperRecordOwnership record_uid -User user@email.com
Record "<some record title>" was transfered to user@email.com
The new record owner can edit or remove your access to this record.
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `share-record`

**Parameters:**

* `record` : \<RECORD\_UID> of record to be shared
* `-e, --email` : Email of user to give access to
* `-a, --action` : Grant, revoke, owner and cancel - permission set for record

**Options**:

* `-s, --share` : Allow user to share record
* `-w, --write` : Allow user to edit record
* `-R, --recursive` : Apply command to the shared folder hierarchy
* `--expire-at` : Share expiration: "never" or ISO date-time "YYYY-MM-DD hh:mm:ss"
* `--expire-in` : Share expiration: "never" or period \<NUMBER>\[(m)inutes | (h)ours | (d)ays | (y)ears]
* `--dry-run` : Show the permission changes without applying them
* `--contact-only` : Share with known contacts only, prompts for matching contacts with other domains
* `-f, --force` : Skip asking prompts

**Example:**

```sh
My Vault> share-record -a='owner' -e='abc@email.com' record_uid
```

</details>

<details>

<summary>Python SDK</summary>

**Command** :&#x20;

```python
request = shares_management.RecordShares.prep_request(
    vault=vault,
    emails=[user_email],
    action=shares_management.ShareAction.OWNER.value,
    uid_or_name=record_uid,
    share_expiration=share_expiration,
    dry_run=False,
    enterprise=enterprise_data,
    enterprise_access=False,
    recursive=False,
    can_edit=can_edit,
    can_share=can_share,
)

# Send the request
shares_management.RecordShares.send_requests(vault, [request])
```

</details>
