Databricks API - Get Dashboard Owner?

ruicarvalho_de
New Contributor III

Hi all!

I'm trying to identify the owner of a dashboard using the API.

Here's a code snippet as an example:

import json

dashboard_id = "XXXXXXXXXXXXXXXXXXXXXXXXXX"
url = f"{workspace_url}/api/2.0/lakeview/dashboards/{dashboard_id}"
headers = {"Authorization": f"Bearer {token}"}

response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()

print(json.dumps(data, indent=2))

This call returns:

  • dashboard_id, display_name, path, create_time, update_time, etag, serialized_dashboard, lifecycle_state and parent_path.

The only way I'm able to see the owner is in the UI.

Has someone faced this issue and found a workaround?
Thanks.

Rui Carvalho
Data Engineer

pradeep_singh
Contributor III

Lakeview (AI/BI) dashboards GET endpoint doesn’t return an explicit owner field. Use the Workspace Permissions API to infer the owner from the ACLs.

import requests

dash = requests.get(f"{workspace_url}/api/2.0/lakeview/dashboards/{dashboard_id}",
                    headers=headers).json()
path = dash["path"]  # e.g., "/Users/alice@example.com/Folder/MyDash.lvdash.json"

st = requests.get(f"{workspace_url}/api/2.0/workspace/get-status",
                  params={"path": path}, headers=headers).json()
resource_id = st["resource_id"]

perms = requests.get(f"{workspace_url}/api/2.0/permissions/dashboards/{resource_id}",
                     headers=headers).json()

owner = None
for ace in perms.get("access_control_list", []):
    perms_list = ace.get("all_permissions", [])
    has_direct_manage = any(p.get("permission_level") == "CAN_MANAGE" and not p.get("inherited", False)
                            for p in perms_list)
    if has_direct_manage:
        # prefer user_name, but could be group_name or service_principal_name depending on who owns it
        owner = ace.get("user_name") or ace.get("group_name") or ace.get("service_principal_name")
        break

print("Owner:", owner)
Thank You
Pradeep Singh - https://www.linkedin.com/in/dbxdev

Unfortunatly the issue persists. All permissions are inherited: True. This happens when the dashboard is in a shared folder and the permissions come from the parent folder, not from the dashboard itself.

permissions: {'object_id': '/dashboards/<redacted>', 'object_type': 'dashboard', 'access_control_list': [{'user_name': '<redacted>', 'display_name': '<redacted>', 'all_permissions': [{'permission_level': 'CAN_EDIT', 'inherited': True, 'inherited_from_object': ['/directories/<redacted>']}]}, {'user_name': '<redacted>', 'display_name': '<redacted>', 'all_permissions': [{'permission_level': 'CAN_MANAGE', 'inherited': True, 'inherited_from_object': ['/directories/<redacted>']}]}, {'group_name': '<redacted>', 'all_permissions': [{'permission_level': 'CAN_MANAGE', 'inherited': True, 'inherited_from_object': ['/directories/']}]}]}

Rui Carvalho
Data Engineer

Sanjeeb2024
Valued Contributor

Hi @ruicarvalho_de - Note sure, can you please give a try to use " /api/2.0/preview/sql/dashboards/{dashboard_id}". see the documentation details below.

https://docs.databricks.com/api/workspace/dashboards/get

Sanjeeb Mohapatra

Yes, tried it but failed. This is for legacy dashboards, I'm using lakeview dashboards.

Status: 404 {'message': 'GetDashboardHandler failed to parse request. Please check dashboard id for errors.'}

Rui Carvalho
Data Engineer

Hi @ruicarvalho_de - Ok got it. Let me explore on the api for lakeview dashboards.

Sanjeeb Mohapatra

JAHNAVI
Databricks Employee
Databricks Employee

@ruicarvalho_de I don't think we have a direct way to fetch the owner of the dashboard through API. 

We can try using an API call to retrieve the dashboard IDs and then use the following API call /api/2.0/permissions/{workspace_object_type}/{workspace_object_id} to get the object permissions. However, it still will not provide a single, authoritative “owner” field; instead, you only get all principals and their permission levels on each dashboard.

Jahnavi N

Is there any reason for that information is not available directly?

Rui Carvalho
Data Engineer

ruicarvalho_de
New Contributor III

Hello, meanwhile, I've found a workaround to get the owner, or more likely the creator of the dashboard.

SELECT 
            request_params.dashboard_id AS dashboard_id,
            FIRST(user_identity.email) AS owner_email
        FROM system.access.audit 
        WHERE workspace_id = '{workspace_id}'
            AND service_name = 'dashboards' 
            AND action_name = 'createDashboard' 
            AND response.status_code = 200
        GROUP BY request_params.dashboard_id

 

Rui Carvalho
Data Engineer

View solution in original post