# IRPCSharedLinks.SetSharedLinks

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) > [Shared links](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/index.md)

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

Badges: `Vault API / standard` `write` `session or assertion` `returns metadata structure version`

Updates the access type of shared links, and grants or revokes access for anyone who has the
link.

- **Service:** [Shared links](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/index.md) `MFiles.IRPCSharedLinks`
- **gRPC method:** `/MFiles.IRPCSharedLinks/SetSharedLinks`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/set-shared-links`
- **Request:** [`SetSharedLinksRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinks/index.md#request)
- **Response:** [`SetSharedLinksResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSharedLinks/SetSharedLinks/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
- **Idempotent:** no
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- For each link, the server sets `external_shared_link_access_type` and the anyone-with-the-link
  state from the request. Every call writes both: a link sent without
  `is_anyone_access_granted` loses its anyone access.
- With `is_anyone_access_granted` true, `expires_at_utc` must be in the future (otherwise "The
  parameter is incorrect.") and becomes the link's expiration time; the vault must allow sharing
  with anyone who has the link. Without it, `expires_at_utc` is ignored; visitors have their own
  expiration times.
- Other fields of the links are ignored. Duplicate access keys are processed once.
- The response contains the updated links. The caller must be able to read the linked objects.

<a id="request"></a>

## Request: SetSharedLinksRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `shared_links[]` | repeated [`SharedLinkInfo`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SharedLinkInfo/index.md) | The links to update, identified by `access_key`, with the new `external_shared_link_access_type`, `is_anyone_access_granted` and `expires_at_utc`. |
| `shared_links[].access_key` | `string` | The access key of the shared link. |
| `shared_links[].description` | `string` | The description of the shared link. |
| `shared_links[].created_at_utc` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The creation time for the shared link. Is set by the server. Should be FILETIME_ZERO, when creating a new link. |
| `shared_links[].expires_at_utc` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The expiration time for the shared link. Use FILETIME_ZERO to indicate no expiration time. |
| `shared_links[].obj_ver` | [`ObjVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVer/index.md) | The object version referenced by the shared link. |
| `shared_links[].obj_ver.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object. |
| `shared_links[].obj_ver.version` | [`ObjVerVersion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVerVersion/index.md) | The version. Usually `OBJ_VER_VERSION_TYPE_SPECIFIC` with `internal_version`. |
| `shared_links[].created_by_user` | `int32` | The creator of this shared Link. |
| `shared_links[].file_ver` | [`FileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileVer/index.md) | The file version referenced by the shared link. |
| `shared_links[].file_ver.file_id` | [`FileID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileID/index.md) | The file. |
| `shared_links[].file_ver.type` | [`FileVerType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FileVerType/index.md) | `FILE_VER_TYPE_SPECIFIC` for a file version number. Values: `FILE_VER_TYPE_UNINITIALIZED` (0), `FILE_VER_TYPE_LATEST` (1), `FILE_VER_TYPE_ANY` (2), `FILE_VER_TYPE_SPECIFIC` (3). |
| `shared_links[].file_ver.internal_version` | `int32` | The file version number. |
| `shared_links[].file_ver.external_repository_version` | `string` | Used only for files in external repositories. Leave empty. |
| `shared_links[].file_ver.external_repository_sort_key` | `int64` | Used only for files in external repositories. Leave 0. |
| `shared_links[].shared_link_type` | [`SharedLinkType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.SharedLinkType/index.md) | Type of the shared link. Values: `SHARED_LINK_TYPE_READ_ONLY` (0), `SHARED_LINK_TYPE_CO_AUTHORING` (1), `SHARED_LINK_TYPE_WOPIREADONLY` (2), `SHARED_LINK_TYPE_WOPIEDIT` (3), `SHARED_LINK_TYPE_VISITOR` (4), `SHARED_LINK_TYPE_EXTERNAL` (5). |
| `shared_links[].is_anyone_access_granted` | `bool` | True if any user has granted public access to the document. |
| `shared_links[].anyone_access_granted_by_user` | `int32` | The user who has granted public access to the document. |
| `shared_links[].external_shared_link_access_type` | [`ExternalSharedLinkAccessType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ExternalSharedLinkAccessType/index.md) | Access type of the external shared link. Values: `EXTERNAL_SHARED_LINK_ACCESS_TYPE_UNINITIALIZED` (0), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_DOWNLOAD` (1), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_PREVIEW` (2), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_EDIT` (3). |
| `shared_links[].created_by_user_name` | `string` | The user who created the shared link. |
| `shared_links[].anyone_access_granted_by_user_name` | `string` | The user who granted public access. |

<a id="response"></a>

## Response: SetSharedLinksResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `shared_links[]` | repeated [`SharedLinkInfo`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SharedLinkInfo/index.md) | The links after the update. |
| `shared_links[].access_key` | `string` | The access key of the shared link. |
| `shared_links[].description` | `string` | The description of the shared link. |
| `shared_links[].created_at_utc` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The creation time for the shared link. Is set by the server. Should be FILETIME_ZERO, when creating a new link. |
| `shared_links[].expires_at_utc` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The expiration time for the shared link. Use FILETIME_ZERO to indicate no expiration time. |
| `shared_links[].obj_ver` | [`ObjVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVer/index.md) | The object version referenced by the shared link. |
| `shared_links[].obj_ver.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object. |
| `shared_links[].obj_ver.version` | [`ObjVerVersion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVerVersion/index.md) | The version. Usually `OBJ_VER_VERSION_TYPE_SPECIFIC` with `internal_version`. |
| `shared_links[].created_by_user` | `int32` | The creator of this shared Link. |
| `shared_links[].file_ver` | [`FileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileVer/index.md) | The file version referenced by the shared link. |
| `shared_links[].file_ver.file_id` | [`FileID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileID/index.md) | The file. |
| `shared_links[].file_ver.type` | [`FileVerType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FileVerType/index.md) | `FILE_VER_TYPE_SPECIFIC` for a file version number. Values: `FILE_VER_TYPE_UNINITIALIZED` (0), `FILE_VER_TYPE_LATEST` (1), `FILE_VER_TYPE_ANY` (2), `FILE_VER_TYPE_SPECIFIC` (3). |
| `shared_links[].file_ver.internal_version` | `int32` | The file version number. |
| `shared_links[].file_ver.external_repository_version` | `string` | Used only for files in external repositories. Leave empty. |
| `shared_links[].file_ver.external_repository_sort_key` | `int64` | Used only for files in external repositories. Leave 0. |
| `shared_links[].shared_link_type` | [`SharedLinkType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.SharedLinkType/index.md) | Type of the shared link. Values: `SHARED_LINK_TYPE_READ_ONLY` (0), `SHARED_LINK_TYPE_CO_AUTHORING` (1), `SHARED_LINK_TYPE_WOPIREADONLY` (2), `SHARED_LINK_TYPE_WOPIEDIT` (3), `SHARED_LINK_TYPE_VISITOR` (4), `SHARED_LINK_TYPE_EXTERNAL` (5). |
| `shared_links[].is_anyone_access_granted` | `bool` | True if any user has granted public access to the document. |
| `shared_links[].anyone_access_granted_by_user` | `int32` | The user who has granted public access to the document. |
| `shared_links[].external_shared_link_access_type` | [`ExternalSharedLinkAccessType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ExternalSharedLinkAccessType/index.md) | Access type of the external shared link. Values: `EXTERNAL_SHARED_LINK_ACCESS_TYPE_UNINITIALIZED` (0), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_DOWNLOAD` (1), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_PREVIEW` (2), `EXTERNAL_SHARED_LINK_ACCESS_TYPE_EDIT` (3). |
| `shared_links[].created_by_user_name` | `string` | The user who created the shared link. |
| `shared_links[].anyone_access_granted_by_user_name` | `string` | The user who granted public access. |
