[{"title":"Delete CF Pages Deployments","url":"/posts/cf-too-many-deploy/","date":"2026-07-25","tags":["cloudflare","pages","tools"],"summary":"You may encounter the error Your project has too many deployments to be deleted, follow this guide to delete them: https://cfl.re/3CXesln when trying to delete a pages project which has more than …","content":"You may encounter the error Your project has too many deployments to be deleted, follow this guide to delete them: https://cfl.re/3CXesln when trying to delete a pages project which has more than approx. 100 deployments(each construction is considered as one build, like you updated an entry in your blog)\nSo I tell the big fat fish(Deepseek) to write a python script for me to automatically delete the deployments so that I can delete the project afterwards. The repo cloudflare-buik-delete is broken as the records per page of the pages api query is limited at 25, while the tool send queries with 100 records per page, causing HTTP 400 error\npython COPY 1#!/usr/bin/env python3 2\u0026amp;#34;\u0026amp;#34;\u0026amp;#34;Bulk delete all Cloudflare Pages deployments in a project.\u0026amp;#34;\u0026amp;#34;\u0026amp;#34; 3 4import os 5import sys 6import requests 7 8# Config — set these via environment variables or edit inline 9ACCOUNT_ID = os.environ.get(\u0026amp;#34;CLOUDFLARE_ACCOUNT_ID\u0026amp;#34;, \u0026amp;#34;your_account_id\u0026amp;#34;) 10TOKEN = os.environ.get(\u0026amp;#34;CLOUDFLARE_API_TOKEN\u0026amp;#34;, \u0026amp;#34;cfut_kfcCRAZYthursday\u0026amp;#34;) 11PROJECT = os.environ.get(\u0026amp;#34;CLOUDFLARE_PROJECT\u0026amp;#34;, \u0026amp;#34;hugo\u0026amp;#34;) 12 13BASE = f\u0026amp;#34;https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/pages/projects/{PROJECT}/deployments\u0026amp;#34; 14HEADERS = {\u0026amp;#34;Authorization\u0026amp;#34;: f\u0026amp;#34;Bearer {TOKEN}\u0026amp;#34;} 15 16 17def fetch_all_deployment_ids(): 18 \u0026amp;#34;\u0026amp;#34;\u0026amp;#34;Fetch all deployment IDs across all pages.\u0026amp;#34;\u0026amp;#34;\u0026amp;#34; 19 ids = [] 20 page = 1 21 while True: 22 resp = requests.get(f\u0026amp;#34;{BASE}?page={page}\u0026amp;#34;, headers=HEADERS).json() 23 if not resp[\u0026amp;#34;success\u0026amp;#34;]: 24 print(f\u0026amp;#34;Error fetching page {page}: {resp[\u0026amp;#39;errors\u0026amp;#39;]}\u0026amp;#34;, file=sys.stderr) 25 sys.exit(1) 26 27 ids.extend(d[\u0026amp;#34;id\u0026amp;#34;] for d in resp[\u0026amp;#34;result\u0026amp;#34;]) 28 total_pages = resp[\u0026amp;#34;result_info\u0026amp;#34;][\u0026amp;#34;total_pages\u0026amp;#34;] 29 print(f\u0026amp;#34; Page {page}/{total_pages} — collected {len(ids)} total\u0026amp;#34;) 30 31 if page \u0026amp;gt;= total_pages: 32 break 33 page += 1 34 35 return ids 36 37 38def …"}]