curl --request POST \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"id": "1234567890"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstant.ly/openapi/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"id": 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()
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
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.konstant.ly/openapi/v1/users/blocked',
{ id: userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data;
} 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', '1234567890')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"id": "1234567890",
"name": "John Doe",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"email": "john.doe@example.com",
"isBanned": true,
"role": {
"alias": "learner"
},
"fromApi": false,
"image": null
}
{
"status": 404,
"message": "Not found"
}
{
"status": 422,
"message": "User cannot be banned because he/she is assigned as expert at courses",
"data": {
"courses": [
{
"id": 123,
"name": "Course name",
"expertHomeworks": [...],
"expertClassworks": [...]
}
]
}
}
Users
Deactivate User
Deactivate (ban) a user account
POST
/
users
/
blocked
curl --request POST \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"id": "1234567890"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstant.ly/openapi/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"id": 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()
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
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.konstant.ly/openapi/v1/users/blocked',
{ id: userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data;
} 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', '1234567890')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"id": "1234567890",
"name": "John Doe",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"email": "john.doe@example.com",
"isBanned": true,
"role": {
"alias": "learner"
},
"fromApi": false,
"image": null
}
{
"status": 404,
"message": "Not found"
}
{
"status": 422,
"message": "User cannot be banned because he/she is assigned as expert at courses",
"data": {
"courses": [
{
"id": 123,
"name": "Course name",
"expertHomeworks": [...],
"expertClassworks": [...]
}
]
}
}
Deactivate a user account, preventing them from logging in. Deactivated users are not counted towards your license.
Request Headers
API Key. Go to your Konstantly site > Settings > API and copy the value from there.
Request Body
User API ID to deactivate
Response
Returns the user object withisBanned: true.
User ID
Full name
Interface language
Email address
Will be
true after deactivationUser role
API management status
Error Responses
curl --request POST \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/blocked' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"id": "1234567890"
}'
import requests
def deactivate_user(api_key: str, user_id: str) -> dict:
url = "https://YOURSITE.konstant.ly/openapi/v1/users/blocked"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
data = {"id": 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()
# Example usage
try:
user = deactivate_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
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.konstant.ly/openapi/v1/users/blocked',
{ id: userId },
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
return response.data;
} 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', '1234567890')
.then(user => {
console.log(`User ${user.name} has been deactivated`);
console.log(`isBanned: ${user.isBanned}`);
})
.catch(error => console.error('Failed:', error.message));
{
"id": "1234567890",
"name": "John Doe",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"email": "john.doe@example.com",
"isBanned": true,
"role": {
"alias": "learner"
},
"fromApi": false,
"image": null
}
{
"status": 404,
"message": "Not found"
}
{
"status": 422,
"message": "User cannot be banned because he/she is assigned as expert at courses",
"data": {
"courses": [
{
"id": 123,
"name": "Course name",
"expertHomeworks": [...],
"expertClassworks": [...]
}
]
}
}
Was this page helpful?
⌘I