Manage Workspaces¶
POST /api/v1/mgroup/{group_uuid}/modify/workspace
Overview¶
Completely replaces the cross-workspace role authorization of a backend group.
Prerequisites and Usage Steps¶
First enable showRefWorkspace through Backend Group List to read the existing complete mapping, then verify the target roles per workspace from Workspace Role List. When refWorkspaces is present, it is replaced as a whole; old workspace authorizations that are not listed are removed; omitting it keeps them; null or [] clears all group workspace roles. Each workspaceUUID is provided only once; for duplicates only the first item is used, without merging. roleUUIDs=[] for a workspace means removing that workspace's group roles; the workspace itself and the accounts are not deleted. This API does not validate item by item whether the workspace/role exists, which workspace it belongs to, or the target authorization constraints; administrators must verify each item in advance and cannot treat true as meaning valid permissions have been established. The group/relationship state is committed first, and then the permission cache refresh is delivered; HTTP 200 does not guarantee that all subsequent requests immediately use the new permissions; a 500 caused by delivery or audit failure may also occur after the principal has been saved. First read the list page by page and locate records by uuid, expand refWorkspaces to verify the saved workspace-role bindings, and then handle the unfinished refreshes. When the refresh target list is empty, the shared job refreshes all active workspaces; this cannot be understood as refreshing only the current group.
Path Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| group_uuid | string | Y | UUID of an active backend group, not the single-workspace group_ team UUID. Example: mgroup_example001How to obtain or fill in: Get it from content.data[].uuid in Backend Group List. |
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| X-Df-SVersion | string | Version of the raw path and request body signature; you cannot omit it and keep using the algorithm on this page. Example: v20240417How to obtain or fill in: The example on this page uses this fixed version, which pairs with the example signing algorithm. |
|
| X-Df-Access-Key | string | Y | Read APIs accept r or w credentials; write APIs require w credentials. Example: <external-access-key>How to obtain or fill in: Assigned by the site administrator as an External API AK; workspace OpenAPI Keys cannot be used. |
| X-Df-Signature | string | Y | HMAC-SHA256 over the uppercase method, nonce, raw full path, timestamp, and raw UTF-8 request body joined by spaces, taking the hex digest. Example: <hmac-sha256-hex>How to obtain or fill in: Compute it with the matching SK as described in External API Signature Authentication; see the complete runnable template below. |
| X-Df-Timestamp | string | Y | Must be within the signature validity window configured on the site; do not reuse the example time. Example: 1785427200How to obtain or fill in: Generate the current Unix seconds string with str(int(time.time())) when sending. |
| X-Df-Nonce | string | Y | Temporary serial number; generate a new value and recompute the signature when resending after a failure. Example: 97d275ee9f774315a7885ba7347acbd9How to obtain or fill in: Regenerate uuid.uuid4().hex for every request. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| refWorkspaces[*].roleUUIDs[*] | string | A single role UUID string; do not use a number or an object; do not judge whether the role is actually valid solely from a successful response. Example: readOnlyHow to obtain or fill in: Get the role uuid from Workspace Role List of the corresponding workspace, and choose according to the platform authorization policy. |
|
| refWorkspaces | array | Complete list of workspace and role targets; once this field appears, everything is replaced; old workspace authorizations that are not listed are removed. Omit to keep; null or [] clears all workspace role authorizations. Allows null: True Example: [{"workspaceUUID": "wksp_example001", "roleUUIDs": ["readOnly"]}]How to obtain or fill in: Get workspace UUIDs from Workspace List, then get the roles of each workspace from Workspace Role List. |
|
| refWorkspaces[*] | object | One workspace authorization object; when the field appears in the request, it must still conform to the declared structure. For duplicate workspaceUUID, only the first role list is used, without merging. Example: {"workspaceUUID": "wksp_example001", "roleUUIDs": ["readOnly"]}How to obtain or fill in: Organize one workspaceUUID and the complete roleUUIDs array for each target workspace; provide each workspace only once. |
|
| refWorkspaces[*].workspaceUUID | string | Conditionally required | Required workspace UUID string. You must first verify that the workspace exists and check its status; this API does not validate item by item, and an incorrect UUID may also be saved. Allows null: False Example: wksp_example001How to obtain or fill in: Get from Workspace List an active workspace that needs to be authorized through the backend group. |
| refWorkspaces[*].roleUUIDs | array | Conditionally required | Required complete role array. Each item is trimmed, deduplicated, and empty strings are removed; [] removes all group role authorizations for that workspace. Role existence/ownership is not fully validated, and Owner uniqueness or handover checks are not performed; you cannot rely on the API to reject unknown roles or roles from other workspaces; for Owner changes, use the formal handover process. Allows null: False Example: ["readOnly"]How to obtain or fill in: For that workspaceUUID, get the corresponding valid role UUIDs from Workspace Role List. |
Additional Parameter Notes¶
Use the site-level External API AK/SK; for the signing method, see External API Signature Authentication. A backend group mgroup_ can be associated with multiple workspaces and grant inherited roles; it is not the same kind of object as a group_ team within a single workspace. Write requests require w permission; listing accepts r or w. roleUUIDs uses the complete target array rather than an incremental one, so the permissions inherited by members change accordingly. After saving, the member caches of the related workspaces are refreshed asynchronously; after that completes, query the list and the actual access permissions for verification.
Request Example¶
import hashlib
import hmac
import json
import time
import uuid
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError
# Replace with the target site address and the External API AK/SK assigned by the administrator.
server = "https://external-api.guance.com"
access_key = "<external-access-key>"
secret_key = "<external-secret-key>"
method = 'POST'
path = '/api/v1/mgroup/mgroup_example001/modify/workspace'
query = {}
data = {'refWorkspaces': [{'workspaceUUID': 'wksp_example001', 'roleUUIDs': ['readOnly']}]}
full_path = path + ("?" + urlencode(query) if query else "")
body = "" if data is None else json.dumps(data, ensure_ascii=False, separators=(",", ":"))
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
string_to_sign = " ".join([method, nonce, full_path, timestamp, body])
signature = hmac.new(secret_key.encode("utf-8"), string_to_sign.encode("utf-8"), hashlib.sha256).hexdigest()
headers = {
"X-Df-Access-Key": access_key,
"X-Df-Timestamp": timestamp,
"X-Df-Nonce": nonce,
"X-Df-Signature": signature,
"X-Df-SVersion": "v20240417",
}
if data is not None:
headers["Content-Type"] = "application/json"
request = Request(server + full_path, data=None if data is None else body.encode("utf-8"), headers=headers, method=method)
try:
with urlopen(request, timeout=30) as result:
payload = json.loads(result.read().decode("utf-8"))
except HTTPError as error:
print("HTTP", error.code, error.read().decode("utf-8")) # Determine by errorCode, content, and traceId; do not output AK/SK.
raise SystemExit(1)
except (URLError, TimeoutError):
print('The request result is unknown. Query the actual configuration and task status first, then decide whether to retry the write request.')
raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))
Response¶
HTTP 200, application/json standard External envelope; declaration is not added automatically. content=true on success; valid workspace/role relationships should still be re-queried for verification.
| Field | Type | Description |
|---|---|---|
| content | boolean | true on success; does not return the actual number written or a list of valid authorizations; omitting refWorkspaces with no change may also return true. |
{
"code": 200,
"content": true,
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
The table lists verified request and business errors; ordinary internal exceptions ultimately return 500 ft.InternalServerError. The group/relationship may already be committed while a subsequent cache or audit operation fails; read the current state first, and do not infer from the error alone that the change did not take effect.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | A request field is missing, or a field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | The request JSON syntax is invalid | Request JSON format error | Fix the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The JSON top level is not an object | Some json file format error | Submit a JSON object as shown in the table. |
| 404 | ft.MGroupNoExists | The group UUID does not exist or the group has been deleted | Group does not exist | Get the uuid of an active mgroup_ record from the backend group list. |
| 500 | ft.InternalServerError | Database, asynchronous cache refresh delivery, audit, or unhandled field exception | Internal error | Save the traceId, expand refWorkspaces from the list by uuid to verify the workspace/role bindings, then handle the unfinished cache refresh to avoid repeated full overwrites. |