Default or Primary Org per User

Hi Grafana-ites,

I am not able to discern from the docs whether there is such a thing :point_up: .
So when I see a Grafana User logged in to possibly another app, I want to use the API to find their Primary or Default Org.

This is also important as when a User logs in, they should have their Primary Org as the Default.

(PS and FWIW . Its well documented and easy to obtain a list of all the Orgs that a User is a member of – but I would like just to have one Org).

If you use the User API endpoint, the orgId returned here is the default org: User HTTP API | Grafana Labs

If you have access to the database tables, then it is the org_id column in the user table.

Thank you @daniellee

Are you able to provide me with an example of how to change the default orgay of a user?

I imagine that the default organization would be the last one that the user became a member of :thinking:

Many thanks for your assistance

I think this is the API endpoint you are looking for - Switch user context for signed in user: User HTTP API | Grafana Labs

1 Like

Thank you @daniellee
(We are using those API command that you reference routinely :blush: )

Our use case is that we have some users that are members of multiple organizations.
So when you use the /api/users/:id:/org
Then this gives you the user’s “default org”
But what decides what the users default or is and can we change that setting?

FYI, when we write a record to db, we include the field denoting that users default org.

Thanks for any further help
Best wishes

This topic was automatically closed after 365 days. New replies are no longer allowed.