Creating users with the Connect API

Hello, I'm trying to do something similar to this post where I automatically create users from a list of users in another environment. I'm currently testing with my own ID which does not exist in the new env yet. When I the post I get a 400 response but the user never shows up in the user list in connect.

        add_headers(Authorization = "api_key"),
        body = list(username = testuser, 
                    first_name =  test, 
                    last_name = user, 
                    user_must_set_password =  TRUE,
                    email =, 
        encode = "json"

Response []
  Date: 2020-03-13 14:24
  Status: 400
  Content-Type: application/json
  Size: 113 B

We're running our connect instance inside a docker container on load balanced servers, not sure if that changes whether or not the api will work? I've tried removing the "user_must_set_password" option and the encode json option, I still get a 400 response with no change in the user list. Maybe I need an addition parameter? Thank you in advance for thoughts!


I actually figured out one of my issues, I did not have the authorization api key string correct, I changed it to the following.

Authorization = paste("Key", apiKeyProd))

I'm now able to create users but the user does not get an email to reset their password so my current option is to manually send each of our ~150 users the pw reset link from the console. Manually it will take maybe an hour but I'm wondering if there's a simple fix to get the emails to send when the account it created. Anything I'm missing? Thank you!

Well yet again I solved my own problem it looks like the email SMTP provider is not setup in our new environment. We had set it up in the console in earlier versions but this did not get copied to production. Unfortunate that is no longer accessible, it would save me a huge headache of manually email everyone.

1 Like

Well done figuring this out @hlendway! Just FYI, there is an R package that could make some of these API interactions a bit easier:

When the API was created, we did not have the notion of "copying the link from the console." I think you are spot on that this should be cleaned up within the API in order to make user management easier. Apologies for the trouble! I will add the feedback to our product tracking so that we can improve this! Please let us know if you have any additional feedback or questions that we can help with!

1 Like

Oops, also - one more thing. The SMTP configuration is now done inside of the configuration file.

Although losing the ability to configure inside of the UI is an admitted loss, it was done in order to maintain consistency with the rest of the product. Many strange things were required in Connect in order to have email be the "one thing" that can be configured inside of the product. We hope to bring back a more comprehensive approach to UI configuration in the future :smile:

EDIT: And one more thing. Are you using Password Auth for this server, I suppose? Usually user confirmation / password setting is not required when using LDAP, SAML, etc. as authentication providers.

1 Like

Hi @cole, sorry for a delayed response, we are using password auth so that's why I needed the SMTP. I ended up manually sending out ~125 emails but it wasn't too bad. We also got our SMTP configured a couple days later but some folks couldn't wait for access.
I have now used the connect api to lock all our users out of the old environment so the connectapi package has been useful, thank you for your comments, I will let you know if I think of any other feedback for the api. Always appreciate the help!


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.