# Creating and activating users from the API

**URL:** https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124
**Category:** Development
**Created:** [August 26, 2020, 12:15pm UTC](https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124 "2020-08-26T12:15:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yerttle](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yerttle](https://meta.discourse.org/u/yerttle)
#### Post date: [August 26, 2020, 12:15pm UTC](https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124/1 "2020-08-26T12:15:22Z")

</div>

Hi there, we are using version 2.5.0.beta3 and are having some problems creating a user via the API.

We would like to create a user and be able to post a topic straight away using the API without them having to click the confirmation link in the email.

We have tweaked the Active flag in various ways when creating a user but cannot seem to remove the need for the confirmation email.

`{"errors":["You are not permitted to view the requested resource."],"error_type":"invalid_access"}`

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 27, 2020, 11:05pm UTC](https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124/2 "2020-08-27T23:05:31Z")

</div>

It looks like 2.5.0.beta3 was released on [April 22, 2020](https://github.com/discourse/discourse/tags?after=v2.4.4) and the fix I made for [this issue](https://meta.discourse.org/t/creating-active-users-via-the-api-gem/33133/43) was released on [April 14, 2020](https://github.com/discourse/discourse/commit/fec68d3d25bfc80d084af52e17882ad886fd5cd0) so you should be able to create an active user via the API with a single request.

Can you verify your requests and response look similar to this curl command:

```plaintext
curl -i -sS -X POST "http://localhost:3000/users" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 079fb2bb12d3b436bb11bde8eb58aaa9a36560fa7d79b14b3087aa40b1ebc2c4" \
-H "Api-Username: blake.erickson" \
-F "name=8fe87241ca91a69f5ccd" \
-F "username=8fe87241ca91a69f5ccd" \
-F "email=8fe87241ca91a69f5ccd@example.com" \
-F "password=c9193506a8f5e402a88cf2f8cee3f258" \
-F "active=true" \
-F "approved=true"

HTTP/1.1 200 OK

{
  "success": true,
  "active": true,
  "message": "Your account is activated and ready to use.",
  "user_id": 10
}

```

---

<div class="post-metadata">

### Author: ![yerttle](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yerttle](https://meta.discourse.org/u/yerttle)
#### Post date: [September 16, 2020, 9:52am UTC](https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124/3 "2020-09-16T09:52:36Z")

</div>

Tried the curl command and the response shows user is not active. The message says the user will be activated through email.

```plaintext
C:\Windows\system32>curl -i -sS -X POST https://our-discourse-host/users -H "Content-Type: multipart/form-data;" -H "Api-Key: The-API-key" -H "Api-Username: The-username" -F "name=8fe87241ca91a69f5ccd" -F "username=8fe87241ca91a69f5ccd" -F "email=8fe87241ca91a69f5ccd@testemail.test" -F "password=c9193506a8f5e402a88cf2f8cee3f258" -F "active=true" -F "approved=true"

```

```plaintext
HTTP/1.1 200 OK
{
"success":true,
"active":false,
"message":"\u003cp\u003eYouΓÇÖre almost done! We sent an activation mail to \u003cb\u003e8fe87241ca91a69f5ccd@testemail.test\u003c/b\u003e. Please follow the instructions in the mail to activate your account.\u003c/p\u003e\u003cp\u003eIf it doesnΓÇÖt arrive, check your spam folder.\u003c/p\u003e",
"user_id":13
}

```

---

<div class="post-metadata">

### Author: ![yerttle](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yerttle](https://meta.discourse.org/u/yerttle)
#### Post date: [September 21, 2020, 8:46am UTC](https://meta.discourse.org/t/creating-and-activating-users-from-the-api/162124/4 "2020-09-21T08:46:49Z")

</div>

@blake Could you please check post #3 and let me know if I am missing anything in there?
