Modify¶
POST /api/v1/workspace/{workspace_uuid}/member/batch_modify
Overview¶
Batch replace the direct roles of workspace members.
Prerequisites and Usage Steps¶
Requires an External credential with w permission. First use the Workspace Member List to save the target members' current direct roles and inherited roles, then submit roleUUIDs according to the complete target list. It is recommended to set onlyModifyRoles=true. The current External call uses a branch different from the frontend member editing branch; memberGroupUUIDs and acntWsNickname are not written to teams/nicknames. Do not use the current Owner as a target to modify. One other direct member can be granted owner; in this case, the roles of other targets are discarded, the original Owner is downgraded to wsAdmin and retains workspace membership; setting multiple people as Owner in a batch is rejected. If you want to remove the original Owner's direct membership, use Transfer Owner. The response is an empty object; it does not return a per-account success list, nor does it prove that the target roles are valid. You must first verify each item in roleUUIDs against this workspace's role list. Do not rely on this API to reject unknown or other-workspace roles; these values may be written to the association and replace the original direct roles. UUIDs of unknown accounts or accounts that are not direct members may be filtered out. Old approval records may be canceled; permission and cache handling is not a cross-service atomic operation. After a failure, verify the current direct roles before retrying.
Route Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| workspace_uuid | string | Y | Target workspace UUID. First confirm its active status and site. Example: wksp_example001How to obtain or enter: Obtain it from content.data[].uuid in the Workspace List and verify the workspace name. |
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| X-Df-SVersion | string | Signature version for the original path and request body; do not omit it and continue using the algorithm on this page. Example: v20240417How to obtain or enter: The example on this page uses this fixed version, which matches the example signing algorithm. |
|
| X-Df-Access-Key | string | Y | Read APIs can use r or w credentials; write APIs require w credentials. Example: <external-access-key>How to obtain or enter: Assigned by the site administrator as an External API AK. Do not use a workspace OpenAPI Key. |
| X-Df-Signature | string | Y | Concatenate the method in uppercase, nonce, original full path, timestamp, and original UTF-8 request body with spaces, then compute an HMAC-SHA256 and take the hex digest. Example: <hmac-sha256-hex>How to obtain or enter: Compute it using the matching SK according to External API Signature Authentication. See the complete runnable template below. |
| X-Df-Timestamp | string | Y | Must be within the signature validity window configured for the site. Do not reuse the example time. Example: 1785427200How to obtain or enter: When sending, use str(int(time.time())) to generate the current Unix seconds string. |
| X-Df-Nonce | string | Y | Temporary serial number; when resending after a failure, generate a new value and recompute the signature. Example: 97d275ee9f774315a7885ba7347acbd9How to obtain or enter: Generate uuid.uuid4().hex anew for each request. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| accountUUIDs[*] | string | A single account UUID. Do not enter an email address, account name, or workspace UUID. Example: acnt_example001How to obtain or enter: Obtain an existing member from content.data[].uuid in the Workspace Member List; for adding/transferring, you can also obtain the target account from the Site Account List. |
|
| roleUUIDs[*] | string | A single valid role UUID. For built-in roles, use the actual identifier; for custom roles, use the returned uuid. Example: generalHow to obtain or enter: Obtain the uuid of a valid role in the workspace from the Workspace Role List. Common built-in roles include general, readOnly, and wsAdmin. |
|
| memberGroupUUIDs[*] | string | A single team UUID. It can only participate in audit preparation; team changes are not saved through this External entry point. Example: group_example001How to obtain or enter: Currently not applied; if provided for compatibility, obtain the real uuid from the team list. |
|
| accountUUIDs | array | Y | Required array; the current implementation uses the subset of accounts with direct relationships. UUIDs without direct relationships mixed in may be ignored. If none match, the request fails. The declaration allows null, but the implementation's set(null) returns 500; do not pass null. An empty array with onlyModifyRoles=false also fails because it accesses the first element. Allows null: True Example: ["acnt_example001"]How to obtain or enter: Select accounts with active direct member associations from the Workspace Member List. |
| roleUUIDs | array | Y | Required complete target role array. It replaces each target member's direct roles, does not merge with old roles, and does not remove roles inherited from teams/backend groups. It cannot be null or an empty array. The current implementation does not verify whether each role exists or which workspace it belongs to; unknown or other-workspace UUIDs may be written to the association but cannot form valid permissions. You must first validate each item against this workspace's role list. Allows null: False Example: ["readOnly"]How to obtain or enter: Obtain the uuid of a valid role in the workspace from the Workspace Role List. Common built-in roles include general, readOnly, and wsAdmin. |
| onlyModifyRoles | boolean | Y | Required boolean. The current External path uses the non-frontend branch; even when false, it does not write team or workspace nicknames. false also prepares a single-member audit in advance and relies on the first target after deduplication being valid. Deduplication uses a set, so order is not guaranteed; the first item is not necessarily the first item in the input array, which may add failure conditions. Allows null: False Example: trueHow to obtain or enter: For this External entry point, it is recommended to set this to true to modify roles only. |
| memberGroupUUIDs | array | Optional array or null. Currently not applied to member teams. It is recommended to omit it; when onlyModifyRoles=false, it participates in audit preparation, and null may trigger an internal exception. Allows null: True Example: []How to obtain or enter: This External entry point currently does not write team relationships; to manage team members, use the corresponding team management capability. |
|
| acntWsNickname | string | Optional string or null. The declared custom length limit is 128 (half-width characters usually count as 1, other characters usually as 2). The current External path does not save this field; it is recommended to omit it. Allows null: True $maxCustomLength: 128 Example: 示例空间昵称How to obtain or enter: This External entry point currently does not write workspace nicknames; if you need to change one, use a member management entry point that supports this feature. |
Additional Parameter Notes¶
Authentication is described in External API Signature Authentication. The example on this page uses v20240417, which matches the signing algorithm for the original full path, Query, and request body. This module operates on membership relationships or roles in a specified workspace; it does not create accounts themselves. After a write request fails, first verify the current member and role status, then decide whether to retry. Use valid UUIDs from the role list, and do not rely on unknown custom roles being fully rejected; after writing, verify the permissions that are actually available.
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/workspace/wksp_example001/member/batch_modify'
query = {}
data = {'accountUUIDs': ['acnt_example001'], 'roleUUIDs': ['readOnly'], 'onlyModifyRoles': True}
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")) # Handle according to errorCode, content, and traceId; do not output AK/SK.
raise SystemExit(1)
except (URLError, TimeoutError):
print('请求结果未知,请先核对目标当前状态及是否已经写入,再决定是否重新签名重试;不要自动重复写请求。')
raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))
Response¶
HTTP 200, application/json unified envelope; business data is located in content. External does not automatically add declaration; list pagination remains in content.pageInfo.
| Field | Type | Description |
|---|---|---|
| content | object | This External branch returns {} on success and does not return autoLoginUrl, needOwnerAudit, or per-account results from the frontend approval branch. |
{
"code": 200,
"content": {},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
The following table lists verified business and request errors. Ordinary database/downstream 5xx errors or unhandled exceptions are globally wrapped as ft.InternalServerError. A failed write request is not guaranteed to have had no partial effect; verify the current relationship status first.
| 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 | Invalid request JSON syntax | Request JSON format error | Fix the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The top level of the request JSON is not an object | Partial JSON file format error | Submit a JSON object; do not use an array or null as the entire request body. |
| 400 | ft.SSOUnsupportModifyRole | The namespace of the target SSO account has SAML role mapping enabled for this workspace | SAML mapping is enabled; modifying the role of an SSO account is prohibited | Adjust it through the corresponding identity provider's role mapping, or have the administrator verify the mapping policy. |
| 400 | ft.RoleUUIDNullError | roleUUIDs is an empty array | The role uuid list is empty | Provide at least one target role. |
| 400 | ft.ForbiddenBatchModifyOwner | Multiple deduplicated target accounts request the owner role at the same time | Invalid operation; the owner cannot be modified in a batch | Owner can be changed to only one target at a time; use an explicit transfer process. |
| 400 | ft.ForbiddenModifyOwner | The targets to modify include the current Owner account | Invalid operation; the owner cannot be modified | Remove the current Owner from the batch; for transfer, use the dedicated API. |
| 400 | ft.MemberRoleNotFound | None of the targets have an active direct member association | The specified member role was not found in the current workspace | First establish a direct relationship through the add API; members inherited from backend groups are not direct members. |
| 400 | ft.AgentMemberCanNotBeOwner | The valid target to be granted Owner is an agent-sourced member | Members from the agent source cannot be set as workspace owners | Select a regular member account as Owner. |
| 404 | ft.NotFoundAccount | When onlyModifyRoles=false, the first deduplicated account used for audit preparation has no active direct member relationship; set deduplication order is not guaranteed | The specified account was not found | Use onlyModifyRoles=true and select valid direct members. |
| 500 | ft.InternalServerError | Database, cache, cancellation of old approval tasks, or unhandled array/field exceptions; accountUUIDs=null, or onlyModifyRoles=false with an empty target array/abnormal audit input | Internal error | Save the traceId and ask the administrator to verify the actual relationships and cache; the write operation may have been partially committed and should not be blindly replayed. |