# How to create the first admin user through rest api

**URL:** <https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647>\
**Category:** Troubleshooting\
**Created:** [April 30, 2020, 4:55am UTC](https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647 "2020-04-30T04:55:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsadkan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/tsadkan/32/3770_2.png) [@tsadkan](https://forum.mattermost.com/u/tsadkan)\
**Post date:** [April 30, 2020, 4:55am UTC](https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647/1 "2020-04-30T04:55:14Z")

</div>

I have an application to integrate with mattermost. But the mattermost server is not accessible publicly. Since I cannot open the mattermost application on the browser, I was finding a solution to create the first admin user through rest API call or if there is some preconfiguration to do so.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [April 30, 2020, 7:45am UTC](https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647/2 "2020-04-30T07:45:45Z")

</div>

Hello, @tsadkan

The easiest way to do this is to [create user via API](https://api.mattermost.com/#tag/users/paths/~1users/post) and then promote the user to system admin via [mattermost roles system\_admin](https://docs.mattermost.com/administration/command-line-tools.html#mattermost-roles-system-admin) CLI.

However, you mentioned this:

> [@tsadkan](#):
>
> But the mattermost server is not accessible publicly. Since I cannot open the mattermost application on the browser

What is the error that you are getting when you are trying to reach the Mattermost server via UI? What is the output of running `echo | telnet <mattermost_url> 443` if the instance is set up via TLS? I am concerned that the API will just fail if you cannot even reach to Mattermost in the first place.

Since the Mattermost Server access is an issue, may I know if you have also reached out to the existing System Administrator(s) to assist with this process as it will be a lot faster if they can do it from their end?

---

<div class="post-metadata">

**Author:** ![tsadkan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/tsadkan/32/3770_2.png) [@tsadkan](https://forum.mattermost.com/u/tsadkan)\
**Post date:** [April 30, 2020, 8:10am UTC](https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647/3 "2020-04-30T08:10:27Z")

</div>

Hello @ahmaddanial,  
It is due to my architecture. Which doesn’t allow Mattemost server to be publicly accessible. We are planning to access the mattermost server through an other server as a proxy.

> [@ahmaddanial](#):
>
> The easiest way to do this is to [create user via API](https://api.mattermost.com/#tag/users/paths/~1users/post) and then promote the user to system admin via [mattermost roles system\_admin](https://docs.mattermost.com/administration/command-line-tools.html#mattermost-roles-system-admin) CLI.

I know I can create a user through the api but by default the open user creation is not allowed. To update this “Enable open server” config, we can use the rest API but the request needs authorization which I don’t have at first.

So, my question is how to create the first admin through rest API request, If that makes sense.

---

<div class="post-metadata">

**Author:** ![jesse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jesse/32/5168_2.png) [@jesse](https://forum.mattermost.com/u/jesse)\
**Post date:** [April 30, 2020, 6:49pm UTC](https://forum.mattermost.com/t/how-to-create-the-first-admin-user-through-rest-api/9647/4 "2020-04-30T18:49:59Z")

</div>

@tsadkan, from the sounds of it, you will have to create the first user via the CLI, having direct access to the Mattermost server itself. Creating the “first” user through the REST API requires enable sign-up with email, enable user creation, and an open server in order to use the REST API (or, equivalently, the web browser).
