API

Grafana Cloud API

The Grafana Cloud API is sometimes referred to as the Grafana.com API. It is a work in progress, however the following calls and paths on this page are static and approved for general use. If you hear of other paths and calls, know that they are subject to change and not generally maintained for user consumption.

Authentication

Generate an API token in the Grafana.com user portal at https://grafana.com/orgs/<org_slug>/api-keys. Make sure it has the “Admin” role.

Requests to the API are authenticated using the Authorization header:

Authorization: Bearer <grafana.com API token>

API Keys

List API Keys

GET https://grafana.com/api/orgs/<org_slug>/api-keys

Create API Key

POST https://grafana.com/api/orgs/<org_slug>/api-keys

Body: name (string) – API key name role (string) – Permission level of API key. One of “Viewer”, “Editor”, “Admin”, or “MetricsPublisher”

Delete API Key

DELETE https://grafana.com/api/orgs/<org_slug>/api-keys/<api key name>

Stacks

List Stacks

GET https://grafana.com/api/orgs/<org_slug>/instances

Create Stack

POST https://grafana.com/api/instances

Body: name (string) – Name of stack. Conventionally matches the url of the instance (e.g. “<stack_slug>.grafana.net”) slug (string) – Subdomain that the Grafana instance will be available at (i.e. setting slug to “<stack_slug>” will make the instance available at “https://<stack_slug>.grafana.net”. url (string, optional) – If a custom domain will be used for the instance it must be provided here (e.g “https://grafana.yourdoman.io”). Note that the custom domain must have a CNAME record set up that points to .grafana.net before it can be specified.

Delete Stack

DELETE https://grafana.com/api/instances/<stack_slug>

Restart Grafana

POST https://grafana.com/api/instances/<stack_slug>/restart

Create Grafana API keys

POST https://grafana.com/api/instances/<stack_slug>/api/auth/keys

This endpoint requires the Admin role. See the Grafana docs for more details.

Body: name (string) – Name of the API key. role (string) – Access level/Grafana Role for the key. Can be one of the following values: Viewer, Editor or Admin. secondsToLive (number, optional) – Key expiration in seconds. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_live configuration option is set) the key will never expire.

Grafana Provisioned Data Sources

List Data Sources

GET https://grafana.com/api/instances/<stack_slug>/datasources

Delete Data Source

DELETE https://grafana.com/api/instances/<stack_slug>/datasources/<data source id>

Restart Grafana

POST https://grafana.com/api/instances/<stack_slug>/restart