How can I bulk update user fields & group preferences via the API?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
We are currently trying to use the emma APIs to bulk add / update users & sync their fields and group preferences. 

I believe the only way to do this via the API is to:  

  1. POST to /#account_id/members to bulk add/update users & set their fields (ex: name)
  2. That returns an import id. We have to use the GET /#account_id/members/imports/#import_id api endpoint to check & wait for the import to finish. 
  3. Once the import is finished, to sync the groups (we have about 4 groups that we sync between our database & emma), we have to: 
  4. For each group, remove the users from all groups using the PUT /#account_id/groups/#member_group_id/members/remove api. 
  5. Then add the users back to each group using the PUT /#account_id/groups/#member_group_id/members api. 

My questions are: 
  1. Is this the only way to update both fields and group preferences in bulk?
  2. Are there any limits on how many users I can bulk add/update and how many users I can bulk add/remove from groups in a single api call?
  3. Approximately how long should I expect the import to take?
  4. Is there any way via the API to bulk fetch user fields and group preferences so that I can verify the results of these api calls? 
Photo of charity: water

charity: water

  • 2 Posts
  • 0 Reply Likes

Posted 2 years ago

  • 0
  • 1
Photo of Kyle Gregory | Lipscomb University

Kyle Gregory | Lipscomb University, Champion

  • 99 Posts
  • 69 Reply Likes
Hey there,

That's a pretty nice workflow. I think you're on track, but if I'm following your proposed workflow, I would recommend the following changes:
  1. If your groups should be cleaned out before each "bulk" import, then I would run that first, before doing the import step. DELETE /#account_id/groups/#member_group_id/members
  2. If any additional fields need to added to the account, do this next before the import step. POST /#account_id/fields
  3. Then in your bulk import, you can add the member data (fields in the members array) and set the groups (group_ids array) during the import phase. POST /#account_id/members
Given the above to help answer your questions:
  1. Yes, the bulk import can do this in the members array and group ids array. See #3 above.
  2. No, I don't believe there are any limits to bulk import. Clearing the group out is a single call as well.
  3. Depends on the number of members. So you'll need to build in a call to periodically check for the import process to complete.
  4. You could build in a spot check, if you knew some of the member ids of your import by checking the affected members GET /#account_id/members/imports/#import_id/members, then you would check the field records GET /#account_id/members/#member_id and groups that they belong to GET /#account_id/members/#member_id/groups.
Hope that helps get you in the right direction,
Photo of Ross Cochran

Ross Cochran, Official Rep

  • 134 Posts
  • 10 Reply Likes
I think Kyle answered this one better than I could have. Look over his answer, and if you have additional questions, don't hesitate to ask. I did also want to add this link:

This will give you the full documentation on the call needed to bulk import.