# Shared links (IRPCSharedLinks)

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/

Creates and manages shared links to files for people outside the vault.

- **gRPC service:** `MFiles.IRPCSharedLinks`
- **Book and level:** [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md), standard
- **Methods:** 15
- **Proto file:** [`mfiles/IRPCSharedLinks.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/IRPCSharedLinks.proto)

<a id="overview"></a>

## Overview

Creates and manages shared links: links that give people outside the vault access to one file of
a document. A link is identified by its **access key**, a 64-character random string that the
server generates. Anyone who has the access key and the vault GUID can use the link through
[IRPCSharedLinksPublic](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinksPublic/index.md) without logging in, so treat access
keys as secrets.

Link types ([SharedLinkType](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.SharedLinkType/index.md)):

- `SHARED_LINK_TYPE_READ_ONLY`: a public download link. Anyone with the key can download the
  file. Points to a specific checked-in object version.
- `SHARED_LINK_TYPE_EXTERNAL`: an external link, shared with named visitors (recipients) that
  each have an expiration time and access type, or with anyone who has the link
  (`is_anyone_access_granted`). Points to the latest version.
- `SHARED_LINK_TYPE_VISITOR`: the older form of a link shared with named visitors. Points to
  the latest version.
- `SHARED_LINK_TYPE_CO_AUTHORING`, `SHARED_LINK_TYPE_WOPIREADONLY`, `SHARED_LINK_TYPE_WOPIEDIT`:
  internal links for co-authoring and Office for the web, used by M-Files clients.

Typical flows:

- **Public download link**:
  [CreateSharedLink](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/CreateSharedLink/index.md) with
  `SHARED_LINK_TYPE_READ_ONLY`; list with
  [GetSharedLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinks/index.md) or
  [GetSharedLinksByObject](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinksByObject/index.md); remove with
  [DeleteSharedLink](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/DeleteSharedLink/index.md).
- **External link**: check
  [GetExternalSharingSettings](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetExternalSharingSettings/index.md), create
  the link with `SHARED_LINK_TYPE_EXTERNAL`, add visitors with
  [AddSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/AddSharedLinkRecipients/index.md), and manage
  them with [GetSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinkRecipients/index.md),
  [SetSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinkRecipients/index.md) and
  [RemoveSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/RemoveSharedLinkRecipients/index.md). Grant
  or revoke access for anyone with the link with
  [SetSharedLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinks/index.md). List an object's external
  links with [GetExternalLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetExternalLinks/index.md).

Prerequisites: sharing must be enabled on the server and in the vault; otherwise the methods fail
with "Access denied." (except for the internal link types). Read-only links, and external links
open to anyone, also need the vault setting that allows sharing with anyone who has the link.
Anonymous sessions cannot use this service.

**Times.** An unset expiration time means "never expires"; the server returns it as
1601-01-01T00:00:00Z. A recipient added without an expiration time is returned with
1753-01-01T00:00:00Z.

**Errors.** An unknown, deleted or expired access key fails with "The link is either expired or
invalid.".

<a id="methods"></a>

## Methods

| Method | Summary | Facts |
|---|---|---|
| [AddSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/AddSharedLinkRecipients/index.md) | Adds visitors (email recipients) to an external or visitor link and returns all its recipients. | `write` `session or assertion` `returns metadata structure version` |
| [CreateSharedLink](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/CreateSharedLink/index.md) | Creates a shared link to one file of an object and returns it with its new access key. | `write` `session or assertion` `returns metadata structure version` |
| [DeleteSharedLink](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/DeleteSharedLink/index.md) | Deletes a shared link, so that its access key stops working. | `write` `session or assertion` `returns metadata structure version` |
| [GetExternalLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetExternalLinks/index.md) | Lists the external links of an object. | `write` `session or assertion` `returns metadata structure version` |
| [GetExternalSharingSettings](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetExternalSharingSettings/index.md) | Tells whether sharing is enabled in the vault and what the caller may do with external links. | `write` `session or assertion` `returns metadata structure version` |
| [GetSharedLink](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLink/index.md) | Gets one shared link by its access key. | `write` `session or assertion` `returns metadata structure version` |
| [GetSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinkRecipients/index.md) | Lists the visitors (email recipients) of an external or visitor link. | `write` `session or assertion` `returns metadata structure version` |
| [GetSharedLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinks/index.md) | Lists the shared links that the caller created, or all links for users who can see all objects. | `write` `session or assertion` `returns metadata structure version` |
| [GetSharedLinksByObject](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetSharedLinksByObject/index.md) | Lists the shared links to one object. | `write` `session or assertion` `returns metadata structure version` |
| [GetWOPILock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/GetWOPILock/index.md) | Not supported: always fails with "Not implemented.". | `write` `no session` |
| [RemoveSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/RemoveSharedLinkRecipients/index.md) | Removes visitors from an external or visitor link. | `write` `session or assertion` |
| [RemoveWOPILock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/RemoveWOPILock/index.md) | Not supported: always fails with "Not implemented.". | `write` `no session` |
| [SetSharedLinkRecipients](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinkRecipients/index.md) | Updates the expiration time and access type of visitors of external links. | `write` `session or assertion` `returns metadata structure version` |
| [SetSharedLinks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinks/index.md) | Updates the access type of shared links, and grants or revokes access for anyone who has the link. | `write` `session or assertion` `returns metadata structure version` |
| [SetWOPILock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetWOPILock/index.md) | Not supported: always fails with "Not implemented.". | `write` `no session` |
