Creating user via API

(Johnathan Nader) #1

Right now on my discourse set up, I have it set up to invite only, admin must approve users, and allow new registrations.

The issue I am having though is when I create a user via my API I still have to log in and approve the user on the forum.

So I was wondering if I had to uncheck any of those three to be able to make the user and they are auto created but I don’t have to log in to the discourse to approve them.

I don’t want other users to be able to invite other users to join though as I am creating users based on another sites sign ups.

(Blake Erickson) #2

Once you create the user through the API, you will need to make another api request to this endpoint to approve them:


Are you using the discourse_api gem to talk to the API or some other way?

(Johnathan Nader) #3

Thank you, I’m using pydiscourse. Didn’t know you could do approvals. I ended up having to tweak their wrapper to have it work. But now it’s working. Thank you

(Vikas) #4

Hello @blake,

Can you please give an example? I tried using this in vain.

curl -X PUT "http://localhost:3000/admin/users/batman/approve?api_key=<my_api_key>&api_username=vikas"

(Blake Erickson) #5

try using the <user_id> of the user instead of the username?

(Vikas) #6

Perfect, worked like a charm. I got confused it with username. Thanks much.

Now, the user gets an activation email which I want to avoid, will look around how to avoid that.

(Blake Erickson) #7

^ I think that might be how you can get around the activate email thing /shrug

(Travis) #8

Sorry to necro this post but it appears to be the most relevant discussion.

I’m currently adding users via the API but they aren’t getting the verification email. Is there something I can add to the response to ensure that this email gets triggered?

I’ve seen people setting active to true but that’s what I don’t want since I want them to be pruned if they never verify. Setting it to false doesn’t seem to trigger the activation email though.