How to get datasource uid via HTTP API?

I’m using Grafana Cloud and I’m trying to manage alerts via HTTP API.
I’m posting …/api/ruler/grafana/api/v1/rules to add new alert. But to add a new alert I have to specify the datasource uid.
Is it possible to get this uid somehow? I tried with GET …/api/datasources but it returns “permission denied”.

@iluanna for the API with grafana cloud, you’ll want to use an API token created in your grafana instance that has the right permissions. Is it possible that the API key you’re using was created from the grafana cloud platform portal?

@melori.arellano thanks for advice. I was using Grafana API token with editor permision and it seems that this request requires admin permision. Now with admin one it works perfectly.

1 Like