Coralogix provides a secure **hosted Grafana API** for creating, editing, exporting, importing, querying, and other Grafana API operations. Through Grafana APIs, you can manage your hosted Grafana dashboards.

## Prerequisites

To use the Grafana API to query your dashboard, you will need:

- To [create](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys/index.md) a personal or team API key. It’s recommended to use permission presets, as they are automatically updated with all relevant permissions. Alternatively, you can manually add individual permissions.

  | Preset  | Action                          | Description                                       |
  | ------- | ------------------------------- | ------------------------------------------------- |
  | Grafana | `GRAFANA:READ` `GRAFANA:UPDATE` | View Grafana Dashboards Manage Grafana Dashboards |

- A Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md)

## **HTTP Request for Your Hosted Grafana**

The API key should be added as Coralogix token with each HTTP request. Your Coralogix Domain will be used to construct the Grafana API endpoint specific to your account.

The API request should contain the following:

- Headers:

  - ‘token:`<cx_api_key>`’
  - ‘Content-type: application/json‘

- URL: https://api.\[[DOMAIN_VALUE]\]/grafana/api

## **Examples**

- GET Home Dashboard

```bash
curl --location --request GET 'https://api.[[DOMAIN_VALUE]]/grafana/api/dashboards/home' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer <cx_api_key>' \
```

- Search all dashboards in your team:

```bash
curl --location --request GET 'https://api.[[DOMAIN_VALUE]]/grafana/api/search' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer <cx_api_key>' \
```

- Get a dashboard and panels by uid:

```bash
curl --location --request GET 'https://api.[[DOMAIN_VALUE]]/grafana/api/dashboards/uid/<UID>' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer <cx_api_key>' \
```

- Post Dashboard - create and update existing dashboards:

```bash
curl --location 'https://api.[[DOMAIN_VALUE]]/grafana/api/dashboards/db' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <cx_api_key>' \
--data '<Dashboard JSON>'
```

- GET Annotations:

```bash
curl --location --request POST 'https://api.[[DOMAIN_VALUE]]/grafana/api/dashboards/db' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer <cx_api_key>' \
--data-binary "@path/to/file"
```

## Additional Resources

- [Grafana’s HTTP API Reference](https://grafana.com/docs/grafana/v9.0/developers/http_api/)
- Grafana API supports the Host Grafana features.

## Support

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email at [support@coralogix.com](mailto:support@coralogix.com).
