Table of Contents
At CallHub, we work closely with customers on their political phone banking and SMS marketing campaigns. A lot of our customers use NationBuilder as their primary CRM. We’ve built a great integration with NationBuilder that we’re proud of. Some of our customers do come to us if they have specific issues with their setup. One such client had way too many stagnant lists in his NationBuilder account. Unfortunately, there isn’t an easy way to delete lists in one go. NationBuilder does not let you batch delete a large number of lists. I thought I’d take a shot at this problem considering my comfort level with NationBuilder as a developer. It took me a weekend but I figured it out. Here is my solution on how to batch delete lists on NationBuilder.
What you need
Python
If you have a Mac, El Capitan comes with Python 2.7 installed. If you have a Windows machine, you can install the Python executable.
NationBuilder Access token
To run a script on NationBuilder you need to use an Access token. Here are steps on how to generate your access token. You need to be an administrator of the Nation to be able to generate a token. If you are not an administrator, either request for access or ask the administrator to follow these steps to generate an access token.
- Go to Settings > Developer > API Token and click on Create Token.
- Copy the token.
List ID
Get the IDs of the list you’d like to delete. If the lists are in sequence, you can even pass a range of IDs to the script. For example, if you want to delete all the lists with ID from 5 to 12 then pass <5:12>
to the script as a parameter.
Unsure of how to get the ID for a list? You’ll find the ID in the url of the list.
Download the script
The code is available for download or for cloning from the CallHub GitHub repository. Unzip the files and access the files under callhub-examples-master/utilities
.
[pivot_button text=”Download the script” url=”https://github.com/callhub/callhub-examples”]
Run the script
To run the script, you need access to a terminal / CLI. If you are on a Mac, use Terminal. If you are on a Windows machine launch the Windows command line program CMD. Switch to the directory callhub-examples-master/utilities
, the directory in which the files are placed and then run the following command, depending on your OS.
Mac
./deletelist.py <slug> <access_token> <list_id> <list_id>
Windows
py deletelist.py <slug> <access_token> <list_id> <list_id> OR py deletelist.py <slug> <access_token> <start:end>
Where:
<slug>
Is your NationBuilder slug
<access_token>
Is the access token you got in the previous step
<list_id>
Is the ID or IDs or range of IDs of the lists you want to delete
That’s all folks!
Yes, it’s that easy. Head over to your nation to find all your errant lists gone. We’ve also thrown in a couple of other scripts that will help speed up your batch operations on NationBuilder.
Add Tag
Use this script to tag a large number of people at once.
Remove Tag
Use this script to remove a tag from a large number of people at one go.
If you’d like to get more tips and content on NationBuilder, subscribe now!