Using Looker API to copy dashboards

Userlevel 1

Hi there,

I am trying to create a simple python script to copy dashboards (these are user-defined dashboards), as well as their underlying Looks.

Basically I am reading the info from the “source” dashboard, and using the create_dashboard and/or update_dashboard API calls.

I am being stumped by a couple of issues:

  1. I can’t seem to get the references to Looks and layouts into the “copied” dashboard. I just end up with an empty dashboard. When I look at the Dashboard data structure, I notice that dashboard_layouts and dashboard_elements are marked as readonly, so it makes sense that it doesn’t use this info when creating/updating the dashboard. But is there a way to do this in the API?

  2. I can’t see how to use the API to copy dashboard-level filters. The dashboard-level filter info doesn’t seem to appear anywhere in the dashboard data structure?

Thanks for any clues you can provide…

23 replies

Userlevel 2

Hi @mjoy_te!

Regarding your first point - I’ve tried running the same process as yourself and I’m getting exactly the same result. I’ll try few different things to confirm whether there is another method of achieving it or it possibly is a bug on our side.

When it comes to dashboard filers - I can see the dashboard(dashboard_id) endpoint returns information about all linked filters in the "dashboard_filters" parameter. It’s important that the dashboard has a filter linked to the desired elements with the default value set.

I’ll keep you posted once I find out more about the create_dashboard(body) endpoint.

Userlevel 1

Thanks Aleks, I’ll have a close look at the filter stuff, maybe I am doing something incorrectly.

Please do keep me posted about point #1 (references to looks and layouts) - this is currently a blocking issue for us so it would be good to know if there is a workaround or if we will need to go about it differently.

Userlevel 2

Hi @mjoy_te!

It turns out the dashboard_elements and dashboard_layouts fields of the dashboard type are read-only in the create_dashboard method. This means they are ignored when passed to create_dashboard API call. I’ve tried to use the update_dashboard post create_dashboard but the child lists are also read-only in that method, so it wont work either.

After discussing it with the engineering team, currently there is no way to copy dashboards via API. However, I’ll pass that request to our product team for you so it’s considered in future releases.

Userlevel 1

OK thanks for your reply. We certainly look forward to seeing this in the API…

Just to add something here, I think I’ve figured out how to do this with the URL based API. I don’t know if it’s possible with the SDK.

For each look you want to add to a dashboard, you can send a POST request to the endpoint /api/3.0/dashboard_elements. It’s body should contain a look_id, a dashboard_id, and a type. The creation of this will add the look to the dashboard, and it will now show up when the dashboard is fetched again.

That makes copying a bit more complicated, but should allow you to at least add the looks from the old dashboard one by one to the new dashboard.

I couldn’t find it documented anywhere, but I guessed from the naming convention and it worked. I presume the same would work if you wanted to create a dashboard_filter object (a POST request to /api/3.0.dashboard_filters) or a dashboard_layout object (a POST request to /api/3.0.dashboard_layouts).

Hope that helps. I certainly struggled with it for a while.

I have created a ruby script which copies a dashboard to any other space, using your thoughts @Tull_Gearrealdas a starting point - thank you!

If others are interested in doing this highly unsupported thing, I could look into sharing it. 🙂 Let me know if so…

Hey Aaron,

Could you please share the script with me so that i can refer that. Thanks in advance.

I’m also interested in this.

Specifically, I’d like to save user defined dashboards as lookml and store in git.

Userlevel 4

GZR, a command line tool for Looker, will allow you to do this outside of the UI.

Hi @aleks – With API 3.1 being rolled out with Looker 6.12, I was wondering where this feature request stands. Being able to copy dashboards via the API will solve a huge missing feature in our user flow.

The command-line / scripting utilities solve the need for internal use-cases but not user-facing needs of an analytics feature built on Looker.

Hoping that this gets prioritized soon. Please let me know if there are any new work-arounds introduced with 3.1 that involve making multiple calls, etc. Thanks!

Userlevel 2

@aleks @shiggins

Any update on this? Looks like the original request to copy a dashboard via the Looker API was submitted on April of 2017.

We have a use case that requires dashboards to be copied into different spaces and doing it the manual way is not possible (you can’t move a dashboard into an embed group in the ui because they don’t show up). I created a Python script to do all of this for me only to find out that the the create_dashboard method doesn’t work due to all the readonly fields (as mentioned above).

I looked at GZR but don’t see anywhere that supports copying a dashboard. If I had the power to Copy a Dashboard (just like you do in the UI), then we’d be good to go here.

Now that it’s August of 2019, and a new API has been delivered (3.1), what’s the update on the ability to copy a dashboard? Is this a feature that Looker will not implement?

Userlevel 4

No new endpoints have been released for explicitly copying a dashboard. You can use GZR to copy dashboards. A basic flow would be the below:


gzr dashboard cat 1004 --host --client_id 123abc --client_secret 789xyz > dashboard1004.json


gzr dashboard import dashboard1004.json 101 --host --client_id 123abc --client_secret 789xyz

(‘1004’ being a dashboard id, 101 being a target space id)

It should be straight forward enough to wrap these into a single Python (or any language) script.

Userlevel 2

Thanks @shiggins!

Userlevel 2

@shiggins How does it handle all of the ids? It looks like this is an export/import of a dashboard rather than copying it. Is this essentially moving the dashboard or does the exported dashboard remain in place with new id’s generated during the import process?

Userlevel 4

It’s an export/import alright but the --force parameter in GZR will allow you to ‘overwrite’ the dashboard.

Each dashboard has a slug, which GZR maintains through the import/export process meaning you can have sandbox versions of dashboards and then use GZR to push these to overwrite existing ones.

You can also just push these sandbox dashboards as separate copies as opposed to overwrite, so there can be multiple versions of the same dashboard in separate spaces as your use case describes.

any news on this feature?

although GZR seems like a solution, its a shame making me add GZR to my environment just to copy dashboards.

Is there any update on how we can duplicate a dashboard?

Userlevel 1

Hi all, here is a sample python script that uses the Looker API to copy a dashboard.

This feature is still needed. Would love to see this aded to the API in 4.0 (Experimental). It doesn’t look like this is a feature at the moment.

Are there rate limits on any of these create endpoints?

Userlevel 4

There is now a copy dashboard endpoint in the 4.0 version of the REST API.

@Eric_Lyons Is this launched yet?

I’m getting a 404 error - confirmed I was able to to retrieve (/api/4.0/dashboards/{dashboard_id}) using same credentials

Hello All,

Im new to looker API.

Will this API’s support to move dashboards from one instance to another ? 

Like from Dev to Prod ?


GZR is in place now but looking that can we able to do it with API only.