Delete Users

DELETE /api/v1/profile/delete-user/:userId

Common errors include:

  • "401 Unauthorized" if the bearer token is missing or invalid.
  • "403 Forbidden" if the current account cannot delete the selected user.
  • "500 Internal Server Error" if the user could not be deleted.

Deletes a user by ID from the current account.

Request

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

URL Parameters Schema

userId number Required
Default: N/A
User ID to delete (passed as URL parameter)
LANGUAGE
REQUEST
 curl -X DELETE 
   "https://apis.divsly.com/api/v1/profile/delete-user/123" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

API REQUEST
 const deleteUser = (userId) => {
  return fetch(`https://apis.divsly.com/api/v1/profile/delete-user/${userId}`, {
	method: 'DELETE',
	headers: {
  	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
	}
  })
  .then(response => response.json())
  .catch(error => {
	console.error('Error:', error);
	throw error; // Ensure errors propagate to the caller
  });
};

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

const deleteUser = (userId) => {
  return axios.delete(`https://apis.divsly.com/api/v1/profile/delete-user/${userId}`, {
	headers: {
  	'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
	}
  })
  .then(response => response.data)
  .catch(error => {
	console.error('Error:', error.response?.data || error.message);
	throw error; // Ensure errors propagate to the caller
  });
};
API REQUEST
 $userId = 123;
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://apis.divsly.com/api/v1/profile/delete-user/" . $userId);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    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(
        'Authorization: Bearer YOUR_ACCESS_TOKEN'
    ));

API REQUEST
 # Python Requests
import requests

def delete_user(user_id, access_token):
	url = f"https://apis.divsly.com/api/v1/profile/delete-user/{user_id}"
	headers = {
    	"Authorization": f"Bearer {access_token}"
	}
    
	response = requests.delete(url, headers=headers)
	return response.json()

RESPONSE
  {
	"error": false,
	"data": {
    	// Deleted user data from deleteProfileQuery
    	"id": 123,
    	"email": "user@example.com",
    	// ... other user fields returned by Prisma
	}
}
   
  {
  "data": {
	"message": "Unauthorized",
  }
}


 {
  "data": {
	"message": "Forbidden Access!",
  }
}


    
  {
  "error": true,
  "message": “Error deleting user”
}