How to store company context in external storage

I’m building a Jira Cloud App with (angular, spring boot, mysql). I have my own entities on which the user is working. He is able to store them in the database on my server. Everything is connected via REST API. I have no problem with getting user id to understand who is the owner of the specific object BUT I need to limit list objects to specific company. So for example there are:

All of them are using my app and their data are stored in the same database (table). If I want to do something like

select * from my_object;

I’ll receive a full list of objects. What I want to do is:

select * from my_object where company_id = x;

But to do that I need to store some kind of identifier of the specific jira cloud instance. The question is: how to obtain it?

@fixianovic welcome to the Atlassian developer community.

Given my response here:

I recommend using OAuth 2.0 and cloudid as your “identifier of the specific jira cloud instance”. To be clear, site is not always 1:1 with company. For example, Atlassian has a handful of Jira sites in production use (and maybe 1000s in use by people and teams). As explained in that post, your client obtains that cloudid by using the OAuth access token with this endpoint: