Plex.tv - Share a Server
This API request will specify the settings for a managed user when sharing a Plex server with that user. This request should be called after adding a managed user to share libraries with the user.
URL
POST https://plex.tv/api/v2/shared_servers?X-Plex-Client-Identifier={client_identifier}&X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
plex_token | The Plex token. |
client_identifier | The identifier for the client. You can get a client ID by making a request to the Get Devices API and look for an ID in the clientIdentifier attribute. |
Body
{"machineIdentifier":"machine_identifier","librarySectionIds":[library_ids],"settings":{"allowTuners":allow_tuners,"allowSync":"allow_sync"},"invitedId":user_id}
Values
Value | Description |
---|---|
machine_identifier | The ProcessedMachineIdentifier for the Plex server. You can get this identifier from the Plex advanced settings |
library_ids | A comma-separated list of library section IDs, or empty for all libraries. The section IDs can be found by calling the Get a Server Plex.tv API endpoint and using the value of the id attribute for the sections you want the user to be able to access. |
allow_tuners | 0 - don't allow access to live TV. 1 - allow access to live TV. |
allow_sync | 0 - don't allow the user to download media. 1 - allow the user to download media. |
user_id | The ID of the user. |
Return Status
HTTP Code | Description |
---|---|
401 | Unauthorized - The token used to make the request is not authorized to share the server. |
422 | Unprocessable Entity - The server has already been shared with the user. |
Response
JSON information about the managed user and the share settings for the user on the Plex server.
Remarks
Making a request to this endpoint for the same user will result in a 422 status code and the following response will be returned:
<?xml version="1.0" encoding="UTF-8"?> <errors> <error code="1999" field="base" status="400"/> </errors>
Examples
curl -X POST -H "Content-Type: application/json" -d '{"machineIdentifier":"machine_identifier","librarySectionIds":[library_ids],"settings":{"allowTuners":allow_tuners,"allowSync":"allow_sync"},"invitedId":user_id}' https://plex.tv/api/v2/shared_servers?X-Plex-Client-Identifier={client_identifier}&X-Plex-Token={plex_token}
import requests plex_url = https://plex.tv/api/v2/shared_servers?X-Plex-Client-Identifier={client_identifier}&X-Plex-Token={plex_token} headers = {'Content-type': 'application/json'} data = {"machineIdentifier":"machine_identifier","librarySectionIds":[library_ids],"settings":{"allowTuners":allow_tuners,"allowSync":"allow_sync"},"invitedId":user_id} response = requests.post(plex_url, headers=headers json=data) print(response.text)
$JSON = @'{"machineIdentifier":"machine_identifier","librarySectionIds":[library_ids],"settings":{"allowTuners":allow_tuners,"allowSync":"allow_sync"},"invitedId":user_id}' $response = Invoke-RestMethod 'https://plex.tv/api/v2/shared_servers?X-Plex-Client-Identifier={client_identifier}&X-Plex-Token={plex_token}' -Method 'POST -Body $JSON -ContentType "application/json"' Write-Output $response