Users - Create
  • 22 Dec 2023
  • 1 Minute to read
  • Dark
    Light

Users - Create

  • Dark
    Light

Article summary

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
string

"Jane"

First Name

surname
string

"Smith"

Last Name

email
string

"test@cogniac.co"

Email address used for logging into the Cogniac system.

password
string

"123ABCdef"

Can be modified, but not returned to user with GET calls.
 
Password Requirements
 Minimum Password Length: 8
 Maximum Password Length: 100
 Minimum Number Of Required Lowercase Characters: 1
 Minimum Number Of Required Numeric Characters: 1
 
 Symbol and Diacritic characters are allowed, but not required.

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?