Synapse media management and quarantine: when your server needs it
Use the Synapse media admin API to quarantine or delete media, and use the separate remote cache purge API to clear files cached from other servers. Your server needs these tools when uploads accumulate faster than your users can justify, or when someone posts abusive or unlawful files that must stop being served. Media on a Synapse homeserver falls into two groups. Local media is what your own users uploaded, and it stays on your storage until someone removes it. Remote cached media is a copy your server fetched because a local user viewed content from another homeserver in a federated room. Your users did not upload it, and it can grow without anyone choosing to store it.
Quarantine and deletion solve different problems. Quarantining makes a file inaccessible, so downloads return 404, but the file stays on disk, which preserves it for review or for a legal request. Quarantining by hash also blocks matching media uploaded later, which matters when the same abusive file is reposted. Deletion removes the file, either one item by server name and media ID, or local media older than a timestamp or above a size threshold. Use quarantine when you need to stop access first and decide later, and use deletion when you have decided the content should not exist on your storage. Before you run any of these, confirm with your legal or trust and safety team what must be retained, and check the endpoint parameters against the Synapse media admin API documentation for your installed version.
The decision that most shapes your plan is whether your server federates. On an internal server with federation disabled, remote cache growth is small or absent, so your effort goes to local uploads and retention. On a federated server, the remote cache is the larger unknown, and you should measure it before you choose a schedule for purges. Remote media can be cleared without touching local users' files, but you should confirm which purge endpoint your Synapse version exposes and whether it needs an admin token with the right scope. Write down who may run quarantine actions, who approves deletions, and how each action is logged, so the record holds up when a user, auditor or regulator asks what happened to a file.
Which media control fits which problem
This table compares the five Synapse media controls by what they remove, whether the file stays on disk, whether future uploads are blocked, and when each one fits. Read the middle columns first, because a quarantine keeps the file while a deletion removes it. The main takeaway is that quarantine is the step to take against abusive content, while deletion and remote purge are for managing storage.
| Control | What it removes and whether the file is kept | Blocks future uploads | When it fits |
|---|---|---|---|
| Quarantine one item | Makes one local or remote file return 404 to users. The file is kept on disk. | No. Only the existing item is affected. | Responding to one specific abusive file while you review it. |
| Quarantine by hash | Makes all matching media inaccessible. The files are kept on disk. | Yes. Matching media uploaded later is also blocked. | Known abusive content that users keep re-uploading. |
| Delete a specific local item | Removes one local media file, identified by server name and media ID. The file is not kept. | No. It acts only on the item named in the request. | Removing one local file after a quarantine review is complete. |
| Delete local media by date or size | Removes local media uploaded before a chosen timestamp. The files are not kept. | No. Future uploads are unaffected. | Reclaiming storage on a local server you operate. Confirm the size option in your version's docs. |
| Purge cached remote media | Removes copies of other servers' media cached on your server. Originals stay on their home servers. | Not stated in the documentation. Confirm before relying on it. | Freeing cache space on a federated server. Check the purge remote media API parameters first. |
How to set up media admin access and run a first cleanup
This sequence gives an operator a working admin API token, a confirmed inventory of media for a test scope, and a tested quarantine and delete path before any broader cleanup runs on a production Synapse homeserver.
Confirm an admin account and token
Confirm that the account you plan to use is a server admin in Synapse, and obtain an access token for it that you will use only for media administration. Store the token in your secrets manager rather than in shell history or scripts. Send a simple authenticated request to the admin API and confirm it returns a successful response for your account. You know this step is done when the request succeeds with the admin token and fails with a non-admin token, which shows the permission boundary works as intended.
Confirm endpoints against your Synapse version
Before you run any command, check the media admin API documentation for the exact endpoint paths and parameters that match the Synapse release you run in production. Compare them with the version reported by your deployment, and record the version next to your runbook. Endpoints and parameters can change between releases, so treat any path copied from an older guide as unverified until you have checked it. You know this step is done when your runbook names the Synapse version and the endpoint documentation you matched it against.
List media for a test user or room
Choose a single test scope, such as one account or one room that you control, and list the media uploaded there using the admin API. Record the server name, media IDs, upload times, sizes and content types in a file that stays outside the server. Do not quarantine or delete anything yet. You know this step is done when you have a written inventory of media IDs for the test scope and you can match at least one item to a message you can see in the room.
Quarantine the test item first
Quarantine one media item from your inventory using the media admin API. Quarantining makes the file inaccessible to users without deleting it, so it is the reversible step to take before any deletion. If you need to block matching content in future uploads, quarantine by hash instead, and confirm that the behavior matches your policy before you apply it widely. You know this step is done when the API reports success and the item still exists in your storage backend.
Verify downloads return 404 after quarantine
Request the quarantined media through the client download path, using a test account that is not an admin, and confirm the response is 404. Also confirm that the media still appears in your inventory and on disk, which shows that quarantine hid the file without destroying it. Repeat the check from a second account if your policy depends on remote access. You know this step is done when the non-admin download returns 404 and the file is still present on the storage backend.
Run a date or size delete on the test scope
Run a delete by date or size on the same test scope, not on the whole server. Use the delete endpoint with a before_ts value that matches only the test items in your inventory, and compare the list of media before and after. Check that deleted items are gone from the inventory and that other media is untouched. Keep the timestamp and the request result in your change log. You know this step is done when the listed test items are removed, nothing outside the scope changed, and the change is recorded.
Record the result and plan the broader cleanup
Write down the Synapse version, the endpoints used, the test scope, the counts before and after, and the verification results. Confirm with your compliance or legal owner whether deletion of local media is allowed under your retention rules before you widen the scope. Plan a separate review for cached remote media, which the Synapse media admin documentation describes through a different purge remote media API. You know this step is done when the record is stored with your runbook and the next scope has an approver.
How quarantine differs from deletion and why it matters for evidence
Quarantine hides media without destroying it. On a Synapse homeserver, the media admin API can quarantine a local or remote media item so that users can no longer download it: requests return 404, but the file stays on disk. That distinction matters when abusive content may be needed later for a moderation review, a user appeal, a law enforcement request or an internal incident investigation. A deleted file cannot be recovered from Synapse, while a quarantined file can still be examined by an administrator with access to the media store. Quarantining by hash goes further, because it also blocks matching media uploaded in the future, which makes it the stronger control for content you have already decided must not circulate on your server.
The decision you face is between preserving evidence and reclaiming storage. Deletion through DELETE /_synapse/admin/v1/media/<server_name>/<media_id> or the date and size based POST /_synapse/admin/v1/media/delete endpoint frees space immediately but removes the only copy Synapse holds. Quarantine keeps the item for review but does not reduce disk use, so a quarantined backlog will keep growing your media store until someone makes a retention decision. Before deleting anything, confirm with counsel whether your organization has legal hold obligations, sector-specific record retention rules or pending requests that cover the affected content. Record who decided, when, and on what basis, so the choice can be defended later.
Document the quarantine policy before the first incident. Name the role allowed to quarantine, the criteria for quarantining versus deleting, how long quarantined media is kept, and who signs off on final removal. Confirm with your Synapse version's media admin documentation exactly which API calls and parameters apply, and test quarantine and restore behavior in a non-production environment. Treat the media store, the database and any backups as one unit when planning retention, because a deleted file may still exist in a backup taken before the deletion.
Security and operational risks of media admin actions
Media admin actions are fast and destructive, and the Synapse media admin API acts on files that other people may still need. The cards below cover the risks that most often turn a cleanup or quarantine into an incident, and one control for each. Review them before any admin token is used against production media.
Over-broad delete commands
A date or size filter on POST /_synapse/admin/v1/media/delete removes every matching local file in one call, including attachments that users still open from old rooms. Before running it, pick a before_ts value that matches a reviewed retention decision, and run the request against a copy of the database or a staging server first. Ask who signed off on the cutoff and whether any room history depends on those files.
Admin token exposure
Anyone holding an admin access token can quarantine, delete or purge media across the server, so a token pasted into a ticket, script or shell history is a direct path to data loss. Keep admin tokens out of scripts and logs, issue them to named admins only, and rotate them after staff changes. Check which accounts have server admin rights in your database before each cleanup window.
Missing audit trail
The media admin calls change what users can see, but nothing in the request itself records who quarantined a file or why. Without a record, a legal hold or user complaint cannot be traced to a decision. Capture the requester, the media ID or hash, the reason and the timestamp in your change system before each call, and confirm that your Synapse logs and reverse proxy logs retain the request.
Quarantine that misses downloaded copies
Quarantining makes media return 404 to users on your server, but a person who already downloaded the file keeps it on their device. A quarantine is therefore a containment step, not a removal from the people who saw the content. Record which users could have accessed the media before quarantining, and decide with legal and trust and safety teams whether that exposure needs a separate response.
Federated copies outside your control
Remote media that your server cached is stored on your disk, but the original and any copies held by other servers stay under those administrators' control. Quarantining or purging a cached copy on your server does not reach them. Confirm which remote servers your users actively join, and document that other homeservers may still serve the file to their own users.
Purging cached media that users still need
Purging remote media clears your server's cache, so the next user who opens an older federated file triggers a new download from the origin server. If that origin is slow, offline or rate limits requests, the file may fail to load for a while. Check the remote media purge options in the media admin docs against your storage goals, and schedule purges outside peak hours.
Media admin API docsManaging cached remote media on a federated server
Cached remote media is a copy your homeserver keeps when a local user opens a file posted by someone on another server in a shared room. On an internal server that rarely federates, that cache is usually small because few remote sources ever reach your users, so purging is mostly housekeeping. The separate purge remote media API covers media cached from other servers, not the uploads your own users made, so confirm its exact scope in the Synapse media admin API documentation before running it.
- Who creates the cache: Only users who open remote media in rooms that include other servers add entries, so a server with federation disabled or tightly restricted has little to clear.
- Check federation settings first: Confirm the federation_domain_whitelist setting, because an empty list disables federation and changes what cache can exist.
- Separate local and remote deletion: Local media deletion removes files your users uploaded, while the purge remote media API targets content from other servers.
- Retention questions: Confirm whether an internal policy requires keeping copies of conversations that included external media.
Before scheduling any purge, confirm with your records owner which conversations must be preserved.
A federated server with active external rooms refills its cache constantly, because every user who opens a remote image, video or file adds to it. Purging therefore trades stored bytes for later work: when a user opens an item again, the server must fetch it from the origin server, which may be slow or may no longer host the file. Quarantine and purge serve different goals. Quarantine blocks access while keeping the file, and purge removes cached copies, so decide which outcome you need before you act on a remote item.
- Expect re-fetching: Purged media is requested again from the origin server on the next view, which adds network load and can fail if the origin has removed the file.
- Schedule outside busy periods: Choose a quiet window, since purges and re-fetches both draw on the server and its outbound network path.
- Coordinate with quarantine: A quarantined remote item stays blocked, so decide whether it should be purged afterward or kept as evidence for a report.
- Record the decision: Log which remote servers were affected and why, so incident reviews can reconstruct what was removed.
Before purging items tied to an abuse report, ask your moderation team whether they still need to review them.
When disks fill, cached remote media is often a large group that can be cleared, but it is not the only consumer of storage. Local uploads, database growth and logs also grow over time, and each needs its own retention decision. Remote cache removal is a common first step because the originating content still exists on the other server, so users can usually re-fetch what they need. Confirm the purge scope and its effect on your environment with the platform team before relying on it to relieve an urgent shortage.
- Measure before deleting: Identify which media directories and database tables are largest so you know what a purge will actually free.
- Handle local media separately: Use the local media deletion by date or size endpoints for uploads, which require their own retention decision.
- Protect the database: Media metadata lives in the database, so confirm backups are current before and after any cleanup.
- Plan for a fetch spike: After a purge, users reopening old rooms can generate a burst of outbound requests.
- Check version notes: Synapse upgrades can change the database schema and rollback can be difficult, so review the upgrade notes before changing media handling alongside an upgrade.
Ask your platform team to test the purge on a staging copy of your data before running it in production.
Limits to confirm in your environment
The media admin API behaves differently across Synapse releases and deployment layouts, so the items below are checks rather than settled facts. Confirm each one against your own Synapse version, database, storage and federation settings before you write a media retention or quarantine procedure.
Admin API version in your release
Confirm which media admin endpoints your installed Synapse release exposes, including quarantine, single-item deletion and the bulk delete by date or size. Check the exact paths against the Synapse documentation for your version, because the before_ts parameter and route names are the first things to break in a script copied from an older guide. Test each call on a non-production homeserver and record the release in your runbook.
Quarantine for remote media
Confirm that quarantining behaves the same for media cached from other servers as it does for local uploads. Test that a quarantined remote item returns a 404 to your users, and confirm whether the hash-based block also applies to matching media fetched from federated servers in future. Do not assume the behavior matches local media until you have tested it on your own release.
Deletion and backups
Confirm how deleting media interacts with your backup set. A restore from a backup taken before a deletion may bring back media records and files that your policy says were removed, so decide whether erasure obligations require backup expiry or re-running deletions after a restore. Confirm this with your backup vendor and your privacy lead, and write the answer into the runbook.
Object storage and media store cleanup
Confirm whether the API removes only database records or also the files on disk or in an object storage backend. If you use a custom media store path or an S3-compatible bucket, check whether files remain after a delete and whether a separate cleanup job is needed. Measure storage before and after a test deletion so your capacity figures reflect actual reclaimed space.
Handling media from other servers
Confirm how cached remote media is re-fetched after a purge, and whether a federated peer can serve the same file again. Check how your federation policy, including any domain allow list, affects what gets cached, and confirm the purge remote media API your release provides. Plan for a purged item to reappear if a remote user still posts it into a shared room.
Questions teams ask before running media cleanup
Can our own team run Synapse media cleanup without a partner?
Yes, if you have an administrator who can run the Synapse media admin API and a process for deciding what to remove. The admin endpoints are documented and the calls themselves are short. The work that takes time is deciding the rules: which media is abusive, which must be kept for a legal hold, and who signs off on deletion. Your team also needs to confirm the server's storage layout and backups before anything is deleted, because a deletion made through the API is not something you can undo from Synapse. A partner is most useful when those rules are unclear or the cleanup has to be documented for an assessment.
What drives the effort of a media cleanup project?
Four factors shape most of the work. The first is media volume: how many local and cached remote files exist and how they are spread across storage. The second is federation scope: a server that federates widely caches far more remote media than an internal server, and purging that cache needs its own review. The third is legal hold rules: each category of content that must be kept adds a decision and a record of it. The fourth is backup and storage layout, since you need to know where media files live, whether they are on shared or object storage, and whether backups hold copies you must also address. Each factor adds review time, so ask a quote to name which of them apply.
What does the cleanup need from our team before it starts?
The work needs four inputs. You need admin access to the Synapse server with an account that can call the media admin endpoints, and a way to read the server logs and database. You need a test server with a copy of realistic media so that the commands and their effect can be checked before production. You need a named approval path that says who may approve a quarantine, a deletion or a legal hold exception, and how that decision is recorded. Finally, you need a current, tested backup and a window in which the server can be watched while the job runs. Missing any of these usually pushes the work into the middle of an incident.
How long does a first media cleanup take?
The duration depends on scope rather than on the API calls, which run quickly. A first cleanup usually includes an inventory of media, the approval rules, a rehearsal on a test server, the production run and a record of what was removed. Ask any provider to state the duration for each of those phases in the written scope, and ask what is excluded. Quarantine decisions for individual abusive files tend to take longer than bulk deletions by date or size, because each one needs a reviewer. Plan for the approval process to set the pace, not the command.
Does quarantining media remove it from the server?
No. Quarantining makes local or remote media inaccessible to users, so downloads return a 404, but the file stays on disk. That keeps the evidence available for review or a legal hold. Quarantining by hash also blocks matching media uploaded in the future, which is useful for repeated abusive files. Deleting media is a separate step with its own risk, and should only follow an approved decision. Confirm with your legal and trust teams which items must be quarantined but kept, and which may be removed.
Why do we need to purge cached remote media, and how is it different from deleting local media?
Local media is what your own users uploaded, so your policy decides its retention. Remote media is copied to your server when your users view content from other servers, and it fills storage without being uploaded by anyone on your side. The Synapse media admin docs refer to a separate purge remote media API for this cache. Purging it is a storage decision, and it does not remove anything your users uploaded. Confirm with the Synapse admin documentation for your release before running the purge, because the exact endpoints and parameters should be checked against the version you run.
What does a DeployOpen engagement include for media cleanup?
DeployOpen plans and implements the cleanup on Synapse servers in your own infrastructure. A typical written scope covers the media inventory, the quarantine and deletion rules your team approves, a rehearsal on a test server, the production run and the records that show what was done. Engagements are fixed-scope, so the deliverables and timelines are agreed in writing before work starts, and a quote follows from that scope. Ongoing media retention checks can be covered by a retainer. DeployOpen does not issue audit reports or certifications, so any evidence you need for an assessment is prepared for your auditor to review.
What should we ask for in a quote for media cleanup work?
Ask for the scope in writing, with each phase listed separately: inventory, rule design, test-server rehearsal, production run, and documentation. Ask which media categories are covered, which storage and backup locations are included, and whether cached remote media is in scope. Ask who approves decisions during the work and what happens if a legal hold appears partway through. Ask whether any follow-up retention checks are priced separately as a retainer. Finally, confirm which Synapse version the quote assumes, since the admin endpoints should be checked against the release you run.
How media moves through quarantine, deletion and remote purge
The diagram starts with a user upload stored as local media on the homeserver. An admin then chooses one of three paths: quarantine, which hides the file from users while keeping it and can block matching hashes in future uploads; deletion by media ID, or by date or size, which removes the file; or a separate purge of remote media cached from other servers. Check that each path uses the right API, and confirm the hash-block behavior in your own Synapse version before relying on it.
Quarantine keeps the file, while deletion and remote purge remove cached copies.
How DeployOpen scopes and supports Synapse media controls
DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, including Synapse media management. For quarantine, deletion and remote media purging, we scope the controls against your retention rules and your moderation process before any admin tooling is changed.
How we scope
- Written scope records which media types, size limits and retention windows the Synapse controls must cover.
- We confirm who may run quarantine and deletion commands, and how those actions are logged and approved.
- We agree the Synapse version, database and deployment model the media procedures will run against.
How we build
- We configure and test the media admin API calls for quarantine, deletion by date or size, and hash blocking in a staging copy.
- We build repeatable runbooks with the exact commands, parameters and checks your operators will use.
- We verify that quarantined media returns 404 to users and that storage shrinks as expected after deletion.
How we hand over
- You receive documented procedures, a decision record for retention settings, and a log of the tests run.
- We walk your administrators through quarantine, deletion and remote media purge steps on your own server.
- Documentation states which steps are one-time setup and which are routine operations your team repeats.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Retainers can cover re-checking media procedures after each Synapse upgrade and API change.
- Ask any provider to confirm how media admin endpoints are versioned and tested before each upgrade.

