Create users using API
A guide on how to create users with our 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).
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.
pip install requests
Source Code
If you wish to run the code locally, make sure you have a working runtime environment.
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': '[email protected]',
'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>.
Last updated