# New users via API if allow new unchecked

**URL:** https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103
**Category:** Development
**Created:** [November 30, 2017, 6:10pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103 "2017-11-30T18:10:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Martyr2](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Martyr2](https://meta.discourse.org/u/Martyr2)
#### Post date: [November 30, 2017, 6:10pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/1 "2017-11-30T18:10:08Z")

</div>

Hello, I was attempting to setup a new user via the API when I received an error back saying that our hosted version of discourse does “not allow new users at this time”. I discovered that the “allow new registrations” checkbox in the settings section is unchecked.

Was there a way to get around that, other than enabling the checkbox, to have new users created via the API? Something like an override or “force” flag? I am not using “approved”. Will that do what I need or is there something perhaps undocumented? I figure that if I am supplying an API key and API User that is valid, that obviously it is me who is wanting to override that feature.

Thanks!

---

<div class="post-metadata">

### Author: ![Martyr2](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Martyr2](https://meta.discourse.org/u/Martyr2)
#### Post date: [November 30, 2017, 6:56pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/4 "2017-11-30T18:56:43Z")

</div>

I have not withdrawn the post. Just looking for an answer is all. 🙂

---

<div class="post-metadata">

### Author: ![Martyr2](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Martyr2](https://meta.discourse.org/u/Martyr2)
#### Post date: [November 30, 2017, 9:02pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/5 "2017-11-30T21:02:33Z")

</div>

So I ran a test to see if in fact that setting is the problem and enabled the checkbox to “allow new registrations” and then ran the exact same request and was able to get working. I guess now the question is, is there a way to force a new user being created via the API with that checkbox disabled?

Surely someone has run into something similar where they don’t want just anyone to create an account, but need to be able to create accounts after being fully vetted through some application.

---

<div class="post-metadata">

### Author: ![naomi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/naomi/32/120507_2.png) [@naomi](https://meta.discourse.org/u/naomi)
#### Post date: [December 1, 2017, 2:51am UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/6 "2017-12-01T02:51:53Z")

</div>

Did you try setting the checkbox to ‘allow new registrations’ but also setting the ‘invite only’ checkbox?

---

<div class="post-metadata">

### Author: ![Martyr2](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Martyr2](https://meta.discourse.org/u/Martyr2)
#### Post date: [December 1, 2017, 5:23pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/7 "2017-12-01T17:23:11Z")

</div>

Interesting idea naomi, we have single sign on enabled so I am not sure if the invite only is going to play nice with it. I don’t want invite buttons to pop up everywhere or our support admins to think they need to invite people.

I guess ultimately all I am looking to do is have an SSO implementation (as we have now) with the option to push user accounts into discourse when they sign up or login on the main site. I don’t want them to leave our main site and go to the discourse site and hit “sign in” to have that information “sucked” over and created in discourse.

Does anyone else think that allow new registrations with invite only would work in SSO? I would love to get more thoughts. 🙂

---

<div class="post-metadata">

### Author: ![naomi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/naomi/32/120507_2.png) [@naomi](https://meta.discourse.org/u/naomi)
#### Post date: [December 1, 2017, 6:19pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/8 "2017-12-01T18:19:15Z")

</div>

I have SSO as well 🙂 You asked about creating new users via an API call, though, without having just anyone able to create an account. And in that case, you should try my solution.

> [@Martyr2](#):
>
> I don’t want invite buttons to pop up everywhere or our support admins to think they need to invite people

Invite buttons don’t show when SSO is enabled ([Source](https://meta.discourse.org/t/sso-and-invites/40008/2)).

> [@Martyr2](#):
>
> I guess ultimately all I am looking to do is have an SSO implementation (as we have now) with the option to push user accounts into discourse when they sign up or login on the main site

If you have SSO, you don’t need to create users via the API as a correct SSO implementation does it for you ([Source](https://github.com/discourse/discourse/blob/master/app/models/discourse_single_sign_on.rb)).

> [@Martyr2](#):
>
> I don’t want them to leave our main site and go to the discourse site and hit “sign in” to have that information “sucked” over and created in discourse.

When you use a separate site as the SSO provider, Discourse will know if they are already logged in and won’t prompt them to sign in again

Here’s one of the resources I used for learning more about how SSO works:

> [@Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045):
>
> [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) is a core Discourse feature that allows you to configure “Single Sign-On (SSO)” to completely outsource all user registration and login from Discourse to another site. Offered to our [pro, business and enterprise hosting customers](https://discourse.org/pricing). information_source (Feb 2021) ‘[Discourse SSO](https://meta.discourse.org/t/13045?silent=true)’ is now ‘[DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)’. If you are running an old version of Discourse, the settings below will be named sso\_... rather than discourse\_connect\_... The Problem Many sites wishing to integrate wit…

> [@Martyr2](#):
>
> Does anyone else think that allow new registrations with invite only would work in SSO?

Why not just try it and see if it works for you? 🙂

---

<div class="post-metadata">

### Author: ![Martyr2](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Martyr2](https://meta.discourse.org/u/Martyr2)
#### Post date: [December 1, 2017, 6:36pm UTC](https://meta.discourse.org/t/new-users-via-api-if-allow-new-unchecked/75103/9 "2017-12-01T18:36:40Z")

</div>

Thanks again naomi, that is very useful information. I understand that SSO will create the accounts for me, but we are going to need to have those accounts exist in Discourse prior to the user visiting our Discourse site. Based on what I have seen that those accounts are only created when they visit the site and click sign in. At that point it will create the account if it doesn’t already exist using the info from our main site.

But based on what you have said I think it might be enough to implement what we are looking to do. 🙂
