The KeyCloak REST API only allows mass insertion of the users at the Realm initialization time.
Creating users on the REST API is pretty well documented, but painful enough that it took a couple of hours to muddle through the reqired options to make this script do the right thing:
- Create the user
- Add them to a group
- Send the password (re)set email
The script reads email addresses from standard in, so you can use it like this:
echo "user@example.com" | bash create-users.sh
or, feed it with a file of email addresses one per line (assumes unix line endings):
cat all-the-new-users.txt | bash create-users.sh