# Create-User via REST-API, does not seem to be working

**URL:** https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112
**Category:** Support
**Created:** [February 28, 2025, 10:16pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112 "2025-02-28T22:16:29Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hat\_trick](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@hat\_trick](https://meta.discourse.org/u/hat_trick)
#### Post date: [February 28, 2025, 10:16pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/1 "2025-02-28T22:16:29Z")

</div>

Hi,

I created a new user using the REST API.

But I am unable to login with the new user credentials. When I search the users table, I cannot find the user account.

To troubleshoot the problem, I ran the following CURL cmd.

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/2/4/324f96a2206ecb864be71225c3887204c981a809.png)

I also tried using a JSON payload with the CURL cmd.

I get the same result both times: I cannot login using the new user credentials and the new user is not found in the users table.

Any ideas?

Thanks

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [February 28, 2025, 10:33pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/2 "2025-02-28T22:33:33Z")

</div>

The message here is somewhat misleading; `active:false` indicates the user was not created but already existed.

Check to ensure there isn’t already a user with the same email address, especially if `normalize_emails` is enabled.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 1, 2025, 12:08am UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/3 "2025-03-01T00:08:15Z")

</div>

Seems similar to [User creation API: ‘active’ attribute set to True but returns False in response](https://meta.discourse.org/t/user-creation-api-active-attribute-set-to-true-but-returns-false-in-response/344908)

> [@User creation API: ‘active’ attribute set to True but returns False in response](https://meta.discourse.org/t/user-creation-api-active-attribute-set-to-true-but-returns-false-in-response/344908/10):
>
> Yes, it seems that the reason for the failure was the flag `normalize_email:true` it’s true by default. As I turned it off the users got created… However, the API is not considering the `normalize_emails` flag and is returning success eventhough the user never got created or activated for that matter

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 3, 2025, 7:53am UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/7 "2025-03-03T07:53:13Z")

</div>

I realised that there is an error in our API docs. The `active` param is only permitted when an API key associated to an admin user is used and has been [the case since 2016](https://github.com/discourse/discourse/commit/429f27ec96c090d9054c498263f0cb635b665d99).

For now, I’ve corrected the docs in

[https://github.com/discourse/discourse/pull/31578](https://github.com/discourse/discourse/pull/31578)

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [March 3, 2025, 4:03pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/8 "2025-03-03T16:03:52Z")

</div>

This will help, yeah.

It still doesn’t address the original problem of the message being misleading for admins though.

```plaintext
○ → curl -X POST -H "api-key: $API_KEY" -H 'api-username: michael' https://try.discourse.org/users.json --json "$(jo email=michael+test@contoso.com username=michaeltest password=$PASSWORD active=true approved=true)"
{"success":true,"active":true,"message":"Your account is activated and ready to use."}

○ → curl -X POST -H "api-key: $API_KEY" -H 'api-username: michael' https://try.discourse.org/users.json --json "$(jo email=michael+test2@contoso.com username=michaeltest2 password=$PASSWORD active=true approved=true)"
{"success":true,"active":false,"message":"Your account is activated and ready to use."}

```

^ only a single user was created above

I’m _inferring_ a lot of obfuscation was put into the `/users.json` path to deter spammers etc. but this seems to be making things difficult for admins as well. I wonder if we should add an explicit admin path to separate the two (normal account creation vs. admin account creation) which will allow the admin function to be unobfuscated.

---

<div class="post-metadata">

### Author: ![hat\_trick](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@hat\_trick](https://meta.discourse.org/u/hat_trick)
#### Post date: [March 3, 2025, 11:37pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/9 "2025-03-03T23:37:10Z")

</div>

> [@supermathie](#):
>
> Check to ensure there isn’t already a user with the same email address, especially if `normalize_emails` is enabled.

You are correct. This was the problem: A user with the same email address already exists.

I was searching by username and by created\_at desc, which was why the new user didn’t come up in the search results.

The successful response threw me off.

Thank you for your help.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 2, 2025, 11:37pm UTC](https://meta.discourse.org/t/create-user-via-rest-api-does-not-seem-to-be-working/355112/10 "2025-04-02T23:37:58Z")

</div>

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