Admin API

GET /api/admin/settings

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

Example Request:

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "DEFAULT": {
  5. "app_mode":"production"
  6. },
  7. "analytics": {
  8. "google_analytics_ua_id":"",
  9. "reporting_enabled":"false"
  10. },
  11. "auth.anonymous":{
  12. "enabled":"true",
  13. "org_name":"Main Org.",
  14. "org_role":"Viewer"
  15. },
  16. "auth.basic":{
  17. "enabled":"false"
  18. },
  19. "auth.github":{
  20. "allow_sign_up":"false",
  21. "allowed_domains":"",
  22. "allowed_organizations":"",
  23. "api_url":"https://api.github.com/user",
  24. "auth_url":"https://github.com/login/oauth/authorize",
  25. "client_id":"some_id",
  26. "client_secret":"************",
  27. "enabled":"false",
  28. "scopes":"user:email,read:org",
  29. "team_ids":"",
  30. "token_url":"https://github.com/login/oauth/access_token"
  31. },
  32. "auth.google":{
  33. "allow_sign_up":"false","allowed_domains":"",
  34. "api_url":"https://www.googleapis.com/oauth2/v1/userinfo",
  35. "auth_url":"https://accounts.google.com/o/oauth2/auth",
  36. "client_id":"some_client_id",
  37. "client_secret":"************",
  38. "enabled":"false",
  39. "scopes":"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
  40. "token_url":"https://accounts.google.com/o/oauth2/token"
  41. },
  42. "auth.ldap":{
  43. "config_file":"/etc/grafana/ldap.toml",
  44. "enabled":"false"
  45. },
  46. "auth.proxy":{
  47. "auto_sign_up":"true",
  48. "enabled":"false",
  49. "header_name":"X-WEBAUTH-USER",
  50. "header_property":"username"
  51. },
  52. "dashboards.json":{
  53. "enabled":"false",
  54. "path":"/var/lib/grafana/dashboards"
  55. },
  56. "database":{
  57. "host":"127.0.0.1:0000",
  58. "name":"grafana",
  59. "password":"************",
  60. "path":"grafana.db",
  61. "ssl_mode":"disable",
  62. "type":"sqlite3",
  63. "user":"root"
  64. },
  65. "emails":{
  66. "templates_pattern":"emails/*.html, emails/*.txt",
  67. "welcome_email_on_sign_up":"false",
  68. "content_types":"text/html"
  69. },
  70. "log":{
  71. "buffer_len":"10000",
  72. "level":"Info",
  73. "mode":"file"
  74. },
  75. "log.console":{
  76. "level":""
  77. },
  78. "log.file":{
  79. "daily_rotate":"true",
  80. "file_name":"",
  81. "level":"",
  82. "log_rotate":"true",
  83. "max_days":"7",
  84. "max_lines_shift":"28",
  85. "max_size_shift":""
  86. },
  87. "paths":{
  88. "data":"/tsdb/grafana",
  89. "logs":"/logs/apps/grafana"},
  90. "security":{
  91. "admin_password":"************",
  92. "admin_user":"admin",
  93. "cookie_remember_name":"grafana_remember",
  94. "cookie_username":"grafana_user",
  95. "disable_gravatar":"false",
  96. "login_remember_days":"7",
  97. "secret_key":"************"
  98. },
  99. "server":{
  100. "cert_file":"",
  101. "cert_key":"",
  102. "domain":"mygraf.com",
  103. "enforce_domain":"false",
  104. "http_addr":"127.0.0.1",
  105. "http_port":"0000",
  106. "protocol":"http",
  107. "root_url":"%(protocol)s://%(domain)s:%(http_port)s/",
  108. "router_logging":"true",
  109. "data_proxy_logging":"true",
  110. "static_root_path":"public"
  111. },
  112. "session":{
  113. "cookie_name":"grafana_sess",
  114. "cookie_secure":"false",
  115. "gc_interval_time":"",
  116. "provider":"file",
  117. "provider_config":"sessions",
  118. "session_life_time":"86400"
  119. },
  120. "smtp":{
  121. "cert_file":"",
  122. "enabled":"false",
  123. "from_address":"admin@grafana.localhost",
  124. "from_name":"Grafana",
  125. "ehlo_identity":"dashboard.example.com",
  126. "host":"localhost:25",
  127. "key_file":"",
  128. "password":"************",
  129. "skip_verify":"false",
  130. "user":""
  131. },
  132. "users":{
  133. "allow_org_create":"true",
  134. "allow_sign_up":"false",
  135. "auto_assign_org":"true",
  136. "auto_assign_org_role":"Viewer"
  137. }
  138. }

Update settings

PUT /api/admin/settings

Note: Available in Grafana Enterprise v8.0+.

Updates / removes and reloads database settings. You must provide either updates, removals or both.

This endpoint only supports changes to auth.saml configuration.

Required permissions

See note in the introduction for an explanation.

ActionScope
settings:writesettings:*
settings:auth.saml:

settings:auth.saml:enabled (property level)

Example request:

  1. PUT /api/admin/settings
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "updates": {
  7. "auth.saml": {
  8. "enabled": "true"
  9. }
  10. },
  11. "removals": {
  12. "auth.saml": ["single_logout"]
  13. },
  14. }

