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

NameDescription
plex_tokenThe Plex token.
client_identifierThe 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

ValueDescription
machine_identifierThe ProcessedMachineIdentifier for the Plex server. You can get this identifier from the Plex advanced settings
library_idsA 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_tuners0 - don't allow access to live TV.
1 - allow access to live TV.
allow_sync0 - don't allow the user to download media.
1 - allow the user to download media.
user_idThe ID of the user.

Return Status

HTTP CodeDescription
401Unauthorized - The token used to make the request is not authorized to share the server.
422Unprocessable 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
Subscribe
Display