List and delete specific package versions from the GitHub Container Registry (GHCR) for an organization using the GitHub REST API

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

Steps

  1. List all versions of a container package using GET https://api.github.com/orgs/<ORG>/packages/container/<PACKAGE_NAME>/versions with a token that has packages:read scope
  2. Parse the response array to identify version IDs by tag name, digest, or creation date — the version ID is the numeric id field in each version object
  3. Delete a specific version using DELETE https://api.github.com/orgs/<ORG>/packages/container/<PACKAGE_NAME>/versions/<VERSION_ID> with a token holding packages:delete and packages:read scopes
  4. For user-owned packages (not org), use the /user/packages/container/<PACKAGE_NAME>/versions endpoint pattern instead of /orgs/<ORG>/...
  5. Automate bulk untagged image cleanup in a GitHub Actions workflow by iterating the versions list, filtering for versions with an empty metadata.container.tags array, and deleting those version IDs

Known gotchas

Related routes

Query open source package vulnerabilities by ecosystem and version via the OSV.dev REST API
google.github.io/osv.dev · 6 steps · unrated
List and dismiss GitHub Dependabot alerts across a repository and organization via the REST API
docs.github.com · 5 steps · unrated
Configure per-artifact COMPATIBILITY and VALIDITY rules in Apicurio Registry via the REST v2 API
apicur.io · 6 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