> For the complete documentation index, see [llms.txt](https://docs.remote.it/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.remote.it/developer-tools/api/usage/device-sharing.md).

# Device Sharing

Share and unshare Remote.It devices and individual services with other users through the GraphQL API, with optional scripting permission.

This mutation allows you to add or remove device and service sharing from your account to other users. DeviceId and ServiceId can be retrieved [here](https://docs.remote.it/developer-tools/api/usage/devices-and-services.md#get-your-devices).

| Parameters | Data Type                | Description                                                                                                                               |
| ---------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| deviceId   | String                   | <p><strong>required</strong></p><p>The ID of the device to share</p>                                                                      |
| email      | \[String]                | <p><strong>required</strong></p><p>The email(s) of the user you want to share the device with, or you can specify an array of emails.</p> |
| scripting  | Boolean                  | Grants bulk scripting permission to the user (**default**: false)                                                                         |
| notify     | Boolean                  | The user will be notified (**default**: true)                                                                                             |
| action     | String                   | ADD, REMOVE, LEAVE (**default**: ADD)                                                                                                     |
| services   | \[ServiceSharingOptions] | For sharing only a subset of services. This field and below is not required if sharing all services of a device                           |
| serviceId  | String                   | The ID of the specific service associated with the deviceID                                                                               |

### Add or Remove

This example shares and notifies `email@example.com` that deviceId `80:00:00:00:12:34:56:78` has been shared and all services associated with it but does not grant bulk scripting permissions.

```graphql
mutation {
  share(deviceId: "80:00:00:00:12:34:56:78", 
        email: "email@example.com", 
        scripting: false,
        notify: true,
        action: ADD)
}
```

This example shares a service and removes a share of another service on the same device to multiple users.

```graphql
mutation {
  share(deviceId: "80:00:00:00:12:34:56:78",
        email: [
          "email1@example.com",
          "email2@example.com"
        ],
        notify: true,
        services: [
          {serviceId: "80:00:00:00:12:34:56:79", action: ADD},
          {serviceId: "80:00:00:00:12:34:56:79", action: REMOVE}
        ]
```

### Leave

If you want to leave a shared device that another user has shared with you previously

```graphql
mutation {
  share(
    deviceId: "80:00:00:00:12:34:56:78"
    email: "YourEmail@example.com"
    action: LEAVE
  )
}
```

Response Example

```graphql
{
  "data": {
    "share": true
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.remote.it/developer-tools/api/usage/device-sharing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
