Does anyone have a good solution for batch disabling of user accounts, for example, students who had Qualtrics accounts but have graduated or are no longer enrolled? Going forward we will be implementing auto-expiration dates for student accounts, but for now we have a huge backlog of accounts and I really don’t want to change their status one by one.
Batch disabling of user accounts
Best answer by erooney
A while back we had the same need. To do this I navigated to Legacy Reports and then exported stats out to CSV. From this list I identified the users I wanted to disable and kept those rows and, importantly, the ‘User ID’ column. I renamed the file to users.csv and used that in a Python script.
With that CSV file in hand, I had a Python script that would go through and disable each account in the CSV file. You can also query Qualtrics via the API and get at all accounts in the brand if you wanted to.
Before you start you will need the following: your API key and your data center. Both are listed under My Account > Qualtrics IDs.
Here’s the Python script I used. You will need to modify it and drop in your API key, data center ID and CSV file name with the User IDs from the report you downloaded. This will disable accounts whose User IDs you have in the CSV file.
I’ve also included some commented out code (at the bottom of the script) you could use to query your brand and access ALL users and use that info to determine which accounts to disable. You would still need to issue a request to the API to do that, but this gets you started if you go down that route.
All this being said, this is provided as-is. Please review any code before running in your environment.
import csv
import json
import requests
# Setting user Parameters
apiToken = "YOUR_TOKEN_HERE" # 1 See My Account > Qualtrics IDs
dataCenter = "sjc1" # 2 See My Account > Qualtrics IDs
csvFile = "mycsv.csv" # 3 Your CSV file downloaded from Legacy reports...
headers = {
"x-api-token": apiToken,
"Content-Type": "application/json"
}
# We want to SET the user account as disabled
data = {
"status": "disabled"
}
# Loop through CSV file and change user account status to inactive/disabled.
with open(csvFile, newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
userId = row['User ID'] # 3
baseUrl = "https://{0}.qualtrics.com/API/v3/users/{1}".format(dataCenter, userId)
response = requests.put(baseUrl, json=data, headers=headers)
#print(response.text)
print(row['User ID'], ' account disabled')
#
# Get list of all users in the brand.
# Use this code if you want to to go against API directly and figure out
# which accounts to disable...
#users = []
#while baseUrl is not None:
# response = requests.get(baseUrl, headers=headers)
# baseUrl = response.json()['result']['nextPage']
# users += response.json()['result']['elements']
#
# Print out list of users
#
#for user in users:
# print(user["id"],",",user["email"],",",user["username"],",",user["accountStatus"])
# # Issue request here to disable...
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
