# Ability to have granular scope for data explorer?

**URL:** https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351
**Category:** Feature
**Tags:** data-explorer, user-api
**Created:** [April 17, 2025, 3:31pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351 "2025-04-17T15:31:20Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [April 17, 2025, 3:31pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/1 "2025-04-17T15:31:20Z")

</div>

Is there a way to scope an API key to be able to both read and write for [data explorer](https://meta.discourse.org/t/32566?silent=true) queries without giving a globally scoped admin API key?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 17, 2025, 4:03pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/3 "2025-04-17T16:03:42Z")

</div>

[Data explorer](https://meta.discourse.org/t/32566?silent=true) cannot write anything, ever.

You can create a query and allow members of a group who cannot otherwise have access to the plugin to run particular queries.

---

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [April 17, 2025, 5:13pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/4 "2025-04-17T17:13:35Z")

</div>

Sorry, maybe it was not written well. Can queries themselves not be created via API?

That is the function in question—read and write the actual queries themselves, not within a query.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 17, 2025, 5:20pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/5 "2025-04-17T17:20:31Z")

</div>

Oh. Sorry. I did miss that. So you want to **create** queries via the API, not just run them. That is different.

I suspect that the answer is no.

What problem do you have that writing queries via the API is going to solve? Do you need to create a lot of them or something?

---

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [April 17, 2025, 5:23pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/6 "2025-04-17T17:23:32Z")

</div>

You can create them via API, my question is if we can somehow limit the scope of an API key for that. Currently an API key scope can be limited to reading [data explorer](https://meta.discourse.org/t/32566?silent=true) queries, but it doesn’t give an option to limit a scope to writing.

So today, if I want to give someone in my business the ability to write queries to [data explorer](https://meta.discourse.org/t/32566?silent=true), I have to give them a full global admin API key.

Here are the docs on creating queries via API:

> [@Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063#p-591217-removing-relations-data-from-the-results-4):
>
> bookmark This guide explains how to use the Discourse API to create, run, and manage queries with the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin. person_raising_hand Required user level: Administrator Virtually any action that can be performed through the Discourse user interface can also be triggered with the Discourse API. This document provides a comprehensive overview for utilizing the API specifically in conjunction with the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin. For a general overview of how to find the correct API …

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 17, 2025, 5:25pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/7 "2025-04-17T17:25:11Z")

</div>

> [@jordan-violet](#):
>
> I want to give someone in my business the ability to write queries

Ah. I see. You trust a particular human to write queries, but not anything else. I don’t think there’s a way to do that currently.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 30, 2025, 1:35pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/8 "2025-05-30T13:35:14Z")

</div>

Sounds to me like what you are asking for, and which seems a good idea alot of communities would benefit from, is a setting like `data_explorer_allowed_groups` which lets you provide full access to [data explorer](https://meta.discourse.org/t/32566?silent=true) to more groups in addition to admins.

Presumably then if the group is allowed access, then the API key of that user would work to create queries as well as access them.

Currently it’s only possible to let people access existing queries, via their groups page.

I’ve moved this to #Contribute > Feature so the feature request can be considered. Not sure it will be picked up but this at least puts the idea out there.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 30, 2025, 4:47pm UTC](https://meta.discourse.org/t/ability-to-have-granular-scope-for-data-explorer/362351/9 "2025-05-30T16:47:36Z")

</div>

> [@tobiaseigen](#):
>
> Sounds to me like what you are asking for, and which seems a good idea a lot of communities would benefit from, is a setting like `data_explorer_allowed_groups` which lets you provide full access to [data explorer](https://meta.discourse.org/t/32566?silent=true) to more groups in addition to admins.

The reason not to do that is that it gives those people full (though read-only) access to everything in the database–passwords, IP addresses (which moderators have), all of the secrets in SiteSettings, and probably some other stuff. OTOH, it is read-only, so it’s not the SAME as being an admin. Oh, also, the secrets needed to log in as someone else if you have a login link sent.
