Skip to main content

Data Sources API

The Data Sources API provides endpoints for managing data source configurations in Grafana.

Get All Data Sources

Retrieve all data sources for the current organization.
integer
Data source internal ID
string
Data source unique identifier
string
Data source name
string
Data source type (e.g., “prometheus”, “mysql”, “postgres”)
string
Access mode: “proxy” (via Grafana backend) or “direct” (from browser)
string
Data source URL
boolean
Whether this is the default data source

Get Data Source by UID

Retrieve a single data source by its UID.
string
required
Data source unique identifier

Create Data Source

Create a new data source.
string
required
Data source name
string
required
Data source type (e.g., “prometheus”, “mysql”, “postgres”)
string
required
Data source URL
string
default:"proxy"
Access mode: “proxy” or “direct”
string
Database name (for database data sources)
string
Database user (for database data sources)
boolean
default:"false"
Enable basic authentication
string
Basic auth username
boolean
default:"false"
Set as default data source
object
Additional data source configuration (varies by type)
object
Secure configuration fields (passwords, API keys). These are encrypted when stored.
string
Database password or API password
string
Basic authentication password

Update Data Source by UID

Update an existing data source.
string
required
Data source unique identifier
The request body uses the same parameters as creating a data source.

Delete Data Source by UID

Delete a data source by its UID.
string
required
Data source unique identifier

Get Data Source by Name

Retrieve a data source by its name.
string
required
Data source name
This endpoint is deprecated. Use the UID-based endpoint instead.

Get Data Source ID by Name

Retrieve a data source ID by its name.
string
required
Data source name
This endpoint is deprecated. Use the UID-based endpoint instead.

Check Data Source Health

Send a health check request to a data source.
string
required
Data source unique identifier
string
Health status: “OK”, “ERROR”, or “UNKNOWN”
string
Health check message
object
Additional health check details (optional)

Permissions

If you are running Grafana Enterprise with Fine-grained access control enabled:
  • Read: Requires datasources:read permission
  • Create: Requires datasources:create permission
  • Update: Requires datasources:write permission with scope datasources:uid:<uid>
  • Delete: Requires datasources:delete permission with scope datasources:uid:<uid>
  • Query: Requires datasources:query permission with scope datasources:uid:<uid>