# How to set the password when we create an user with an API call?

**URL:** <https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428>\
**Category:** Developers & API\
**Tags:** users, org, api\
**Created:** [April 6, 2017, 7:16am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428 "2017-04-06T07:16:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeromevi](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jeromevi](https://community.grafana.com/u/jeromevi)\
**Post date:** [April 6, 2017, 7:16am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/1 "2017-04-06T07:16:12Z")

</div>

Hi,  
I’m actually trying to create user with the API and I figured out that we can’t set the password in the call ?

> POST /api/org/users HTTP/1.1  
> Accept: application/json  
> Content-Type: application/json  
> Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

> {  
> “role”: “Admin”,  
> “loginOrEmail”: “admin”  
> }

So how can the user login without password ? Is it a default password ? Should I make an other call to change the password of this user ?

Thank you for the help

---

<div class="post-metadata">

**Author:** ![torkel](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/torkel/32/20_2.png) [@torkel](https://community.grafana.com/u/torkel)\
**Post date:** [April 6, 2017, 7:23am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/2 "2017-04-06T07:23:06Z")

</div>

The org api can only add existing users or create invites, not create new users.

To create a new user you need to use the admin api:  
[http://docs.grafana.org/http\_api/admin/#global-users](http://docs.grafana.org/http_api/admin/#global-users)

---

<div class="post-metadata">

**Author:** ![jeromevi](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jeromevi](https://community.grafana.com/u/jeromevi)\
**Post date:** [April 6, 2017, 7:56am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/3 "2017-04-06T07:56:42Z")

</div>

Hi @torkel,  
and to get all the users, I can only do `GET grafana_url/api/org/users` right ?

Or I’m missing a method somewhere ?

and I get the error “403 permission denied” with the call to add the user, maybe you can figure out what is wrong in my JS call ?

```
    HTTP.call("POST", "http://grafana.staged-by-discourse.com/api/admin/users", {
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    'Authorization': APIKEY_ADMIN,
                },
                data: {
                    "name":name,
                    "email":"",
                    "login":name,
                    "password":"userpassword",
                }
            }

```

where APIKEY\_ADMIN is something like Bearer xxxxx

---

<div class="post-metadata">

**Author:** ![torkel](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/torkel/32/20_2.png) [@torkel](https://community.grafana.com/u/torkel)\
**Post date:** [April 6, 2017, 8:41am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/4 "2017-04-06T08:41:19Z")

</div>

you cannot use an api key here, as you need a user with grafana admin permissions. Will have to use basic auth with a username/password that has Grafana Server Admin permission set.

---

<div class="post-metadata">

**Author:** ![jeromevi](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jeromevi](https://community.grafana.com/u/jeromevi)\
**Post date:** [April 6, 2017, 8:42am UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/5 "2017-04-06T08:42:08Z")

</div>

Perfect 🙂

And it’s right for the part where I want to get all the users ?

---

<div class="post-metadata">

**Author:** ![anon80964540](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@anon80964540](https://community.grafana.com/u/anon80964540)\
**Post date:** [January 13, 2021, 4:02pm UTC](https://community.grafana.com/t/how-to-set-the-password-when-we-create-an-user-with-an-api-call/428/6 "2021-01-13T16:02:17Z")

</div>


