Creating multiple Service Accounts/ Tokens (via the API) for individual organisations

  • What Grafana version and what operating system are you using?
    Grafana v10.0.3 (eb8dd72637)

  • What are you trying to achieve?
    Create an token for admin access to a single Grafana organisation

  • How are you trying to achieve it?
    I have create a new “admin” account for the Grafana instance I’m testing on.
    I’m using that account to call the Service Account and Tokens API’s.
    First I create the service account, and then I create the tokens.

  • What happened?
    It works but the service account only appears in the admin users default organisation.

  • What did you expect to happen?
    I would like to specify the orgId on the Service Account and have the Service Account created in that organisation.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No, the service account is created - it’s just in the wrong organisation.

  • Did you follow any online instructions? If so, what is the URL?
    Service account HTTP API | Grafana documentation

I suspect I am missing something, but nothing in the documentation suggests what it is or how I fix it - I’d be very happy if this was just a documentation problem!

Yep. It was a documentation issue.

This allows you to switch the context for the signed in user to a different organisation.

It sounds like you’re trying to create a service account for a specific Grafana organisation but are facing an issue where the service account defaults to the admin user’s default organisation. Here’s a question:

Is there a way to create a service account tied to a specific organisation via the API in Grafana?

From your description, it seems like you’re already using the Service Account and Tokens API to generate tokens, but they’re not appearing in the correct organisation. You mentioned that specifying the orgId would be ideal, but it’s not behaving as expected.

Have you tried switching the context for the signed-in user to the desired organisation before creating the service account? Sometimes the API operates within the scope of the current organisation context. If the documentation doesn’t directly cover it, adjusting the context might be the solution.

For managing multiple accounts seamlessly and avoiding tracking issues, you might want to consider using an anti-detect browser like Multilogin. It can help streamline the process of handling different profiles without cross-contamination of information.

Feel free to share if there’s any additional configuration you’ve tried or other insights you’ve gathered!