Public API to get cloud/site ID


We have this requirement in our application to redirect to User Management > Groups whenever we click a certain link. Part of the URL for this page is the cloud id

I have tried the solution provided here How to find Cloud Site Id | Jira | Atlassian Documentation but it will throw an error when called from the application. So I was wondering if there is any available rest API that we can use to retrieve the value for this?

Context for the error:
When I access the API thru the browser, I actually get a successful response with the cloud id but when I try to request thru our app with AP.context(…) which adds this additional parameter ?_r=1705633321612 in the URL, I get a 403 error. Same case happens when I access it thru the browser with this exact URL

Thank you in advance.