Skip to content

Change Workspace Owner



POST /api/v1/workspace/{workspace_uuid}/owner/transfer

Overview

Set the specified account as Owner and remove the original Owner's direct membership association.

Prerequisites and Usage Steps

Requires External credentials with w permission. First confirm that the workspace actually exists from the Workspace List, read the current Owner, and check the impact of the handover; then select the target account from the Site Account List. The target does not need to already be in this workspace; a direct membership relationship will be added when necessary. It is recommended to use an enabled account. The current validation only excludes deleted accounts; a disabled account may also pass but cannot log in normally. An agent source cannot become Owner. The original Owner's Owner role and direct membership association will be removed, but the account itself will not be deleted; inheritance relationships generated based on backend groups, etc. should not be considered synchronously cleared. The target is added to the Owner role, and existing other direct roles are not guaranteed to be deleted along with it. If the target is already the current Owner, true is returned directly. This operation does not create/migrate a Billing Center account; after success, verify the workspace members and Owner.

Route Parameters

Parameter Type Required Description
workspace_uuid string Y Target workspace UUID; confirm the active status and site first.
Example: wksp_example001
How to obtain or fill in: Obtain from content.data[].uuid in the Workspace List and verify the workspace name.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Original path and request body signature version; do not omit it and continue using the algorithm on this page.
Example: v20240417
How to obtain or fill in: This page's example uses this fixed version, paired with the example signature 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 fill in: Assigned by the site administrator as External API AK; workspace OpenAPI Key cannot be used.
X-Df-Signature string Y Join the uppercase method, nonce, original full path, timestamp, and original UTF-8 request body with spaces, then compute HMAC-SHA256 and take the hex digest.
Example: <hmac-sha256-hex>
How to obtain or fill in: Calculate 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 time window configured for the site; do not reuse the example time.
Example: 1785427200
How to obtain or fill in: When sending, use str(int(time.time())) to generate the current Unix seconds string.
X-Df-Nonce string Y Temporary serial number; generate a new value and recalculate the signature even when resending after a failure.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or fill in: Regenerate uuid.uuid4().hex for each request.

Body Request Parameters

Parameter Type Required Description
accountUUID string Y Required target account UUID string. Although the declaration allows null, null or an empty string will fail to find the account; do not fill in the workspace UUID. This External API does not require the target to be a workspace member in advance.
Allow null: True
Allow empty string: False
Example: acnt_example001
How to obtain or fill in: Obtain the target account from content.data[].uuid in the Site Account List. It must not be from an agent source; status=0 is recommended.

Additional Parameter Notes

For authentication, see External API Signature Authentication. The example on this page uses v20240417, which is paired with the signature algorithm for the original full path, Query, and request body. This module operates on membership relationships or roles in the specified workspace and does not create the account itself. After a write request fails, check the current membership and role status first before deciding whether to retry. The workspace UUID should be confirmed from the list in advance; the current transfer method does not provide additional confirmation of workspace existence. The transfer and subsequent cache cleanup are performed in separate steps; after a failure, verify the current Owner first before deciding the next step.

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/owner/transfer'
query = {}
data = {'accountUUID': 'acnt_example001'}
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 by 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 in content. External does not automatically add declaration, and list pagination retains content.pageInfo.

Field Type Description
content boolean true when the transfer is complete or the target is already the current Owner; Owner details are not returned.
{
  "code": 200,
  "content": true,
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

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, so verify the current relationship status first.

HTTP Status errorCode Trigger Condition Message or Response Description Handling Method
406 ft.ParameterValidationFailed Request field is missing, or the field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Request JSON syntax is invalid Request JSON format error Correct 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.
404 ft.NotFoundAccount Target accountUUID does not exist, has been deleted, is empty, or is null Specified account not found Reselect the target account from the Site Account List.
400 ft.AgentMemberCanNotBeOwner Target account source=agent Members from an agent source are not allowed to be set as Workspace Owner Use a regular member account.
500 ft.InternalServerError Database, cache, cancellation of old approval tasks, or unhandled array/field exceptions 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.

Feedback

Is this page helpful?