Users - Update
  • 06 Feb 2024
  • 1 Minute to read
  • Dark
    Light

Users - Update

  • Dark
    Light

Article summary

With the update Users endpoint, Cogniac users may update their own User object data. Currently, users can only update name fields. For additional user account changes, please contact Cogniac support.

Field

Example

Definition

user_id string

"2ke2daisdflkj"

The ID of the user to be updated.    Users can only change their own user data.

POST /1/users/{user_id}
Host: https://api.cogniac.io

Example: Update a User with the 'current' Identifier

curl -X POST https://api.cogniac.io/1/users/current \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d \
'{
  "surname":"Patterson"
}'
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 = {
  "surname":"Patterson"
  }

url = f'{url_prefix}/{api_version}/users/current'
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},{res.headers}")
{
   "created_at" : 1670446838.80874,
   "email" : "test@cogniac.co",
   "first_login" : false,
   "given_name" : "Patterson",
   "machine_user" : false,
   "modified_at" : 1701889815.41249,
   "password_modified_at" : 1701889815.41249,
   "realm_id" : null,
   "status" : "ENABLED",
   "surname" : "Patterson",
   "user_id" : "2ke2daisdflkj"
}


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence