Grafana Data API

The Data API from Grafana — 9 operation(s) for data.

OpenAPI Specification

grafana-data-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Grafana HTTP Access Data API
  description: The Grafana HTTP API provides programmatic access to Grafana's core functionality including dashboards, data sources, alerts, users, organizations, folders, annotations, and teams. Authentication is handled via API keys, basic auth, or OAuth tokens passed in the Authorization header.
  version: 11.0.0
  contact:
    name: Grafana Labs
    url: https://grafana.com
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
servers:
- url: https://{instance}.grafana.net/api
  description: Grafana Cloud
  variables:
    instance:
      default: your-instance
- url: http://localhost:3000/api
  description: Local Grafana instance
security:
- BearerAuth: []
- BasicAuth: []
- ApiKeyAuth: []
tags:
- name: Data
paths:
  /datasources:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Sources
      description: The GET /datasources endpoint in the Grafana HTTP API retrieves a list of all configured data sources within the Grafana instance. This operation returns an array of data source objects, each containing details such as the data source ID, name, type (like Prometheus, InfluxDB, or Elasticsearch), URL, access method, and other configuration parameters. Authentication is required to access this endpoint, and the response will only include data sources that the authenticated user has permission to view based on their role and organizational membership. This endpoint is commonly used for discovering available data sources, validating configurations, or building administrative tools that need to enumerate and manage data source connections within Grafana.
      operationId: getDataSources
      parameters: []
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DataSourceListItemDTO'
                description: ''
                contentMediaType: application/json
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    post:
      tags:
      - Data
      summary: Grafana Add Data Source
      description: Adds a new data source to Grafana by creating a configuration that defines how Grafana connects to and retrieves data from external systems such as Prometheus, Elasticsearch, MySQL, or other supported data sources. This POST operation requires authentication and accepts a JSON payload containing the data source properties including the type, name, access mode (proxy or direct), URL, database credentials if applicable, and any additional JSON data specific to the data source type. Upon successful creation, the API returns the newly created data source object with its assigned unique identifier, allowing users to reference and use this data source in dashboards, alerts, and queries throughout the Grafana instance.
      operationId: addDataSource
      parameters: []
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddDataSourceCommand'
        required: true
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createOrUpdateDatasourceResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '409':
          description: ConflictError
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/id/{name}:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Source Id By Name
      description: This API operation retrieves the unique identifier of a Grafana data source by providing its name as a path parameter. It performs a GET request to the endpoint '/datasources/id/{name}' where {name} is replaced with the actual name of the data source you want to look up. The operation returns the numeric ID associated with that specific data source, which can be useful for subsequent API calls that require the data source ID rather than its name. This is particularly helpful when you need to programmatically reference data sources in scripts or applications where you know the name but need the ID for other operations.
      operationId: getDataSourceIdByName
      parameters:
      - name: name
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getDataSourceIDResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/name/{name}:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Source By Name
      description: This API operation retrieves a specific data source configuration from Grafana by using its unique name as an identifier. When you send a GET request to the endpoint with the data source name as a path parameter, Grafana returns the complete configuration details of that data source, including its type, connection settings, authentication credentials, and other relevant metadata. This is particularly useful when you need to programmatically access or verify the configuration of a specific data source without knowing its numeric ID, making it more intuitive for automation scripts and integrations that work with human-readable names rather than database identifiers.
      operationId: getDataSourceByName
      parameters:
      - name: name
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataSource'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    delete:
      tags:
      - Data
      summary: Grafana Delete Data Source By Name
      description: Removes a data source from Grafana by specifying its unique name rather than its numeric ID. This operation permanently deletes the data source configuration including all associated settings, credentials, and metadata. Once deleted, any dashboards or panels that reference this data source will no longer function properly until reconfigured with an alternative data source. This endpoint is particularly useful when automating data source management through scripts or infrastructure-as-code tools where the data source name is known but the internal ID is not readily available.
      operationId: deleteDataSourceByName
      parameters:
      - name: name
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deleteDataSourceByNameResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/uid/{uid}:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Source By UID
      description: This API operation retrieves detailed information about a specific data source in Grafana by providing its unique identifier (UID). When called with a GET request to the endpoint /datasources/uid/{uid}, it returns the complete configuration and metadata for the requested data source, including its name, type, access method, connection details, and other relevant settings. This endpoint is particularly useful when you need to programmatically query or verify the configuration of a specific data source using its immutable UID rather than its numeric ID, which may change across different Grafana instances or during migrations.
      operationId: getDataSourceByUID
      parameters:
      - name: uid
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataSource'
        '400':
          description: BadRequestError is returned when the request is invalid and it cannot be processed.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    put:
      tags:
      - Data
      summary: Grafana Update Data Source By UID
      description: This API operation updates an existing data source in Grafana by specifying its unique identifier (UID) in the URL path. The PUT request allows administrators to modify the configuration of a data source, including its name, type, URL, authentication settings, and other connection parameters. The operation requires the data source's UID as a path parameter and accepts a JSON payload containing the updated data source configuration in the request body. Upon successful execution, it returns the updated data source object with all its properties, making it useful for programmatically managing and maintaining data source configurations in Grafana instances without needing to access the user interface.
      operationId: updateDataSourceByUID
      parameters:
      - name: uid
        in: path
        description: ''
        required: true
        schema:
          type: string
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDataSourceCommand'
        required: true
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createOrUpdateDatasourceResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '409':
          description: ConflictError
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    delete:
      tags:
      - Data
      summary: Grafana Delete Data Source By UID
      description: Deletes a data source from Grafana by its unique identifier (UID). This operation permanently removes the specified data source configuration from the Grafana instance, including all its settings and connection details. The UID parameter in the URL path identifies which data source to delete. This is a destructive action that cannot be undone, and any dashboards or panels relying on this data source will lose their connection to it. Proper permissions are required to execute this operation, typically requiring admin or editor roles with data source management capabilities.
      operationId: deleteDataSourceByUID
      parameters:
      - name: uid
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: An OKResponse is returned if the request was successful.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponseBody'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/{id}:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Source By ID
      description: Retrieves detailed information about a specific data source in Grafana by providing its unique identifier. This endpoint returns comprehensive configuration details for the data source including its name, type, URL, access mode, authentication settings, and other metadata associated with the specified ID. It requires appropriate permissions to view data source configurations and is commonly used when you need to inspect or verify the settings of a particular data source that has already been configured in your Grafana instance.
      operationId: getDataSourceByID
      parameters:
      - name: id
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataSource'
        '400':
          description: BadRequestError is returned when the request is invalid and it cannot be processed.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: true
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    put:
      tags:
      - Data
      summary: Grafana Update Data Source By ID
      description: Updates an existing data source in Grafana by specifying its unique identifier in the URL path. This PUT operation requires the complete data source configuration including connection details, authentication credentials, and any custom settings. The request must include all data source properties as the PUT method typically replaces the entire resource rather than partially updating it. Users need appropriate permissions to modify data sources, and the operation returns the updated data source configuration upon success. This endpoint is commonly used when reconfiguring database connections, updating credentials, or modifying data source settings through automation or administrative interfaces.
      operationId: updateDataSourceByID
      parameters:
      - name: id
        in: path
        description: ''
        required: true
        schema:
          type: string
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDataSourceCommand'
        required: true
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createOrUpdateDatasourceResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: true
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    delete:
      tags:
      - Data
      summary: Grafana Delete Data Source By ID
      description: This API operation removes a specific data source from Grafana by referencing its unique identifier. When executed, it performs a DELETE request to the endpoint /datasources/{id}, where {id} represents the numeric identifier of the data source to be removed. The operation permanently deletes the data source configuration from Grafana, including all its associated settings and connection details. This action requires appropriate administrative permissions and cannot be undone once completed. Upon successful deletion, the data source will no longer be available for use in dashboards or queries within the Grafana instance.
      operationId: deleteDataSourceByID
      parameters:
      - name: id
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: An OKResponse is returned if the request was successful.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponseBody'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '403':
          description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '404':
          description: NotFoundError is returned when the requested resource was not found.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: true
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/{dataSourceUID}/cache:
    parameters: []
    get:
      tags:
      - Data
      summary: Grafana Get Data Source Cache Config
      description: Retrieves the caching configuration settings for a specific data source in Grafana identified by its unique identifier (dataSourceUID). This GET operation allows administrators and users with appropriate permissions to view the current cache configuration parameters associated with a particular data source, which may include settings such as cache TTL (time-to-live), cache size limits, and enabled/disabled status. The response provides insight into how query results from this data source are being cached to optimize performance and reduce load on the underlying data source system.
      operationId: getDataSourceCacheConfig
      parameters:
      - name: dataSourceUID
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: CacheConfigResponse
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CacheConfigResponse'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    post:
      tags:
      - Data
      summary: Grafana Set Data Source Cache Config
      description: Sets the cache configuration for a specific data source in Grafana identified by its unique identifier (dataSourceUID). This POST operation allows administrators to configure caching parameters such as TTL (time-to-live), cache size limits, and other cache-related settings that control how query results from the data source are stored and retrieved. By enabling and configuring caching at the data source level, users can improve dashboard performance and reduce the load on backend data sources by serving frequently requested data from cache rather than executing redundant queries.
      operationId: setDataSourceCacheConfig
      parameters:
      - name: dataSourceUID
        in: path
        description: ''
        required: true
        schema:
          type: string
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CacheConfigSetter'
        required: true
      responses:
        '200':
          description: CacheConfigResponse
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CacheConfigResponse'
        '400':
          description: BadRequestError is returned when the request is invalid and it cannot be processed.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /datasources/{dataSourceUID}/cache/clean:
    parameters: []
    post:
      tags:
      - Data
      summary: Grafana Clean Data Source Cache
      description: This API operation allows you to clear the cache for a specific data source in Grafana by sending a POST request to the endpoint with the data source's unique identifier (UID). When invoked, it removes all cached query results and stored data associated with that particular data source, forcing subsequent queries to fetch fresh data directly from the source. This is useful when you need to ensure users see the most up-to-date information, troubleshoot data inconsistencies, or after making configuration changes to the data source that might affect cached results.
      operationId: cleanDataSourceCac

# --- truncated at 32 KB (44 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/grafana/refs/heads/main/openapi/grafana-data-api-openapi.yml