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

Users - Delete

  • Dark
    Light

Article summary

This endpoint will irrevocably remove a user from the Cogniac system. Only the given user or a tenant administrator can delete a user object.

Delete User ID

While the keyword 'current' is accepted in most tenant and user endpoints, when deleting tenants or users it is best practice to pass a valid ID to ensure the correct resources are being removed with the proper authentication.

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

Example: Delete a User

curl -X DELETE https://api.cogniac.io/1/users/2ke2daisdflkj \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"
import requests
import json
from pprint import pprint

url_prefix = 'https://api.cogniac.io'
api_version = "1"
user_id = '2ke2daisdflkj'
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}

url = f'{url_prefix}/{api_version}/users/{user_id}'
res = requests.delete(url, headers=headers)

if res.status_code == 204:
    print(f"Status code = {res.status_code}")
    print(f"User {user_id} was deleted successfully.")
else:
    print(f"Error: {res.status_code}, {res.text},{res.headers}")
HTTP 204 Code (with no body)


Was this article helpful?