User HTTP resources / actions

Search Users

GET /api/users?perpage=10&page=1

Example Request:

  1. GET /api/users HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Default value for the perpage parameter is 1000 and for the page parameter is 1. Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id": 1,
  6. "name": "Admin",
  7. "login": "admin",
  8. "email": "admin@mygraf.com",
  9. "isAdmin": true
  10. },
  11. {
  12. "id": 2,
  13. "name": "User",
  14. "login": "user",
  15. "email": "user@mygraf.com",
  16. "isAdmin": false
  17. }
  18. ]

Search Users with Paging

GET /api/users/search?perpage=10&page=1&query=mygraf

Example Request:

  1. GET /api/users/search?perpage=10&page=1&query=mygraf HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Default value for the perpage parameter is 1000 and for the page parameter is 1. The totalCount field in the response can be used for pagination of the user list E.g. if totalCount is equal to 100 users and the perpage parameter is set to 10 then there are 10 pages of users. The query parameter is optional and it will return results where the query value is contained in one of the name, login or email fields. Query values with spaces need to be url encoded e.g. query=Jane%20Doe.

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "totalCount": 2,
  5. "users": [
  6. {
  7. "id": 1,
  8. "name": "Admin",
  9. "login": "admin",
  10. "email": "admin@mygraf.com",
  11. "isAdmin": true
  12. },
  13. {
  14. "id": 2,
  15. "name": "User",
  16. "login": "user",
  17. "email": "user@mygraf.com",
  18. "isAdmin": false
  19. }
  20. ],
  21. "page": 1,
  22. "perPage": 10
  23. }

Get single user by Id

GET /api/users/:id

Example Request:

  1. GET /api/users/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "email": "user@mygraf.com"
  5. "name": "admin",
  6. "login": "admin",
  7. "theme": "light",
  8. "orgId": 1,
  9. "isGrafanaAdmin": true
  10. }

Get single user by Username(login) or Email

GET /api/users/lookup?loginOrEmail=user@mygraf.com

Example Request using the email as option:

  1. GET /api/users/lookup?loginOrEmail=user@mygraf.com HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Request using the username as option:

  1. GET /api/users/lookup?loginOrEmail=admin HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "email": "user@mygraf.com",
  6. "name": "admin",
  7. "login": "admin",
  8. "theme": "light",
  9. "orgId": 1,
  10. "isGrafanaAdmin": true
  11. }

User Update

PUT /api/users/:id

Example Request:

  1. PUT /api/users/2 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=
  5. {
  6. "email":"user@mygraf.com",
  7. "name":"User2",
  8. "login":"user",
  9. "theme":"light"
  10. }

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

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

Get Organizations for user

GET /api/users/:id/orgs

Example Request:

  1. GET /api/users/1/orgs HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "orgId":1,
  6. "name":"Main Org.",
  7. "role":"Admin"
  8. }
  9. ]

Get Teams for user

GET /api/users/:id/teams

Example Request:

  1. GET /api/users/1/teams HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Basic YWRtaW46YWRtaW4=

Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id":1,
  6. "orgId":1,
  7. "name":"team1",
  8. "email":"",
  9. "avatarUrl":"/avatar/3fcfe295eae3bcb67a49349377428a66",
  10. "memberCount":1
  11. }
  12. ]

User

Actual User

GET /api/user

Example Request:

  1. GET /api/user HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "email":"admin@mygraf.com",
  5. "name":"Admin",
  6. "login":"admin",
  7. "theme":"light",
  8. "orgId":1,
  9. "isGrafanaAdmin":true
  10. }

Change Password

PUT /api/user/password

Changes the password for the user

Example Request:

  1. PUT /api/user/password HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "oldPassword": "old_password",
  7. "newPassword": "new_password",
  8. "confirmNew": "confirm_new_password"
  9. }

Example Response:

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

Switch user context for a specified user

POST /api/users/:userId/using/:organizationId

Switch user context to the given organization. Requires basic authentication and that the authenticated user is a Grafana Admin.

Example Request:

  1. POST /api/users/7/using/2 HTTP/1.1
  2. Authorization: Basic YWRtaW46YWRtaW4=

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Active organization changed"}

Switch user context for signed in user

POST /api/user/using/:organizationId

Switch user context to the given organization.

Example Request:

  1. POST /api/user/using/2 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Active organization changed"}

Organizations of the actual User

GET /api/user/orgs

Return a list of all organizations of the current user.

Example Request:

  1. GET /api/user/orgs HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "orgId":1,
  6. "name":"Main Org.",
  7. "role":"Admin"
  8. }
  9. ]

Teams that the actual User is member of

GET /api/user/teams

Return a list of all teams that the current user is member of.

Example Request:

  1. GET /api/user/teams HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id": 1,
  6. "orgId": 1,
  7. "name": "MyTestTeam",
  8. "email": "",
  9. "avatarUrl": "\/avatar\/3f49c15916554246daa714b9bd0ee398",
  10. "memberCount": 1
  11. }
  12. ]

Star a dashboard

POST /api/user/stars/dashboard/:dashboardId

Stars the given Dashboard for the actual user.

Example Request:

  1. POST /api/user/stars/dashboard/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Dashboard starred!"}

Unstar a dashboard

DELETE /api/user/stars/dashboard/:dashboardId

Deletes the starring of the given Dashboard for the actual user.

Example Request:

  1. DELETE /api/user/stars/dashboard/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

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

Auth tokens of the actual User

GET /api/user/auth-tokens

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

Example Request:

  1. GET /api/user/auth-tokens HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id": 361,
  6. "isActive": true,
  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 an auth token of the actual User

POST /api/user/revoke-auth-token

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

Example Request:

  1. POST /api/user/revoke-auth-token HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "authTokenId": 364
  7. }

Example Response:

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