4cacab01f4
* Use relative aliases for all non-current Grafana aliases Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Remove all current page aliases find docs/sources -type f -name '*.md' -exec sed -z -i 's#\n *- /docs/grafana/latest/[^\n]*\n#\n#' {} \; find docs/sources -type f -name '*.md' -exec sed -Ez -i 's#\n((aliases:\n *-)|aliases:\n)#\n\2#' {} \; Signed-off-by: Jack Baldry <jack.baldry@grafana.com> Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
343 lines
7.4 KiB
Markdown
343 lines
7.4 KiB
Markdown
---
|
|
description: Grafana service account HTTP API
|
|
keywords:
|
|
- grafana
|
|
- http
|
|
- documentation
|
|
- api
|
|
- serviceaccount
|
|
title: 'Service account HTTP API '
|
|
---
|
|
|
|
# Service account API
|
|
|
|
> If you are running Grafana Enterprise and have [Fine-grained access control]({{< relref "../enterprise/access-control/_index.md" >}}) enabled, for some endpoints you would need to have relevant permissions.
|
|
> Refer to specific resources to understand what permissions are required.
|
|
|
|
## Search service accounts with Paging
|
|
|
|
`GET /api/serviceaccounts/search?perpage=10&page=1&query=myserviceaccount`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#user-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| -------------------- | ------------------------- |
|
|
| serviceaccounts:read | global:serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
GET /api/serviceaccounts/search?perpage=10&page=1&query=mygraf HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
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`. Query values with spaces need to be URL encoded e.g. `query=Jane%20Doe`.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
{
|
|
```
|
|
|
|
## Create service account
|
|
|
|
`POST /api/serviceaccounts`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| --------------------- | ------------------ |
|
|
| serviceaccounts:write | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
POST /api/serviceaccounts HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
## Get single serviceaccount by Id
|
|
|
|
`GET /api/serviceaccounts/:id`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| -------------------- | ------------------ |
|
|
| serviceaccounts:read | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
GET /api/serviceaccounts/1 HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
## Update service account
|
|
|
|
`PATCH /api/serviceaccounts/:id`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| --------------------- | ------------------ |
|
|
| serviceaccounts:write | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
PUT /api/serviceaccounts/2 HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
---
|
|
|
|
## Service account tokens
|
|
|
|
## Get service account tokens
|
|
|
|
`GET /api/serviceaccounts/:id/tokens`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| -------------------- | ------------------ |
|
|
| serviceaccounts:read | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
GET /api/serviceaccounts/2/tokens HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
## Create service account tokens
|
|
|
|
`POST /api/serviceaccounts/:id/tokens`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| --------------------- | ------------------ |
|
|
| serviceaccounts:write | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
POST /api/serviceaccounts/2/tokens HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
## Delete service account tokens
|
|
|
|
`DELETE /api/serviceaccounts/:id/tokens/:tokenId`
|
|
|
|
#### Required permissions
|
|
|
|
See note in the [introduction]({{< ref "#serviceaccount-api" >}}) for an explanation.
|
|
|
|
| Action | Scope |
|
|
| --------------------- | ------------------ |
|
|
| serviceaccounts:write | serviceaccounts:\* |
|
|
|
|
**Example Request**:
|
|
|
|
```http
|
|
DELETE /api/serviceaccounts/2/tokens/1 HTTP/1.1
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
|
```
|
|
|
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
|
|
|
**Example Response**:
|
|
|
|
```http
|
|
HTTP/1.1 200
|
|
Content-Type: application/json
|
|
|
|
```
|