docs/sources/developer-resources/api-reference/http-api/api-legacy/team.md
{{< docs/shared lookup="developers/deprecated-apis.md" source="grafana" version="<GRAFANA_VERSION>" >}}
This API can be used to manage Teams and Team Memberships.
Access to these API endpoints is restricted as follows:
If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to Role-based access control permissions for more information.
GET /api/teams/search?perpage=50&page=1&query=myteam&sort=memberCount-desc
or
GET /api/teams/search?name=myteam
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:read | teams:* |
Example Request:
GET /api/teams/search?perpage=10&page=1&query=mytestteam HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"totalCount": 1,
"teams": [
{
"id": 1,
"orgId": 1,
"name": "MyTestTeam",
"email": "",
"avatarUrl": "\/avatar\/3f49c15916554246daa714b9bd0ee398",
"memberCount": 1
}
],
"page": 1,
"perPage": 1000
}
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 teams list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams.
The query parameter is optional and it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded e.g. query=my%20team.
The sort param is an optional comma separated list of options to order the search result. Accepted values for the sort filter are: name-asc, name-desc, email-asc, email-desc, memberCount-asc, memberCount-desc. By default, if sort is not specified, the teams list will be ordered by name in ascending order.
The name parameter returns a single team if the parameter matches the name field.
GET /api/teams/:id
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:read | teams:* |
Example Request:
GET /api/teams/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"id": 1,
"orgId": 1,
"name": "MyTestTeam",
"email": "",
"created": "2017-12-15T10:40:45+01:00",
"updated": "2017-12-15T10:40:45+01:00"
}
Status Codes:
The Team name needs to be unique. name is required and email is optional.
POST /api/teams
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:create | N/A |
Example Request:
POST /api/teams HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
{
"name": "MyTestTeam",
"email": "[email protected]",
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Team created","teamId":2,"uid":"ceaulqadfoav4e"}
Status Codes:
There are two fields that can be updated for a team: name and email.
PUT /api/teams/:id
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:write | teams:* |
Example Request:
PUT /api/teams/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
{
"name": "MyTestTeam",
"email": "[email protected]"
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Team updated"}
Status Codes:
DELETE /api/teams/:id
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:delete | teams:* |
Example Request:
DELETE /api/teams/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Team deleted"}
Status Codes:
GET /api/teams/:teamId/members
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams.permissions:read | teams:* |
Example Request:
GET /api/teams/1/members HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
Example Response:
HTTP/1.1 200
Content-Type: application/json
[
{
"orgId": 1,
"teamId": 1,
"userId": 3,
"email": "[email protected]",
"login": "user1",
"avatarUrl": "\/avatar\/1b3c32f6386b0185c40d359cdc733a79"
},
{
"orgId": 1,
"teamId": 1,
"userId": 2,
"email": "[email protected]",
"login": "user2",
"avatarUrl": "\/avatar\/cad3c68da76e45d10269e8ef02f8e73e"
}
]
Status Codes:
POST /api/teams/:teamId/members
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams.permissions:write | teams:* |
Example Request:
POST /api/teams/1/members HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
{
"userId": 2
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Member added to Team"}
Status Codes:
DELETE /api/teams/:teamId/members/:userId
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams.permissions:write | teams:* |
Example Request:
DELETE /api/teams/2/members/3 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Team Member removed"}
Status Codes:
Allows bulk updating team members and administrators using user emails. Will override all current members and administrators for the specified team.
`PUT /api/teams/:teamId/members
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams.permissions:write | teams:* |
Example Request:
PUT /api/teams/1/members HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer glsa_iNValIdinValiDinvalidinvalidinva_5b582697
{
"members": ["[email protected]", "[email protected]"]
"admins": ["[email protected]"]
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Team memberships have been updated"}
Status Codes:
GET /api/teams/:teamId/preferences
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:read | teams:* |
Example Request:
GET /api/teams/2/preferences HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"theme": "",
"homeDashboardId": 0,
"homeDashboardUID": "",
"timezone": ""
}
PUT /api/teams/:teamId/preferences
Required permissions
See note in the introduction for an explanation.
| Action | Scope |
|---|---|
| teams:write | teams:* |
Example Request:
PUT /api/teams/2/preferences HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"theme": "dark",
"homeDashboardId": 39,
"homeDashboardUID": "jcIIG-07z",
"timezone": "utc"
}
JSON Body Schema:
light, dark, or an empty string for the default themehomeDashboardUID instead.:uid of a dashboardutc, browser, or an empty string for the defaultOmitting a key will cause the current value to be replaced with the system default value.
Example Response:
HTTP/1.1 200
Content-Type: text/plain; charset=utf-8
{
"message":"Preferences updated"
}