2022-05-26 23:06:25 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../../http_api/org/
- ../../http_api/organization/
2023-02-07 01:14:36 +08:00
canonical: /docs/grafana/latest/developers/http_api/org/
2022-05-26 23:06:25 +08:00
description: Grafana Organization HTTP API
keywords:
- grafana
- http
- documentation
- api
- organization
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2022-12-10 00:36:04 +08:00
title: Organization HTTP API
2022-05-26 23:06:25 +08:00
---
2016-11-24 17:16:24 +08:00
2018-11-29 03:33:41 +08:00
# Organization API
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
The Organization HTTP API is divided in two resources, `/api/org` (current organization)
and `/api/orgs` (admin organizations). One big difference between these are that
the admin of all organizations API only works with basic authentication, see [Admin Organizations API ](#admin-organizations-api ) for more information.
2018-06-30 01:08:38 +08:00
2025-03-06 20:59:08 +08:00
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions](/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes/) for more information.
2021-05-21 00:53:34 +08:00
2018-11-29 03:33:41 +08:00
## Current Organization API
2018-06-30 01:08:38 +08:00
2018-11-29 03:33:41 +08:00
### Get current Organization
2016-02-03 14:59:22 +08:00
2017-10-25 14:15:51 +08:00
`GET /api/org/`
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| --------- | ----- |
| orgs:read | N/A |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2017-10-25 14:15:51 +08:00
GET /api/org/ HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"id":1,
"name":"Main Org."
}
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Get all users within the current organization
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
`GET /api/org/users`
2016-02-03 14:59:22 +08:00
2019-08-13 02:03:48 +08:00
Returns all org users within the current organization.
Accessible to users with org admin role.
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| -------------- | -------- |
| org.users:read | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
GET /api/org/users HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2018-06-30 01:08:38 +08:00
[
{
2019-08-13 02:03:48 +08:00
"orgId": 1,
"userId": 1,
"email": "admin@localhost",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
"login": "admin",
"role": "Admin",
"lastSeenAt": "2019-08-09T11:02:49+02:00",
"lastSeenAtAge": "< 1m "
}
]
```
### Get all users within the current organization (lookup)
`GET /api/org/users/lookup`
Returns all org users within the current organization, but with less detailed information.
Accessible to users with org admin role, admin in any folder or admin of any team.
Mainly used by Grafana UI for providing list of users when adding team members and
when editing folder/dashboard permissions.
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| -------------- | -------- |
| org.users:read | users:\* |
2019-08-13 02:03:48 +08:00
**Example Request**:
```http
GET /api/org/users/lookup HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
[
{
"userId": 1,
"login": "admin",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
2017-10-06 01:01:03 +08:00
}
2018-06-30 01:08:38 +08:00
]
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
### Updates the given user
`PATCH /api/org/users/:userId`
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2022-06-02 20:14:48 +08:00
| Action | Scope |
| --------------- | -------- |
| org.users:write | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
PATCH /api/org/users/1 HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2018-06-30 01:08:38 +08:00
{
"role": "Viewer",
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2018-06-30 01:08:38 +08:00
{"message":"Organization user updated"}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Delete user in current organization
2016-11-16 16:06:05 +08:00
2018-06-30 01:08:38 +08:00
`DELETE /api/org/users/:userId`
2016-11-16 16:06:05 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| ---------------- | -------- |
| org.users:remove | users:\* |
2021-05-21 00:53:34 +08:00
2016-11-16 16:06:05 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
DELETE /api/org/users/1 HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-11-16 16:06:05 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-11-16 16:06:05 +08:00
2018-06-30 01:08:38 +08:00
{"message":"User removed from organization"}
2017-10-06 01:01:03 +08:00
```
2016-11-16 16:06:05 +08:00
2018-11-29 03:33:41 +08:00
### Update current Organization
2016-02-03 14:59:22 +08:00
`PUT /api/org`
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| ---------- | ----- |
| orgs:write | N/A |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
PUT /api/org HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"name":"Main Org."
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{"message":"Organization updated"}
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Add a new user to the current organization
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
`POST /api/org/users`
2018-11-29 03:33:41 +08:00
Adds a global user to the current organization.
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| ------------- | -------- |
| org.users:add | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
POST /api/org/users HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2018-06-30 01:08:38 +08:00
{
"role": "Admin",
"loginOrEmail": "admin"
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2020-09-14 14:58:23 +08:00
{"message":"User added to organization","userId":1}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
## Admin Organizations API
2016-02-03 14:59:22 +08:00
2024-08-29 17:50:11 +08:00
{{< admonition type = "caution" > }}
You can't authenticate to the Admin Organizations HTTP API with service account tokens.
Service accounts are limited to an organization and an organization role.
They can't be granted [Grafana server administrator permissions ](/docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/#grafana-server-administrators ).
To use these API endpoints you have to use Basic authentication and the Grafana user must have the Grafana server administrator permission.
The `admin` user that Grafana is provisioned with by default has permissions to use these API endpoints.
{{< / admonition > }}
2018-06-30 01:08:38 +08:00
2018-11-29 03:33:41 +08:00
### Get Organization by Id
2018-06-30 01:08:38 +08:00
`GET /api/orgs/:orgId`
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| --------- | ----- |
| orgs:read | N/A |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
GET /api/orgs/1 HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
{
"id":1,
"name":"Main Org.",
"address":{
"address1":"",
"address2":"",
"city":"",
"zipCode":"",
"state":"",
"country":""
}
}
2017-10-06 01:01:03 +08:00
```
2021-08-06 21:52:36 +08:00
2018-11-29 03:33:41 +08:00
### Get Organization by Name
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
`GET /api/orgs/name/:orgName`
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope | Note |
| --------- | ----- | ------------------------------ |
| orgs:read | N/A | Needs to be assigned globally. |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
GET /api/orgs/name/Main%20Org%2E HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
{
"id":1,
"name":"Main Org.",
"address":{
"address1":"",
"address2":"",
"city":"",
"zipCode":"",
"state":"",
"country":""
}
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Create Organization
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
`POST /api/orgs`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope | Note |
| ----------- | ----- | ------------------------------ |
| orgs:create | N/A | Needs to be assigned globally. |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-06-30 01:08:38 +08:00
POST /api/orgs HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
Content-Type: application/json
2018-06-30 01:08:38 +08:00
{
"name":"New Org."
}
2017-10-06 01:01:03 +08:00
```
2021-08-06 21:52:36 +08:00
2018-06-30 01:08:38 +08:00
Note: The api will work in the following two ways
2021-08-06 21:52:36 +08:00
1. Need to set GF_USERS_ALLOW_ORG_CREATE=true
2. Set the config value users.allow_org_create to true in ini file
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2018-06-30 01:08:38 +08:00
{
"orgId":"1",
"message":"Organization created"
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Search all Organizations
2016-02-03 14:59:22 +08:00
2020-08-12 15:59:07 +08:00
`GET /api/orgs?perpage=10&page=1`
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope | Note |
| --------- | ----- | ------------------------------ |
| orgs:read | N/A | Needs to be assigned globally. |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
GET /api/orgs HTTP/1.1
Accept: application/json
Content-Type: application/json
```
2021-08-06 21:52:36 +08:00
2017-10-25 14:15:51 +08:00
Note: The api will only work when you pass the admin name and password
2020-02-15 00:11:08 +08:00
to the request HTTP URL, like http://admin:admin@localhost:3000/api/orgs
2016-02-03 14:59:22 +08:00
2020-08-12 15:59:07 +08:00
Default value for the `perpage` parameter is `1000` and for the `page` parameter is `0` .
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
[
{
"id":1,
"name":"Main Org."
}
]
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Update Organization
2016-02-03 14:59:22 +08:00
`PUT /api/orgs/:orgId`
2021-08-06 21:52:36 +08:00
Update Organization, fields _Address 1_ , _Address 2_ , _City_ are not implemented yet.
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| ---------- | ----- |
| orgs:write | N/A |
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
PUT /api/orgs/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"name":"Main Org 2."
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{"message":"Organization updated"}
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Delete Organization
2018-06-15 03:25:45 +08:00
`DELETE /api/orgs/:orgId`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-11-24 17:08:55 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-11-24 17:08:55 +08:00
| Action | Scope |
| ----------- | ----- |
| orgs:delete | N/A |
2018-06-15 03:25:45 +08:00
**Example Request**:
```http
DELETE /api/orgs/1 HTTP/1.1
Accept: application/json
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{"message":"Organization deleted"}
```
2018-11-29 03:33:41 +08:00
### Get Users in Organization
2016-02-03 14:59:22 +08:00
`GET /api/orgs/:orgId/users`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| -------------- | -------- |
| org.users:read | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
GET /api/orgs/1/users HTTP/1.1
Accept: application/json
Content-Type: application/json
```
2021-08-06 21:52:36 +08:00
2017-10-25 14:15:51 +08:00
Note: The api will only work when you pass the admin name and password
2020-02-15 00:11:08 +08:00
to the request HTTP URL, like http://admin:admin@localhost:3000/api/orgs/1/users
2017-10-25 14:15:51 +08:00
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
[
{
"orgId":1,
"userId":1,
"email":"admin@mygraf.com",
"login":"admin",
"role":"Admin"
}
]
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Add User in Organization
2016-02-03 14:59:22 +08:00
`POST /api/orgs/:orgId/users`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| ------------- | -------- |
| org.users:add | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
POST /api/orgs/1/users HTTP/1.1
Accept: application/json
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"loginOrEmail":"user",
"role":"Viewer"
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2020-09-14 14:58:23 +08:00
{"message":"User added to organization", "userId": 1}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Update Users in Organization
2016-02-03 14:59:22 +08:00
`PATCH /api/orgs/:orgId/users/:userId`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2022-06-02 20:14:48 +08:00
| Action | Scope |
| --------------- | -------- |
| org.users:write | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
PATCH /api/orgs/1/users/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"role":"Admin"
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{"message":"Organization user updated"}
```
2016-02-03 14:59:22 +08:00
2018-11-29 03:33:41 +08:00
### Delete User in Organization
2016-02-03 14:59:22 +08:00
`DELETE /api/orgs/:orgId/users/:userId`
2018-11-29 03:33:41 +08:00
Only works with Basic Authentication (username and password), see [introduction ](#admin-organizations-api ).
2018-06-30 01:08:38 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
2021-05-21 00:53:34 +08:00
2025-03-06 20:59:08 +08:00
See note in the [introduction ](#organization-api ) for an explanation.
2021-05-21 00:53:34 +08:00
2021-08-06 21:52:36 +08:00
| Action | Scope |
| ---------------- | -------- |
| org.users:remove | users:\* |
2021-05-21 00:53:34 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
DELETE /api/orgs/1/users/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{"message":"User removed from organization"}
2018-04-14 02:02:45 +08:00
```