curl --request PATCH \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I'\''ve transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}'
import requests
def update_user(api_key: str, user_id: str, update_data: dict) -> None:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
response = requests.patch(url, headers=headers, json=update_data)
if response.status_code == 400:
error_data = response.json()
print("Validation errors:")
for field, errors in error_data.get('errors', {}).items():
print(f"{field}: {', '.join(errors)}")
raise ValueError(error_data.get('message', 'Invalid request'))
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
# Example usage
update_data = {
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I've transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}
try:
update_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890", update_data)
print("User updated successfully")
except Exception as e:
print(f"Failed to update user: {str(e)}")
const axios = require('axios');
async function updateUser(apiKey, userId, updateData) {
try {
await axios.patch(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}`,
updateData,
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
} catch (error) {
if (error.response?.status === 400) {
console.error('Validation errors:');
const errors = error.response.data.errors || {};
Object.entries(errors).forEach(([field, messages]) => {
console.error(`${field}: ${messages.join(', ')}`);
});
throw new Error(error.response.data.message || 'Invalid request');
}
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
const updateData = {
email: "j.wunderliebb@mycompany.tld",
bio: "An updated information about me: I've transferred to London!",
occupation: "Associate",
location: "London",
timezone: "Europe/London"
};
updateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890', updateData)
.then(() => console.log('User updated successfully'))
.catch(error => console.error('Failed to update user:', error.message));
{
"status": 400,
"message": "Validation failed",
"errors": {
"email": ["Invalid email format"]
}
}
{
"status": 404,
"message": "Not found"
}
Users
Update User
Edit user’s personal information
PATCH
/
users
/
{userId}
curl --request PATCH \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I'\''ve transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}'
import requests
def update_user(api_key: str, user_id: str, update_data: dict) -> None:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
response = requests.patch(url, headers=headers, json=update_data)
if response.status_code == 400:
error_data = response.json()
print("Validation errors:")
for field, errors in error_data.get('errors', {}).items():
print(f"{field}: {', '.join(errors)}")
raise ValueError(error_data.get('message', 'Invalid request'))
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
# Example usage
update_data = {
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I've transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}
try:
update_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890", update_data)
print("User updated successfully")
except Exception as e:
print(f"Failed to update user: {str(e)}")
const axios = require('axios');
async function updateUser(apiKey, userId, updateData) {
try {
await axios.patch(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}`,
updateData,
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
} catch (error) {
if (error.response?.status === 400) {
console.error('Validation errors:');
const errors = error.response.data.errors || {};
Object.entries(errors).forEach(([field, messages]) => {
console.error(`${field}: ${messages.join(', ')}`);
});
throw new Error(error.response.data.message || 'Invalid request');
}
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
const updateData = {
email: "j.wunderliebb@mycompany.tld",
bio: "An updated information about me: I've transferred to London!",
occupation: "Associate",
location: "London",
timezone: "Europe/London"
};
updateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890', updateData)
.then(() => console.log('User updated successfully'))
.catch(error => console.error('Failed to update user:', error.message));
{
"status": 400,
"message": "Validation failed",
"errors": {
"email": ["Invalid email format"]
}
}
{
"status": 404,
"message": "Not found"
}
Update an existing user’s information.
Request Headers
URL Parameters
Request Body
Response
On success, returns HTTP 200 status code.Error Responses
curl --request PATCH \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv' \
--header 'Content-Type: application/json' \
--data '{
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I'\''ve transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}'
import requests
def update_user(api_key: str, user_id: str, update_data: dict) -> None:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}"
headers = {
"X-API-KEY": api_key,
"Content-Type": "application/json"
}
response = requests.patch(url, headers=headers, json=update_data)
if response.status_code == 400:
error_data = response.json()
print("Validation errors:")
for field, errors in error_data.get('errors', {}).items():
print(f"{field}: {', '.join(errors)}")
raise ValueError(error_data.get('message', 'Invalid request'))
if response.status_code == 404:
raise ValueError(f"User {user_id} not found")
response.raise_for_status()
# Example usage
update_data = {
"email": "j.wunderliebb@mycompany.tld",
"bio": "An updated information about me: I've transferred to London!",
"occupation": "Associate",
"location": "London",
"timezone": "Europe/London"
}
try:
update_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890", update_data)
print("User updated successfully")
except Exception as e:
print(f"Failed to update user: {str(e)}")
const axios = require('axios');
async function updateUser(apiKey, userId, updateData) {
try {
await axios.patch(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}`,
updateData,
{
headers: {
'X-API-KEY': apiKey,
'Content-Type': 'application/json'
}
}
);
} catch (error) {
if (error.response?.status === 400) {
console.error('Validation errors:');
const errors = error.response.data.errors || {};
Object.entries(errors).forEach(([field, messages]) => {
console.error(`${field}: ${messages.join(', ')}`);
});
throw new Error(error.response.data.message || 'Invalid request');
}
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}
// Example usage
const updateData = {
email: "j.wunderliebb@mycompany.tld",
bio: "An updated information about me: I've transferred to London!",
occupation: "Associate",
location: "London",
timezone: "Europe/London"
};
updateUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890', updateData)
.then(() => console.log('User updated successfully'))
.catch(error => console.error('Failed to update user:', error.message));
{
"status": 400,
"message": "Validation failed",
"errors": {
"email": ["Invalid email format"]
}
}
{
"status": 404,
"message": "Not found"
}
Was this page helpful?