How create Dashboard and Panel via API

Hi All,

I know how to create a dashboard via API but I don’t find instructions to how to create panels within that dashboard still via API. Any idea?

There is no API for panels only.

You can create & update dashboards using this API

I saw that :slight_smile: But what is the point to create an empty dashboard?

1 Like

The panels need to be defined within the JSON that you submit in your POST request.

The example in the docs doesn’t spell this out, beyond

dashboard – The complete dashboard model

To get hands-on with this, you can (1) create a new dashboard with some panels manually, (2) export that dashboard’s definition as JSON, (3) put the exported dashboard definition inside the “dashboard” field of a new JSON object, (4) POST the resulting JSON object to the API endpoint. This will create a copy of your original dashboard. From there on, you can edit the JSON model you’re posting in order to modify or add any panels you desire.

So to your original question, if you want to add a panel to an existing dashboard you can obtain its definition via the API, add the panel to the JSON object, and push the updated model. (keep the same id/uid and set "overwrite": true)


After I obtain dashboard definition via the API, I push the updated model. When I do this, the dashboard goes to another folder. Do you know why this happens and how to fix it?