Create Service Account for Specific Org Without Context Switching

Hi all,

I’m working on automating operations across multiple organizations in Grafana and ran into some challenges around organization scoping.

Creating service accounts requires switching the current org context (e.g., via /api/user/using/:orgId). However, this introduces issues in concurrent scenarios where multiple jobs (one per org) perform operations in parallel.

I also tested using the X-Grafana-Org-Id header to scope requests explicitly, but it does not seem to work for service account creation.

This makes the process dependent on mutable session context, which may lead to race conditions when using a shared admin like identity.

My questions are:

  • Is there a way to create a service account directly for a specific org without switching context?
  • If not, is this a known limitation or intentional design decision?
  • Any recommendation for this use case?

Thanks!!