{"openapi":"3.0.3","info":{"title":"Grafana HTTP API","description":"Grafana HTTP API for the Haiven infrastructure.\n\nThis API provides programmatic access to Grafana's functionality including:\n- Dashboard management (CRUD operations)\n- Data source configuration\n- User and organization management\n- Alert rule management\n- Annotation management\n- Search functionality\n\n## Authentication\n\nGrafana supports multiple authentication methods:\n\n1. **Basic Auth**: Use username and password\n   ```\n   Authorization: Basic base64(username:password)\n   ```\n\n2. **API Key**: Create in Grafana UI (Configuration > API keys)\n   ```\n   Authorization: Bearer <api_key>\n   ```\n\n## Base URL\n\n- Internal: `https://grafana.haiven.site/api`\n- External: `https://grafana.haiven.site/api`\n","version":"11.0","contact":{"name":"Haiven Infrastructure"},"license":{"name":"AGPL-3.0","url":"https://www.gnu.org/licenses/agpl-3.0.html"}},"servers":[{"url":"https://grafana.haiven.site/api","description":"Internal access (haiven.site)"},{"url":"https://grafana.haiven.site/api","description":"External access (haiven.site)"}],"tags":[{"name":"Health","description":"Health check endpoints"},{"name":"Dashboards","description":"Dashboard management"},{"name":"Search","description":"Search dashboards and folders"},{"name":"Data Sources","description":"Data source management"},{"name":"Alerts","description":"Alert rule management"},{"name":"Annotations","description":"Annotation management"},{"name":"Organizations","description":"Organization management"},{"name":"Users","description":"User management"},{"name":"Folders","description":"Folder management"}],"paths":{"/health":{"get":{"tags":["Health"],"summary":"Health check","description":"Returns the health status of the Grafana instance","operationId":"getHealth","security":[],"responses":{"200":{"description":"Grafana is healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/org":{"get":{"tags":["Organizations"],"summary":"Get current organization","description":"Returns the current organization for the authenticated user","operationId":"getCurrentOrg","responses":{"200":{"description":"Current organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/search":{"get":{"tags":["Search"],"summary":"Search dashboards and folders","description":"Search for dashboards and folders by query, tags, type, etc.","operationId":"search","parameters":[{"name":"query","in":"query","description":"Search query string","schema":{"type":"string"}},{"name":"tag","in":"query","description":"Filter by tag(s)","schema":{"type":"array","items":{"type":"string"}}},{"name":"type","in":"query","description":"Filter by type","schema":{"type":"string","enum":["dash-db","dash-folder"]}},{"name":"dashboardIds","in":"query","description":"Filter by dashboard IDs","schema":{"type":"array","items":{"type":"integer"}}},{"name":"folderIds","in":"query","description":"Filter by folder IDs","schema":{"type":"array","items":{"type":"integer"}}},{"name":"starred","in":"query","description":"Return only starred items","schema":{"type":"boolean"}},{"name":"limit","in":"query","description":"Maximum number of results","schema":{"type":"integer","default":1000}},{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SearchResult"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/dashboards/db":{"post":{"tags":["Dashboards"],"summary":"Create or update a dashboard","description":"Creates a new dashboard or updates an existing one","operationId":"createOrUpdateDashboard","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardInput"}}}},"responses":{"200":{"description":"Dashboard created or updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardResponse"}}}},"400":{"description":"Bad request"},"401":{"$ref":"#/components/responses/Unauthorized"},"412":{"description":"Precondition failed (version mismatch)"}}}},"/dashboards/uid/{uid}":{"get":{"tags":["Dashboards"],"summary":"Get dashboard by UID","description":"Returns the dashboard with the given UID","operationId":"getDashboardByUID","parameters":[{"name":"uid","in":"path","required":true,"description":"Dashboard UID","schema":{"type":"string"}}],"responses":{"200":{"description":"Dashboard found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardFullResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Dashboard not found"}}},"delete":{"tags":["Dashboards"],"summary":"Delete dashboard by UID","description":"Deletes the dashboard with the given UID","operationId":"deleteDashboardByUID","parameters":[{"name":"uid","in":"path","required":true,"description":"Dashboard UID","schema":{"type":"string"}}],"responses":{"200":{"description":"Dashboard deleted","content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string"},"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Dashboard not found"}}}},"/datasources":{"get":{"tags":["Data Sources"],"summary":"List all data sources","description":"Returns all configured data sources","operationId":"listDataSources","responses":{"200":{"description":"List of data sources","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DataSource"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Data Sources"],"summary":"Create a data source","description":"Creates a new data source","operationId":"createDataSource","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataSourceInput"}}}},"responses":{"200":{"description":"Data source created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataSource"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Data source with same name already exists"}}}},"/datasources/{id}":{"get":{"tags":["Data Sources"],"summary":"Get data source by ID","description":"Returns the data source with the given ID","operationId":"getDataSourceById","parameters":[{"name":"id","in":"path","required":true,"description":"Data source ID","schema":{"type":"integer"}}],"responses":{"200":{"description":"Data source found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataSource"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Data source not found"}}},"put":{"tags":["Data Sources"],"summary":"Update data source","description":"Updates the data source with the given ID","operationId":"updateDataSource","parameters":[{"name":"id","in":"path","required":true,"description":"Data source ID","schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataSourceInput"}}}},"responses":{"200":{"description":"Data source updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataSource"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Data source not found"}}},"delete":{"tags":["Data Sources"],"summary":"Delete data source","description":"Deletes the data source with the given ID","operationId":"deleteDataSource","parameters":[{"name":"id","in":"path","required":true,"description":"Data source ID","schema":{"type":"integer"}}],"responses":{"200":{"description":"Data source deleted"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Data source not found"}}}},"/alerts":{"get":{"tags":["Alerts"],"summary":"List alert rules","description":"Returns all alert rules for the current organization","operationId":"listAlerts","parameters":[{"name":"dashboardId","in":"query","description":"Filter by dashboard ID","schema":{"type":"integer"}},{"name":"panelId","in":"query","description":"Filter by panel ID","schema":{"type":"integer"}},{"name":"query","in":"query","description":"Filter by alert name","schema":{"type":"string"}},{"name":"state","in":"query","description":"Filter by alert state","schema":{"type":"string","enum":["ok","paused","alerting","pending","no_data"]}},{"name":"limit","in":"query","description":"Maximum number of results","schema":{"type":"integer"}},{"name":"folderId","in":"query","description":"Filter by folder ID","schema":{"type":"array","items":{"type":"integer"}}}],"responses":{"200":{"description":"List of alerts","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Alert"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/annotations":{"get":{"tags":["Annotations"],"summary":"List annotations","description":"Returns annotations matching the query","operationId":"listAnnotations","parameters":[{"name":"from","in":"query","description":"Start time in epoch milliseconds","schema":{"type":"integer","format":"int64"}},{"name":"to","in":"query","description":"End time in epoch milliseconds","schema":{"type":"integer","format":"int64"}},{"name":"limit","in":"query","description":"Maximum number of results","schema":{"type":"integer","default":100}},{"name":"alertId","in":"query","description":"Filter by alert ID","schema":{"type":"integer"}},{"name":"dashboardId","in":"query","description":"Filter by dashboard ID","schema":{"type":"integer"}},{"name":"panelId","in":"query","description":"Filter by panel ID","schema":{"type":"integer"}},{"name":"dashboardUID","in":"query","description":"Filter by dashboard UID","schema":{"type":"string"}},{"name":"type","in":"query","description":"Filter by annotation type","schema":{"type":"string","enum":["annotation","alert"]}},{"name":"tags","in":"query","description":"Filter by tags (comma-separated)","schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"List of annotations","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Annotation"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Annotations"],"summary":"Create annotation","description":"Creates a new annotation","operationId":"createAnnotation","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotationInput"}}}},"responses":{"200":{"description":"Annotation created","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"id":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/annotations/{annotationId}":{"patch":{"tags":["Annotations"],"summary":"Update annotation","description":"Updates an existing annotation","operationId":"updateAnnotation","parameters":[{"name":"annotationId","in":"path","required":true,"description":"Annotation ID","schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotationInput"}}}},"responses":{"200":{"description":"Annotation updated","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Annotation not found"}}},"delete":{"tags":["Annotations"],"summary":"Delete annotation","description":"Deletes an annotation","operationId":"deleteAnnotation","parameters":[{"name":"annotationId","in":"path","required":true,"description":"Annotation ID","schema":{"type":"integer"}}],"responses":{"200":{"description":"Annotation deleted","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Annotation not found"}}}},"/folders":{"get":{"tags":["Folders"],"summary":"List folders","description":"Returns all folders","operationId":"listFolders","parameters":[{"name":"limit","in":"query","description":"Maximum number of folders to return","schema":{"type":"integer"}},{"name":"page","in":"query","description":"Page number","schema":{"type":"integer"}}],"responses":{"200":{"description":"List of folders","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Folder"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Folders"],"summary":"Create folder","description":"Creates a new folder","operationId":"createFolder","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string","description":"Folder title"},"uid":{"type":"string","description":"Folder UID (auto-generated if not provided)"}}}}}},"responses":{"200":{"description":"Folder created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Folder"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Folder with same title already exists"}}}},"/folders/{uid}":{"get":{"tags":["Folders"],"summary":"Get folder by UID","description":"Returns the folder with the given UID","operationId":"getFolderByUID","parameters":[{"name":"uid","in":"path","required":true,"description":"Folder UID","schema":{"type":"string"}}],"responses":{"200":{"description":"Folder found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Folder"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Folder not found"}}},"put":{"tags":["Folders"],"summary":"Update folder","description":"Updates the folder with the given UID","operationId":"updateFolder","parameters":[{"name":"uid","in":"path","required":true,"description":"Folder UID","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"version":{"type":"integer"},"overwrite":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Folder updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Folder"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Folder not found"}}},"delete":{"tags":["Folders"],"summary":"Delete folder","description":"Deletes the folder with the given UID (and all dashboards in it)","operationId":"deleteFolder","parameters":[{"name":"uid","in":"path","required":true,"description":"Folder UID","schema":{"type":"string"}}],"responses":{"200":{"description":"Folder deleted"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Folder not found"}}}},"/user":{"get":{"tags":["Users"],"summary":"Get current user","description":"Returns the current authenticated user","operationId":"getCurrentUser","responses":{"200":{"description":"Current user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/users":{"get":{"tags":["Users"],"summary":"List users","description":"Returns all users (admin only)","operationId":"listUsers","parameters":[{"name":"perpage","in":"query","description":"Number of users per page","schema":{"type":"integer","default":1000}},{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}}],"responses":{"200":{"description":"List of users","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Forbidden (admin access required)"}}}}},"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"Basic authentication with username and password"},"bearerAuth":{"type":"http","scheme":"bearer","description":"API key authentication"}},"responses":{"Unauthorized":{"description":"Authentication required","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Unauthorized"}}}}}}},"schemas":{"HealthResponse":{"type":"object","properties":{"commit":{"type":"string","description":"Git commit hash"},"database":{"type":"string","description":"Database status","example":"ok"},"version":{"type":"string","description":"Grafana version"}}},"Organization":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"}}},"SearchResult":{"type":"object","properties":{"id":{"type":"integer"},"uid":{"type":"string"},"title":{"type":"string"},"uri":{"type":"string"},"url":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["dash-db","dash-folder"]},"tags":{"type":"array","items":{"type":"string"}},"isStarred":{"type":"boolean"},"folderId":{"type":"integer"},"folderUid":{"type":"string"},"folderTitle":{"type":"string"},"folderUrl":{"type":"string"}}},"DashboardInput":{"type":"object","required":["dashboard"],"properties":{"dashboard":{"type":"object","description":"Dashboard model (JSON)","properties":{"id":{"type":"integer","nullable":true,"description":"Dashboard ID (null for new dashboard)"},"uid":{"type":"string","description":"Dashboard UID"},"title":{"type":"string","description":"Dashboard title"},"tags":{"type":"array","items":{"type":"string"}},"timezone":{"type":"string","default":"browser"},"schemaVersion":{"type":"integer"},"version":{"type":"integer"},"refresh":{"type":"string"},"panels":{"type":"array","items":{"type":"object"}}}},"folderId":{"type":"integer","description":"Folder ID to save dashboard in"},"folderUid":{"type":"string","description":"Folder UID to save dashboard in"},"message":{"type":"string","description":"Commit message"},"overwrite":{"type":"boolean","description":"Overwrite existing dashboard with same title"}}},"DashboardResponse":{"type":"object","properties":{"id":{"type":"integer"},"uid":{"type":"string"},"url":{"type":"string"},"status":{"type":"string"},"version":{"type":"integer"},"slug":{"type":"string"}}},"DashboardFullResponse":{"type":"object","properties":{"meta":{"type":"object","properties":{"type":{"type":"string"},"canSave":{"type":"boolean"},"canEdit":{"type":"boolean"},"canAdmin":{"type":"boolean"},"canStar":{"type":"boolean"},"canDelete":{"type":"boolean"},"slug":{"type":"string"},"url":{"type":"string"},"expires":{"type":"string"},"created":{"type":"string","format":"date-time"},"updated":{"type":"string","format":"date-time"},"updatedBy":{"type":"string"},"createdBy":{"type":"string"},"version":{"type":"integer"},"hasAcl":{"type":"boolean"},"isFolder":{"type":"boolean"},"folderId":{"type":"integer"},"folderUid":{"type":"string"},"folderTitle":{"type":"string"},"folderUrl":{"type":"string"},"provisioned":{"type":"boolean"},"provisionedExternalId":{"type":"string"}}},"dashboard":{"type":"object","description":"Dashboard model"}}},"DataSource":{"type":"object","properties":{"id":{"type":"integer"},"orgId":{"type":"integer"},"uid":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"typeName":{"type":"string"},"typeLogoUrl":{"type":"string"},"access":{"type":"string","enum":["proxy","direct"]},"url":{"type":"string"},"user":{"type":"string"},"database":{"type":"string"},"basicAuth":{"type":"boolean"},"basicAuthUser":{"type":"string"},"withCredentials":{"type":"boolean"},"isDefault":{"type":"boolean"},"jsonData":{"type":"object"},"secureJsonFields":{"type":"object"},"version":{"type":"integer"},"readOnly":{"type":"boolean"}}},"DataSourceInput":{"type":"object","required":["name","type","access"],"properties":{"name":{"type":"string"},"type":{"type":"string","description":"Data source type (e.g., prometheus, loki)"},"access":{"type":"string","enum":["proxy","direct"]},"url":{"type":"string"},"user":{"type":"string"},"database":{"type":"string"},"basicAuth":{"type":"boolean"},"basicAuthUser":{"type":"string"},"withCredentials":{"type":"boolean"},"isDefault":{"type":"boolean"},"jsonData":{"type":"object"},"secureJsonData":{"type":"object"}}},"Alert":{"type":"object","properties":{"id":{"type":"integer"},"dashboardId":{"type":"integer"},"dashboardUid":{"type":"string"},"dashboardSlug":{"type":"string"},"panelId":{"type":"integer"},"name":{"type":"string"},"state":{"type":"string","enum":["ok","paused","alerting","pending","no_data"]},"newStateDate":{"type":"string","format":"date-time"},"evalDate":{"type":"string","format":"date-time"},"evalData":{"type":"object"},"executionError":{"type":"string"},"url":{"type":"string"}}},"Annotation":{"type":"object","properties":{"id":{"type":"integer"},"alertId":{"type":"integer"},"alertName":{"type":"string"},"dashboardId":{"type":"integer"},"dashboardUID":{"type":"string"},"panelId":{"type":"integer"},"userId":{"type":"integer"},"userName":{"type":"string"},"newState":{"type":"string"},"prevState":{"type":"string"},"created":{"type":"integer","format":"int64"},"updated":{"type":"integer","format":"int64"},"time":{"type":"integer","format":"int64"},"timeEnd":{"type":"integer","format":"int64"},"text":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}}}},"AnnotationInput":{"type":"object","properties":{"dashboardUID":{"type":"string","description":"Dashboard UID"},"panelId":{"type":"integer","description":"Panel ID"},"time":{"type":"integer","format":"int64","description":"Start time in epoch milliseconds"},"timeEnd":{"type":"integer","format":"int64","description":"End time in epoch milliseconds (for region annotations)"},"text":{"type":"string","description":"Annotation text"},"tags":{"type":"array","items":{"type":"string"},"description":"Annotation tags"}}},"Folder":{"type":"object","properties":{"id":{"type":"integer"},"uid":{"type":"string"},"title":{"type":"string"},"url":{"type":"string"},"hasAcl":{"type":"boolean"},"canSave":{"type":"boolean"},"canEdit":{"type":"boolean"},"canAdmin":{"type":"boolean"},"canDelete":{"type":"boolean"},"createdBy":{"type":"string"},"created":{"type":"string","format":"date-time"},"updatedBy":{"type":"string"},"updated":{"type":"string","format":"date-time"},"version":{"type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"integer"},"email":{"type":"string"},"name":{"type":"string"},"login":{"type":"string"},"theme":{"type":"string"},"orgId":{"type":"integer"},"isGrafanaAdmin":{"type":"boolean"},"isDisabled":{"type":"boolean"},"isExternal":{"type":"boolean"},"authLabels":{"type":"array","items":{"type":"string"}},"updatedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"avatarUrl":{"type":"string"}}}}},"security":[{"basicAuth":[]},{"bearerAuth":[]}]}