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

If you are running Grafana Enterprise and have Fine-grained access control enabled, for some endpoints you would need to have relevant permissions. Refer to specific resources to understand what permissions are required.

Fetch settings

GET /api/admin/settings

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

Required permissions

See note in the introduction for an explanation.

ActionScope
settings:readsettings:*
settings:auth.saml:

settings:auth.saml:enabled (property level)

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, 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":"1000000",
  85. "max_lines_shift":"28",
  86. "max_size_shift":""
  87. },
  88. "paths":{
  89. "data":"/tsdb/grafana",
  90. "logs":"/logs/apps/grafana"},
  91. "security":{
  92. "admin_password":"************",
  93. "admin_user":"admin",
  94. "cookie_remember_name":"grafana_remember",
  95. "cookie_username":"grafana_user",
  96. "disable_gravatar":"false",
  97. "login_remember_days":"7",
  98. "secret_key":"************"
  99. },
  100. "server":{
  101. "cert_file":"",
  102. "cert_key":"",
  103. "domain":"mygraf.com",
  104. "enable_gzip":"false",
  105. "enforce_domain":"false",
  106. "http_addr":"127.0.0.1",
  107. "http_port":"0000",
  108. "protocol":"http",
  109. "root_url":"%(protocol)s://%(domain)s:%(http_port)s/",
  110. "router_logging":"true",
  111. "data_proxy_logging":"true",
  112. "static_root_path":"public"
  113. },
  114. "session":{
  115. "cookie_name":"grafana_sess",
  116. "cookie_secure":"false",
  117. "gc_interval_time":"",
  118. "provider":"file",
  119. "provider_config":"sessions",
  120. "session_life_time":"86400"
  121. },
  122. "smtp":{
  123. "cert_file":"",
  124. "enabled":"false",
  125. "from_address":"admin@grafana.localhost",
  126. "from_name":"Grafana",
  127. "ehlo_identity":"dashboard.example.com",
  128. "host":"localhost:25",
  129. "key_file":"",
  130. "password":"************",
  131. "skip_verify":"false",
  132. "user":""
  133. },
  134. "users":{
  135. "allow_org_create":"true",
  136. "allow_sign_up":"false",
  137. "auto_assign_org":"true",
  138. "auto_assign_org_role":"Viewer"
  139. }
  140. }

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

Grafana Usage Report preview

GET /api/admin/usage-report-preview

Preview usage report to be sent to vendor.

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

Example Request:

  1. GET /api/admin/usage-report-preview
  2. Accept: application/json
  3. Content-Type: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "version": "8_4_0",
  5. "metrics": {
  6. "stats.active_admins.count": 1,
  7. "stats.active_editors.count": 1,
  8. "stats.active_sessions.count": 0,
  9. "stats.active_users.count": 2,
  10. "stats.active_viewers.count": 0,
  11. "stats.admins.count": 1,
  12. "stats.alert_rules.count": 0,
  13. "stats.alerting.ds.other.count": 0,
  14. "stats.alerts.count": 5,
  15. "stats.annotations.count": 6,
  16. "stats.api_keys.count": 1
  17. }
  18. }

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.

ActionScope
users:createn/a

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. "OrgId": 1
  10. }

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

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.

Required permissions

See note in the introduction for an explanation.

ActionScope
users.password:updateglobal:users:*

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.

Required permissions

See note in the introduction for an explanation.

ActionScope
users.permissions:updateglobal:users:*

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.

Required permissions

See note in the introduction for an explanation.

ActionScope
users:deleteglobal:users:*

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.

Required permissions

See note in the introduction for an explanation.

ActionScope
users.authtoken:listglobal:users:*

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.

Required permissions

See note in the introduction 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 introduction for an explanation.

Required permissions

See note in the introduction for an explanation.

ActionScope
users.logoutglobal:users:*

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

Required permissions

See note in the introduction 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. }

Reload LDAP configuration

POST /api/admin/ldap/reload

Reloads the LDAP configuration.

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

Example Request:

  1. POST /api/admin/ldap/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": "LDAP config reloaded"
  5. }