A utility script for completely removing all resources from a Split.io project workspace.
NOTE: This will not work out of the box with migrated accounts that are accessed from app.harness.io.
You will have to adjust the get_client configuration to set harness_mode to true and use the harness_token configuration option.
If so, you will also have to delete the project itself manually from the Harness UI, but the rest of the code for deleting the components of the project will still function in that case
This script systematically deletes all resources associated with a specific workspace/project in FME, including:
-
Environment-level resources:
- Splits/Feature Flags
- Segments (standard, rule-based, and large segments)
-
Project-level resources:
- Splits/Feature Flags
- Segments (all types)
- Traffic Types
- Flag Sets
-
Infrastructure:
- SDK Keys/API Keys
- Environments
- The workspace itself
- Python 3.x
- Split API Client library (
splitapiclient) - Admin-level API key with permissions to delete all resources
Before running the script, configure the following parameters:
projectName: Name of the workspace/project to deletethisApiKey: Your Split admin API keyenvironmentNameToSDKKeyMap: Dictionary mapping environment names to their SDK keysdryRun: Set toTrueto run in simulation mode (prints actions without actually deleting resources)
Example:
projectName = 'YOUR_PROJECT_NAME'
thisApiKey = 'your-admin-api-key'
dryRun = False # Set to True for a dry run without actual deletionsSimply run the script with Python:
python delete_all.pyThe script supports a dry run mode for safely previewing what would be deleted without actually making any changes:
- Set
dryRun = Trueat the top of the script - Run the script as normal
- Review the output to see what would be deleted
- When ready to proceed with actual deletion, set
dryRun = False
The script may fail with the following errors:
'NoneType' object has no attribute 'id': This occurs if the workspace specified inprojectNamecannot be found. Verify the workspace name is correct and that your API key has access to it.- API permission errors: Ensure your API key has sufficient permissions to delete all resource types.
- Because the API does not have access to metric configurations, the script will not delete them. This also means that traffic types will not be deleted if they are used in a metric and this will result in errors.
This script performs irreversible deletion of data. Once executed, all specified resources will be permanently removed. It is recommended to:
- Verify the
projectNamecarefully before running - Back up any important configuration before deletion
- Use in non-production environments first to understand the behavior
splitapiclient
Install using:
pip install splitapiclient