Skip to content

Prune Pages Deployments

The purpose of this command is to offer a quick way to bulk remove Cloudflare Pages deployments.

There are three ways to remove deployments:

  • Deleting all deployments for a branch.
  • Deleting all deployments before a certain time.
  • Deleting all deployments after a certain time.

If you want to delete all deployments for a project, check out the purge deployments command.

Running

You need to pass the following flags to run this program:

  • --api-token: Your API token with the required permissions.
  • --account-id: Your account ID where the pages project is located.
  • --project-name: The name of the pages project.

You need to pass only one of the following flags:

  • --branch: The alias you want to remove deployments from.
  • --before: The date you want to remove deployments before. Format: YYYY-MM-DDTHH:mm:ss. Example: 2021-01-01T00:00:00 = January 1st, 2021 at 12:00:00 AM.
  • --after: The date you want to remove deployments after. Format: YYYY-MM-DDTHH:mm:ss. Example: 2021-01-01T00:00:00 = January 1st, 2021 at 12:00:00 AM.

Optional flags:

  • --dry-run: If you want to see what would be deleted without actually deleting anything.
  • --lots-of-deployments: If you have more than 1000 deployments, this will slow down the rate of listing deployments.

Example:

cloudflare-utils --api-token <API Token with Pages:Edit> --account-id <account ID> prune-deployments --project-name <project name> --branch <branch>
Warning

I have only tested this with a project with 20,000 deployments. While doing so, it was able to delete all deployments even though some throw errors. It will take a while to run with a lot of deployments so be patient.

Required API Permissions

  • Account:Cloudflare Pages:Edit

Token Quick Link