---
title: "Dashboards - Tutorial - How to use the Grafana® API"
description: "Learn how to use the Grafana® API"
url: https://docs.ovhcloud.com/en/guides/public-cloud/databases/grafana-tuto-using-api
lang: en
lastUpdated: 2024-12-11
---
# Dashboards - Tutorial - How to use the Grafana® API

## Objective

Using the Grafana® API is not obvious and already clearly documented.
This tutorial explains how to configure Grafana® to use the API and how make calls to the exposed API.

## Requirements

- A [Public Cloud project](https://www.ovhcloud.com/en-gb/public-cloud/) in your OVHcloud account
- A Dashboards service running on your OVHcloud Public Cloud project (see [this guide](/en/guides/public-cloud/databases/getting-started.md) to create a managed Dashboards service)

## Instructions

### Create a Grafana® service account

In the configuration menu, display the `Service accounts
` tab:
![Grafana service accounts tab](/images/public-cloud/databases/grafana-tuto-02-using-api/service-account-tab.png)
Create a new service account `sa-editor` with the role `Editor`:

![Grafana service accounts creation](/images/public-cloud/databases/grafana-tuto-02-using-api/service-account-creation.png)
Click on `Add service account token
`:
![Grafana service accounts token button](/images/public-cloud/databases/grafana-tuto-02-using-api/add-service-account-token-button.png)
Enter the name of the desired token, `grafana-sa-token-editor`
, and click on `Generate token
`:
![Grafana service accounts token generation](/images/public-cloud/databases/grafana-tuto-02-using-api/generate-sa-token.png)
Copy the generated token:

![Grafana service accounts token generated](/images/public-cloud/databases/grafana-tuto-02-using-api/sa-account-generated-token.png)
:::warning
After closing the pop-up, you will no longer be able to display the token!
:::

The created token appears in the tokens list:

![Grafana service accounts token list](/images/public-cloud/databases/grafana-tuto-02-using-api/sa-account-created-tokens-list.png)
You are ready to use this token with the Grafana® API.

### Use the Grafana® API

:::info
Detailed instructions on how to use the API and the possible actions can be found in the official documentation: [https://grafana.com/docs/grafana/latest/developers/http\_api/](https://grafana.com/docs/grafana/latest/developers/http_api/)
:::

:::warning
Don't forget to set the `Authorised IP addresses` in the Dashboards configuration. See our guide on [Configuring your Grafana instance to accept incoming connections](/en/guides/public-cloud/databases/grafana-prepare-for-incoming-connections.md) for more details.
:::

To send a request to the API you must use the previously created token and set it in the request header as a "Bearer token":

```bash
export GRAFANA_API_TOKEN=042footoken420

curl -H "Authorization: Bearer $GRAFANA_API_TOKEN" https://grafana-xxxxxxxxx-yyyyyyyyy.database.cloud.ovh.net/api/folders    
[
    {
        "id":11,
        "uid":"HnDCAp-4k",
        "title":"foo 1"
    },
    {
        "id":5,
        "uid":"cb_S6Pb4k",
        "title":"foo 2"
    },
    {
        "id":9,
        "uid":"Xav55taVk",
        "title":"foo 3"
    },
    {
        "id":10,
        "uid":"AH8sApaVz",
        "title":"foo 4"
    }
]

```

Here it is, you can now use all the power of the Grafana® API.

## We want your feedback!

We would love to help answer questions and appreciate any feedback you may have.

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://www.ovhcloud.com/en-gb/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

Are you on Discord? Connect to our channel at [https://discord.gg/ovhcloud](https://discord.gg/ovhcloud) and interact directly with the team that builds our databases service!