Example response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. Content-Length: 32
  4. {
  5. "message":"Settings updated"
  6. }

Status codes:

  • 200 - OK
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 500 - Internal Server Error

Grafana Stats

GET /api/admin/stats

Only works with Basic Authentication (username and password). See introduction for an explanation.

Required permissions

See note in the introduction for an explanation.

ActionScope
server.stats:readn/a

Example Request:

  1. GET /api/admin/stats
  2. Accept: application/json
  3. Content-Type: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "users":2,
  5. "orgs":1,
  6. "dashboards":4,
  7. "snapshots":2,
  8. "tags":6,
  9. "datasources":1,
  10. "playlists":1,
  11. "stars":2,
  12. "alerts":2,
  13. "activeUsers":1
  14. }

Global Users

POST /api/admin/users

Create new user. Only works with Basic Authentication (username and password). See introduction for an explanation.

Required permissions

See note in the introduction for an explanation.

Example Request:

  1. POST /api/admin/users HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. {
  5. "name":"User",
  6. "email":"user@graf.com",
  7. "password":"userpassword",
  8. "OrgId": 1
  9. }

Note that OrgId is an optional parameter that can be used to assign a new user to a different organization when is set to true.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"id":5,"message":"User created"}

Only works with Basic Authentication (username and password). See for an explanation. Change password for a specific user.

Required permissions

See note in the for an explanation.

ActionScope
users.password:updateglobal:users:*

Example Request:

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message": "User password updated"}

Permissions

PUT /api/admin/users/:id/permissions

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

ActionScope
users.permissions:updateglobal:users:*

Example Request:

  1. Accept: application/json
  2. Content-Type: application/json
  3. {"isGrafanaAdmin": true}

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message": "User permissions updated"}

Delete global User

DELETE /api/admin/users/:id

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

Example Request:

  1. DELETE /api/admin/users/2 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message": "User deleted"}

Pause all alerts

POST /api/admin/pause-all-alerts

Only works with Basic Authentication (username and password). See for an explanation.

Example Request:

  1. POST /api/admin/pause-all-alerts HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. {
  5. "paused": true
  6. }

JSON Body schema:

  • paused – If true then all alerts are to be paused, false unpauses all alerts.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "state": "Paused",
  5. "message": "alert paused",
  6. "alertsAffected": 1
  7. }

GET /api/admin/users/:id/auth-tokens

Return a list of all auth tokens (devices) that the user currently have logged in from.

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

ActionScope
users.authtoken:listglobal:users:*

Example Request:

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id": 361,
  6. "isActive": false,
  7. "clientIp": "127.0.0.1",
  8. "browser": "Chrome",
  9. "browserVersion": "72.0",
  10. "os": "Linux",
  11. "osVersion": "",
  12. "device": "Other",
  13. "createdAt": "2019-03-05T21:22:54+01:00",
  14. "seenAt": "2019-03-06T19:41:06+01:00"
  15. },
  16. {
  17. "id": 364,
  18. "isActive": false,
  19. "clientIp": "127.0.0.1",
  20. "browser": "Mobile Safari",
  21. "browserVersion": "11.0",
  22. "os": "iOS",
  23. "osVersion": "11.0",
  24. "device": "iPhone",
  25. "createdAt": "2019-03-06T19:41:19+01:00",
  26. "seenAt": "2019-03-06T19:41:21+01:00"
  27. }
  28. ]

Revoke auth token for User

Revokes the given auth token (device) for the user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

ActionScope
users.authtoken:updateglobal:users:*

Example Request:

  1. POST /api/admin/users/1/revoke-auth-token HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. {
  5. "authTokenId": 364
  6. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "User auth token revoked"
  5. }

Logout User

POST /api/admin/users/:id/logout

Logout user revokes all auth tokens (devices) for the user. User of issued auth tokens (devices) will no longer be logged in and will be required to authenticate again upon next activity.

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

Example Request:

  1. POST /api/admin/users/1/logout HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "User auth token revoked"
  5. }

Reload provisioning configurations

POST /api/admin/provisioning/dashboards/reload

POST /api/admin/provisioning/datasources/reload

POST /api/admin/provisioning/plugins/reload

POST /api/admin/provisioning/notifications/reload

POST /api/admin/provisioning/accesscontrol/reload

Reloads the provisioning config files for specified type and provision entities again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.

Only works with Basic Authentication (username and password). See for an explanation.

Required permissions

See note in the for an explanation.

ActionScopeProvision entity
provisioning:reloadprovisioners:accesscontrolaccesscontrol
provisioning:reloadprovisioners:dashboardsdashboards
provisioning:reloadprovisioners:datasourcesdatasources
provisioning:reloadprovisioners:pluginsplugins
provisioning:reloadprovisioners:notificationsnotifications

Example Request:

  1. POST /api/admin/provisioning/dashboards/reload HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "Dashboards config reloaded"
  5. }

POST /api/admin/ldap/reload

Reloads the LDAP configuration.

Only works with Basic Authentication (username and password). See for an explanation.

Example Request:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {