I looked into this and the best way to create a “pre-activated” (ready to login) user account is to first create a user and activate it just after the user is created.
Here is how to do it via official discourse_api gem:
# create user
user = client.create_user(
name: "Bruce Wayne",
email: "bruce@wayne.com",
username: "batman",
password: "WhySoSerious"
)
# activate user
client.activate(user["user_id"])
Here is how to do it via cURL request:
# create user
curl -X POST --data "name=dave&username=dave&email=dave@example.com&password=daveIsAwesome&api_key=x1y2z3&api_username=xyz" http://discourse.example.com/users
# activate user
curl -X PUT "http://discourse.example.com/admin/users/{USER_ID}/activate.json?api_key=x1y2z3&api_username=xyz"