Plex.tv - Add an Admin User PIN

This API request will add a PIN to an administrator account on a Plex server.

URL

PUT https://plex.tv/api/home/users/{user_id}?pin={new_pin}&X-Plex-Token={plex_token}

Parameters

NameDescription
plex_tokenThe Plex token.
user_idThe ID of the administrative user. You can get the user ID by making a request to the Get Users API and using the id attribute value for a user that has the admin attribute set to 1.
new_pinThe new PIN for the administrator account.

Return Status

HTTP CodeDescription
200Success - The request was successful.
401Unauthorized - The token used to make the request is not authorized to change the PIN, or the user already has a PIN.
404Not found - The user associated with the ID was not found. Verify the ID of the API request.

Response

Not much information is returned in the response. Only a status code of 200, a response code of 0, and a status indicating the user's PIN was added is returned. The response of a successful PIN being added to the administrative account is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<Response code="0" status="Updated user"/>

Remarks

This API request will return different responses for each error status code.

If the administrative user already has a PIN, then this request will return a 401 (Unauthorized) error with the following response:

<?xml version="1.0" encoding="UTF-8"?>
<Response code="401" status="Incorrect PIN"/>

You may also get a 401 if the Plex token cannot be parsed on the command line. The response would be:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
    <error>Please sign in.</error>
</errors>

If the provided Plex token is not a valid administrator token, then the request will return a 404 (Not Found) with the following response:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
    <error>Invalid authentication token.</error>
</errors>

A 404 can also be returned if the user ID was not found. This error will have the following response:

<?xml version="1.0" encoding="UTF-8"?>
<Response code="404" status="User {user_id} could not be found in your home"/>

The user_id value will be replaced with the ID provided in the request.

Examples

curl -X PUT https://plex.tv/api/home/users/{user_id}?pin={new_pin}&X-Plex-Token={plex_token}
import requests
plex_url = https://plex.tv/api/home/users/{user_id}?pin={new_pin}&X-Plex-Token={plex_token}

response = requests.put(plex_url)

print(response.text)
$response = Invoke-RestMethod 'https://plex.tv/api/home/users/{user_id}?pin={new_pin}&X-Plex-Token={plex_token}' -Method 'PUT'

Write-Output $response

Subscribe
Display