Users - Create
- 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
Users - Create
- Updated on 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
The create User endpoint allows existing Cogniac users to create new users within their authenticated tenant.
To create a new user, the following fields should be passed:
Name | Example | Description |
---|---|---|
given_name | "Jane" | First Name |
surname | "Smith" | Last Name |
email | "test@cogniac.co" | Email address used for logging into the Cogniac system. |
password | "123ABCdef" | Can be modified, but not returned to user with GET calls. |
POST /1/users
Host: https://api.cogniac.io
Example: Creating a New User
curl -X POST https://api.cogniac.io/1/users \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d \
'{
"given_name":"Jane",
"surname":"Smith",
"email":"test@cogniac.co",
"password": "MySecurePassW@rd123"
}'
import requests
import json
from pprint import pprint
url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = '' # add your token here
headers = {'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'}
user_data = {
"given_name":"Jane",
"surname":"Smith",
"email":"test@cogniac.co",
"password": "MySecurePassW@rd123"
}
url = f'{url_prefix}/{api_version}/users'
res = requests.post(url, json=user_data, headers=headers)
if res.status_code == 200:
response_data = json.loads(res.content)
pprint(response_data)
else:
print(f"Error: {res.status_code}, {res.text}")
{
"user_id": "2ke2daisdflkj",
"given_name":"Jane",
"surname":"Smith",
"status":"ENABLED",
"email":"test@cogniac.co",
"tenant_id": "pipoyp63lqc7",
"tenant_name": "Jane Smith Tenant",
"tenant_type": "usertenant",
"created_at": 1508431720,
"modified_at": 1508431720
}
Was this article helpful?