Scan a Single Library

When you add or remove media from your Plex server you will need to scan the libraries to update Plex with the changed media. You can run the scan from the Plex Web app, or you can use this API command to run the scan from outside of Plex.

You should run a scan when one of the following has occurred:

  • Added or removed media files.
  • Added or removed directories from a library.
  • Renamed a media file or directory.
  • Moved any files from one location to another.

This command will run a scan for a single in your Plex server.

URL

GET http://{ip_address}:32400/library/sections/{id}/refresh?X-Plex-Token={plex_token}

Parameters

NameDescription
ip_addressThe IP address of the Plex Media server.
plex_tokenThe Plex token.
idThe key associated with the library. This key can be found by calling the Libraries API command.

Return Status

HTTP CodeDescription
200Success - The request was successful.
401Unauthorized - The Plex token provided was not valid.

Response

No response is returned. You will be able to see the scan API command run from the Plex console.

Remarks

The time it takes for the scan to complete is dependent on how many media times are within the library

This command will return immediately, but the scan will still be running on the Plex server.

Whenever you want to add movies, add TV shows, or add music to Plex, you will first add the media files to your Plex library location, and then run this scan.

If you only need to scan for a few media items, you can use the Scan Partial Library API command.

Examples

curl -X GET http://{ip_address}:32400/library/sections/{id}/refresh?X-Plex-Token={plex_token}
import requests
plex_url = http://{ip_address}:32400/library/sections/{id}/refresh?X-Plex-Token={plex_token}
response = requests.get(plex_url)
print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/refresh?X-Plex-Token={plex_token}' -Method 'GET'
Write-Output $response
Subscribe
Display