# Pre-create user accounts for SSO users

**URL:** https://meta.discourse.org/t/pre-create-user-accounts-for-sso-users/139103
**Category:** SSO
**Created:** [January 19, 2020, 5:41pm UTC](https://meta.discourse.org/t/pre-create-user-accounts-for-sso-users/139103 "2020-01-19T17:41:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Judith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/judith/32/289903_2.png) [@Judith](https://meta.discourse.org/u/Judith)
#### Post date: [January 19, 2020, 5:41pm UTC](https://meta.discourse.org/t/pre-create-user-accounts-for-sso-users/139103/1 "2020-01-19T17:41:23Z")

</div>

I am happily using SSO and the Discourse API on my site. I now want to extend it much further, by enabling all my existing Groups to have a private subforum within my Discourse forum (I [have just written](https://meta.discourse.org/t/providing-restricted-subforums-for-external-groups/139107) a howto about that, since most of the API involved is poorly documented). This however raises the problem that not all of my users have logged into the forum so far, and login is exclusively via SSO, so it is likely that some Group members don’t have forum names. In order to nevertheless be able to assign them to a certain forum group, I’d like to pre-create their user accounts. How do I do that? I mean, there is an API for creating Discourse users, but how would I ensure that, if I create an account for Mark, that when Mark eventually signs into the forum, the SSO signs him into the account that I created for him and not a new one? Thanks!

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [January 19, 2020, 6:31pm UTC](https://meta.discourse.org/t/pre-create-user-accounts-for-sso-users/139103/2 "2020-01-19T18:31:59Z")

</div>

SSO users are matched by external\_id and if that does not exist or match, by email address.

So if you make sure that one of those (preferably the external\_id) matches, you’ll be alright.

---

<div class="post-metadata">

### Author: ![Judith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/judith/32/289903_2.png) [@Judith](https://meta.discourse.org/u/Judith)
#### Post date: [January 20, 2020, 3:09pm UTC](https://meta.discourse.org/t/pre-create-user-accounts-for-sso-users/139103/3 "2020-01-20T15:09:54Z")

</div>

Turns out that the POST /users path was impossible and I needed [Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-sso-user-data-with-the-sync-sso-route/84398) which is quite a bit more complicated, for no good reason. Anyway it’s done.
