Create User API, force a password reset on account creation possible?

AI-generated summary

Create User API: Force Password Reset on Account Creation

Stigin is seeking advice on how to force a password reset email when creating a user via the Post /user.json endpoint. Currently, a password is required, but Stigin wants to automate the process of sending a “setup password” email to the user. They have tried using the “staged” option with a random password, but this doesn’t trigger the desired email. Alternative options include using the /forgot_password.json flow or the Invite API, but both have drawbacks. Stigin is looking for a solution that can be achieved through the /user.json API without requiring additional calls or logic.

Hi All,

Just working on some integration with Discourse’s API.

In terms of Creating a user, specifically under the Post /user.json endpoint, is there any way to force a password reset email as opposed to mandating a password input on calling that specific endpoint? I’ve tried using the “staged” option, with a random password at the time of calling the /user.json endpoint when creating the user in Discourse to try and prompt an email that would force the user to set a new password. the other option here is to call the /forgot_password.json flow as soon as I create the user but just wondering if it’s possible to do this in that /users.json api as opposed to calling an additional API. i.e. something that’s not currently documented such as adding “staged” to the body.

Obviously the other option here is to go with Invite API, but that in it self has issues as only 1 invite can be issued at once per user and i’m finding people are loosing the original email sent to them by discourse. This could be fixed by the expires_at just that’s not an ideal scenario as my web hook only fires once on an event and I would have to cater for additional logic here…

Essentially the use case i’m looking at is I want to create a user, have that email of the user be sent a “setup password” flow as my application is only a backend web hook and I can’t request the user to enter a password before it fires.

Any thoughts / opinions would be greatly appreciated. If the answer is one of the options above that’s totally fine just thought I’d check as it’s late here!

Cheers!

Any thoughts by anyone?