Organization state in the API

Hello,

As part of a project I’m working on we are using the API to manage (for instance) dashboards and datasources across different grafana organizations.

The issue is that it seems like the API for grafana is not stateless, specifically for each user there is a context of which organization is ‘active’ which affects many of the endpoints for dashboards and datasources.

Architectural our solution will be based around serverless microservices, so I see the potential for issues if calls are issued concurrently using the same global user account. Solutions I have considered are either using an external concurrency lock, or creating a new user with a randomized name to do the calls and then delete that user when finished.

I’m reaching out to see if we have missed anything in terms of another way to solve this problem using the existing API, or if there are any plans for the future roadmap to move the REST API towards stateless invocations.

Thank you very much for your time and help,
Kirk Fort

You can pass the header X-Grafana-Org-Id: 1 to set the active org id for that particular call to 1.