# Disable account confirm emails when creating users via API

**URL:** https://meta.discourse.org/t/disable-account-confirm-emails-when-creating-users-via-api/68663
**Category:** Development
**Tags:** rest-api
**Created:** [8월 23, 2017, 11:18오후 UTC](https://meta.discourse.org/t/disable-account-confirm-emails-when-creating-users-via-api/68663 "2017-08-23T23:18:20Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![jeffbrowning](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jeffbrowning](https://meta.discourse.org/u/jeffbrowning)
#### Post date: [8월 24, 2017, 8:54오후 UTC](https://meta.discourse.org/t/disable-account-confirm-emails-when-creating-users-via-api/68663/11 "2017-08-24T20:54:33Z")

</div>

Correct. This is an API call. The data is:

```plaintext
data = {
        'api_key': settings.DISCOURSE_API_KEY,
        'api_username': settings.DISCOURSE_API_USERNAME,
        'name': 'foobar',
        'email':email,
        'password': password,
        'username': 'barbaz',
        'active': True,
        'approved': True
    }

```

I first tried just sending this API call:  
`first_res = requests.post('{base}/users.json'.format(base=settings.DISCOURSE_BASE_URL), data`

When I did this, my users were not active (despite the `active: True` in the `data` above).  
I then tried to activate them via the api:

```plaintext
data = {
        'api_key': settings.DISCOURSE_API_KEY,
        'api_username': settings.DISCOURSE_API_USERNAME,
    }
    requests.put('{base}/admin/users/{id}/activate'.format(
        base=settings.DISCOURSE_BASE_URL,
        id=json_response_content['user_id']
    ), data)

```

When I did this, the users were active, but the activation email was still being sent. I read here ([Creating Active Users via the API gem - #3 by MikeTaber](https://meta.discourse.org/t/creating-active-users-via-the-api-gem/33133/3)) That I should try deactivating the user and _then_ activating, so I tried that as well:

```plaintext
data = {
        'api_key': settings.DISCOURSE_API_KEY,
        'api_username': settings.DISCOURSE_API_USERNAME,
    }
    requests.put('{base}/admin/users/{id}/deactivate'.format(
        base=settings.DISCOURSE_BASE_URL,
        id=json_response_content['user_id']
    ), data)
    requests.put('{base}/admin/users/{id}/activate'.format(
        base=settings.DISCOURSE_BASE_URL,
        id=json_response_content['user_id']
    ), data)

```

I could not see any difference in behavior between this code and the previous version (creating the user, and then activating).

---

_[View the full topic](https://meta.discourse.org/t/disable-account-confirm-emails-when-creating-users-via-api/68663)._
