> For the complete documentation index, see [llms.txt](https://developers.neowit.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.neowit.io/tutorials/create-users-using-api.md).

# Create users using API

## Overview

This guide aims to provide the basic understanding and ability to add users to the Neowit platform using the API.

API Reference: <https://app.neowit.io/api/swagger/index.html#/user/post_user_v1_user>

## Prerequistes

To use this API you must have an access token to a principal that is an organization admin (see [REST API/Authentication](/rest-api/authentication/oauth2.md)).

## Example

The example code in this page is provided as is, it may not work in your environment and should be used as a quick guide for implementation rather than code to be used in a production environment.

### Environment Setup

The following packages are required by the example code and must be installed.

```bash
pip install requests
```

### Source Code

If you wish to run the code locally, make sure you have a working runtime environment.

```python
import requests # pip install requests

user_endpoint = 'https://app.neowit.io/api/user/v1/user'
token='' # add token here

def create_user(access_token):
    data = {
        'email':    'testuser321@contoso.com',
        'name':     'testuser321',
        'locale':   'en-US',
        'role':     'ROLE_MEMBER', # ROLE_MEMBER or ROLE_ADMIN
        'timezone': 'Europe/Oslo',
        'idpId':    '', # blank if username/password
    }

    return requests.post(
        url=user_endpoint,
        headers={
            'Authorization': 'Bearer ' + access_token,
            'Content-Type':  'application/json',
        },
        json=data,
    )
    
def main():
    print(create_user(token).json())

if __name__ == '__main__':
    main()
```

### Customizing user authentication

If you wish to add a specific Idp you can go to <https://app.neowit.io/settings/idps> then select your Idp and get the ID from the URL, it will have the following format <https://app.neowit.io/settings/idps/edit/>*\<ID>.*
