I have around 500 users who need to be deactivated from the confluence. Is there any query to run in DB to disable or is there any possible solution via Rest API.
can someone provide suggestion on this.
Unofficially you might want to take a look in network tab of your browser, deactivate a sample user, and work with the HTTP request you see - this way you might be able to automate it with some small local automation script.
Replicating the http forms, and removing unnecessary clutter gets me to
curl 'https://confluencebaseurl.com/admin/users/deactivateuser-confirm.action' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Cookie: JSESSIONID=55B07A765493F5F108D211F0CDB36CF8' \
-H 'X-Atlassian-Token: no-check' \
confluencebaseurl - obviously
JSESSIONID - you need to get this cookie from your current session once you log in, when you log in, you get a JSESSIONID cookie which servers as your authentication, but you could replace this with PAT or basic auth
X-Atlassian-Token - I added this because the data originally contained atl_token, but since this would be automated from outside, we would not have a valid token, so this will skip the token check
testuser - the username
And locally, this seems to be working.
Alternatively you could use groovy (if you have a plugin allowing to), or write a java plugin, but if you just need to do this one time I don't see a big harm in just cracking the http form. Mind you - not official, so do test this first if it does what you expect it to.