This Node.js script deletes all taxonomy concepts and concept schemes in your Contentful organization using the Contentful Management API.
-
Copy
.env.sample
to.env
and fill in your credentials. -
Run
npm install
to install dependencies. -
Run the script in dry run mode (default):
node delete-taxonomy-concepts-and-schemes.js
To actually delete concepts and concept schemes, run:
node delete-taxonomy-concepts-and-schemes.js --dry-run=false
ornode delete-taxonomy-concepts-and-schemes.js --no-dry-run
The script uses minimist for argument parsing.
CONTENTFUL_MANAGEMENT_TOKEN
: Your Contentful management API tokenORGANIZATION_ID
: Your organization ID
flowchart TD
A[Start] --> B[Fetch all taxonomy concepts from the Organization]
B --> C[Delete each concept]
C --> D[Fetch all concept schemes from the Organization]
D --> E[Delete each concept scheme]
E --> F[Done]
- By default, the script runs in dry run mode and will only show what would be deleted. No deletions will occur unless you pass
--dry-run=false
or--no-dry-run
. - Before any deletion (or in dry run), the script automatically backs up all concepts and concept schemes to JSON files in the
taxonomy-backup
directory. The backup files include the organization ID and the current date/time in both the filename and the file contents. - This script will delete all taxonomy concepts and concept schemes in the specified organization using the Contentful plain client. Use with caution.
- See Contentful API docs for more details.