Update Users

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

Common errors include:

  • "Bad Request" if body parameters are not passed
  • "DNS_CONFIGURATION_ERROR" if custom domain DNS is misconfigured.

The createQrCodeHandler creates a qr code for the input body and returns the reponse to users

Request

Method : GET
Content-Type : Application/json

URL 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 -X PUT "https://divsly-backend.vercel.app/api/v1/profile/update-user/123" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
	"email": "newemail@example.com",
	"userType": "USER"
  }

API REQUEST
 const updateUser = (userId, userData) => {
  return fetch(`https://divsly-backend.vercel.app/api/v1/profile/update-user/${userId}`, {
	method: 'PUT',
	headers: {
  	'Content-Type': 'application/json',
  	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
	},
	body: JSON.stringify({
  	email: userData.email,
  	userType: userData.userType
	})
  })
	.then(response => response.json())
	.catch(error => {
  	console.error('Error:', error);
  	throw error;
	});
};

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

const updateUser = (userId, userData) => {
  return axios.put(
	`https://divsly-backend.vercel.app/api/v1/profile/update-user/${userId}`,
	{
  	email: userData.email,
  	userType: userData.userType
	},
	{
  	headers: {
    	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  	}
	}
  )
	.then(response => response.data)
	.catch(error => {
  	console.error('Error:', error.response?.data || error.message);
  	throw error;
	});
};

API REQUEST
 // PHP cURL
  function updateUser($userId, $email, $userType, $accessToken) {
	$data = array(
    	'email' => $email,
    	'userType' => $userType
	);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "https://divsly-backend.vercel.app/api/v1/profile/update-user/" . $userId);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    	'Content-Type: application/json',
    	'Authorization: Bearer ' . $accessToken
	));

	$response = curl_exec($ch);
	curl_close($ch);

	return json_decode($response, true);
}
API REQUEST
 # Python Requests
import requests

def update_user(user_id, email, user_type, access_token):
	url = f"https://divsly-backend.vercel.app/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"
}