Admin API

The Admin HTTP API does not currently work with an API Token. API Tokens are currently only linked to an organization and an organization role. They cannot be given the permission of server admin, only users can be given that permission. So in order to use these API calls you will have to use Basic Auth and the Grafana user must have the Grafana Admin permission. (The default admin user is called admin and has permission to use this API.)

Settings

GET /api/admin/settings

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

Example Request:

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

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",
  67. "welcome_email_on_sign_up":"false"
  68. },
  69. "log":{
  70. "buffer_len":"10000",
  71. "level":"Info",
  72. "mode":"file"
  73. },
  74. "log.console":{
  75. "level":""
  76. },
  77. "log.file":{
  78. "daily_rotate":"true",
  79. "file_name":"",
  80. "level":"",
  81. "log_rotate":"true",
  82. "max_days":"7",
  83. "max_lines":"1000000",
  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. "enable_gzip":"false",
  104. "enforce_domain":"false",
  105. "http_addr":"127.0.0.1",
  106. "http_port":"0000",
  107. "protocol":"http",
  108. "root_url":"%(protocol)s://%(domain)s:%(http_port)s/",
  109. "router_logging":"true",
  110. "data_proxy_logging":"true",
  111. "static_root_path":"public"
  112. },
  113. "session":{
  114. "cookie_name":"grafana_sess",
  115. "cookie_secure":"false",
  116. "gc_interval_time":"",
  117. "provider":"file",
  118. "provider_config":"sessions",
  119. "session_life_time":"86400"
  120. },
  121. "smtp":{
  122. "cert_file":"",
  123. "enabled":"false",
  124. "from_address":"admin@grafana.localhost",
  125. "from_name":"Grafana",
  126. "ehlo_identity":"dashboard.example.com",
  127. "host":"localhost:25",
  128. "key_file":"",
  129. "password":"************",
  130. "skip_verify":"false",
  131. "user":""
  132. },
  133. "users":{
  134. "allow_org_create":"true",
  135. "allow_sign_up":"false",
  136. "auto_assign_org":"true",
  137. "auto_assign_org_role":"Viewer"
  138. }
  139. }

Grafana Stats

GET /api/admin/stats

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

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.

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. "login":"user",
  8. "password":"userpassword"
  9. }

Example Response:

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

Password for User

PUT /api/admin/users/:id/password

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

Example Request:

  1. PUT /api/admin/users/2/password HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. {"password":"userpassword"}

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 introduction for an explanation.

Example Request:

  1. PUT /api/admin/users/2/permissions HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. {"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 introduction 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 introduction 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. }

Auth tokens for User

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 introduction for an explanation.

Example Request:

  1. GET /api/admin/users/1/auth-tokens 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. {
  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

POST /api/admin/users/:id/revoke-auth-token

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 introduction for an explanation.

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 introduction 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/notifications/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 configs after returning.

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

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. }