Create and apply a cleanup policy in Sonatype Nexus Repository via the REST API to remove Maven artifacts not downloaded in the past 60 days

domain: help.sonatype.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Send a POST request to https://<NEXUS_URL>/service/rest/v1/cleanup-policies with a JSON body containing name, format (maven2), and the criteriaLastDownloaded field set to 60 (days)
  2. Authenticate with an account that holds the nexus:settings:read and nexus:settings:update permissions; use HTTP Basic Auth or a user token
  3. Associate the cleanup policy with one or more hosted repositories by PATCHing the repository configuration at /service/rest/v1/repositories/maven/hosted/<repoName> and adding the cleanup policy name to the cleanup.policyNames array
  4. Trigger the cleanup task manually via POST to /service/rest/v1/tasks/<taskId>/run where the task type is repository.cleanup, or let the scheduled task run on its configured interval
  5. Review the Cleanup Performance Data page in the Nexus UI or query /service/rest/v1/cleanup-policies/<policyName> to confirm artifact counts targeted

Known gotchas

Related routes

Create a JFrog Artifactory retention policy via the REST API to automatically delete artifacts older than 180 days from a Docker hosted repository
jfrog.com · 5 steps · unrated
Create a Docker-format repository in Google Artifact Registry and configure cleanup policies to delete untagged images older than 30 days via gcloud and the REST API
cloud.google.com · 5 steps · unrated
Create, update, and delete New Relic alert policies via the NerdGraph API
docs.newrelic.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans