curl --request POST \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"userId": "emp-1042"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstantly.ai/api/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"userId": user_id}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
if response.status_code == 422:
error_data = response.json()
raise ValueError(f"Cannot deactivate user: {error_data['message']}")
response.raise_for_status()
return response.json()["user"]
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "emp-1042")
print(f"User {user['name']} has been deactivated")
print(f"isBanned: {user['isBanned']}")
except Exception as e:
print(f"Failed to deactivate user: {str(e)}")
const axios = require('axios');
async function deactivateUser(apiKey, userId) {
try {
const response = await axios.post(
'https://YOURSITE.konstantly.ai/api/v1/users/blocked',
{ userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data.user;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
if (error.response?.status === 422) {
throw new Error(`Cannot deactivate: ${error.response.data.message}`);
}
throw error;
}
}
// Example usage
deactivateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', 'emp-1042')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"user": {
"id": "emp-1042",
"name": "John Doe",
"email": "john.doe@example.com",
"language": null,
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": true,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": null,
"image": null
}
}
{
"status": 404,
"message": "User not found"
}
{
"status": 422,
"message": "User cannot be banned because they are assigned as expert"
}
Users
Deactivate User
Deactivate (ban) a user account
POST
/
users
/
blocked
curl --request POST \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"userId": "emp-1042"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstantly.ai/api/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"userId": user_id}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
if response.status_code == 422:
error_data = response.json()
raise ValueError(f"Cannot deactivate user: {error_data['message']}")
response.raise_for_status()
return response.json()["user"]
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "emp-1042")
print(f"User {user['name']} has been deactivated")
print(f"isBanned: {user['isBanned']}")
except Exception as e:
print(f"Failed to deactivate user: {str(e)}")
const axios = require('axios');
async function deactivateUser(apiKey, userId) {
try {
const response = await axios.post(
'https://YOURSITE.konstantly.ai/api/v1/users/blocked',
{ userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data.user;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
if (error.response?.status === 422) {
throw new Error(`Cannot deactivate: ${error.response.data.message}`);
}
throw error;
}
}
// Example usage
deactivateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', 'emp-1042')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"user": {
"id": "emp-1042",
"name": "John Doe",
"email": "john.doe@example.com",
"language": null,
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": true,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": null,
"image": null
}
}
{
"status": 404,
"message": "User not found"
}
{
"status": 422,
"message": "User cannot be banned because they are assigned as expert"
}
Deactivate a user account, preventing them from logging in and ending their active sessions. Deactivated users are not counted towards your license. The workspace owner cannot be deactivated.
Request Headers
Request Body
User ID to deactivate: your own user ID or the Konstantly user ID (see User IDs)
Response
Returns the user object, withisBanned: true, in user.
The deactivated user
Show User object properties
Show User object properties
Error Responses
curl --request POST \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"userId": "emp-1042"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstantly.ai/api/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"userId": user_id}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
if response.status_code == 422:
error_data = response.json()
raise ValueError(f"Cannot deactivate user: {error_data['message']}")
response.raise_for_status()
return response.json()["user"]
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "emp-1042")
print(f"User {user['name']} has been deactivated")
print(f"isBanned: {user['isBanned']}")
except Exception as e:
print(f"Failed to deactivate user: {str(e)}")
const axios = require('axios');
async function deactivateUser(apiKey, userId) {
try {
const response = await axios.post(
'https://YOURSITE.konstantly.ai/api/v1/users/blocked',
{ userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data.user;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
if (error.response?.status === 422) {
throw new Error(`Cannot deactivate: ${error.response.data.message}`);
}
throw error;
}
}
// Example usage
deactivateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', 'emp-1042')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"user": {
"id": "emp-1042",
"name": "John Doe",
"email": "john.doe@example.com",
"language": null,
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": true,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": null,
"image": null
}
}
{
"status": 404,
"message": "User not found"
}
{
"status": 422,
"message": "User cannot be banned because they are assigned as expert"
}
Was this page helpful?