Update Users

PUT /api/v1/profile/update-user/:id

Common errors include:

  • "400 Bad Request" if the request body is invalid.
  • "401 Unauthorized" if the bearer token is missing or invalid.
  • "500 Internal Server Error" if the user update fails.

Updates an existing user's email address or role using the provided user ID.

Request

Method : PUT
Content-Type : Application/json
Authentication : Bearer Token
Base URL : https://apis.divsly.com/api/v1

Request Parameters Schema

email string
Default: current email
New email address for the user
userType string
Default: current user type
User type/role to be updated
idnumberRequired
Default: -
User ID to update (passed as URL parameter)
LANGUAGE
REQUEST
 
curl --location --request PUT 'https://apis.divsly.com/api/v1/update-user/1140' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer oauth2_XdwUa1OJE' \
--data-raw '{
    "email": "newuser@example.com",
    "userType": "user"
}'
API REQUEST
 fetch('https://apis.divsly.com/api/v1/update-user/1140', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer oauth2_XdwUa1OJE'
  },
  body: JSON.stringify({
    email: 'newuser@example.com',
    userType: 'user'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

API REQUEST
 const axios = require('axios');

axios.put(
  'https://apis.divsly.com/api/v1/update-user/1140',
  {
    email: 'newuser@example.com',
    userType: 'user'
  },
  {
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer oauth2_XdwUa1OJE'
    }
  }
)
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error.response?.data || error.message);
});

API REQUEST
 import requests

url = "https://apis.divsly.com/api/v1/update-user/1140"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer oauth2_XdwUa1OJE"
}

payload = {
    "email": "newuser@example.com",
    "userType": "user"
}

response = requests.put(url, json=payload, headers=headers)

print(response.status_code)
print(response.json())
API REQUEST
 # Python Requests
import requests

def update_user(user_id, email, user_type, access_token):
	url = f"https://apis.divsly.com/api/v1/profile/update-user/{user_id}"
    
	headers = {
    	"Content-Type": "application/json",
    	"Authorization": f"Bearer {access_token}"
	}
    
	payload = {
    	"email": email,
    	"userType": user_type
	}
    
	response = requests.put(url, json=payload, headers=headers)
	return response.json()

RESPONSE
  {
  "success": true,
  "data": {
	// updated user data
  },
  "message": "User updated successfully!"
}

   
  {
  "error": true,
  "message": "Unauthorized access",
  "data": null
}


  {
	"success": false,
	"message": "An unexpected error occurred while updating user"
}