Modify Site Account Brand Identifier¶
POST /api/v1/account/change_brand_key
Overview¶
Batch modify the brand identifiers of accounts.
Before Calling and Usage Steps¶
Requires an External credential with w permission. accountUUIDs is obtained from the Account List. brandKey is provided by the target site administrator and must belong to the set allowed for that site. Only the account brandKey and update time are changed, and the account profile cache is cleared. Workspaces, member roles, and historical data are not migrated, and the Workspace's own brand is not modified. Before switching, confirm that the login entry point and integration configuration for the target brand are ready.
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| X-Df-SVersion | string | Signature version for the original path and request body; you cannot omit it and continue using the algorithm on this page. Example: v20240417How to obtain or fill in: This page's example uses this fixed version and is 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 an External API AK. A Workspace OpenAPI Key cannot be used. |
| X-Df-Signature | string | Y | Perform HMAC-SHA256 on the uppercase method, nonce, original full path, timestamp, and original UTF-8 request body joined by spaces, then 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 window configured for the site; do not reuse the example time. Example: 1785427200How to obtain or fill in: When sending, generate the current Unix seconds string with str(int(time.time())). |
| X-Df-Nonce | string | Y | Temporary serial number; when resending after a failure, also generate a new value and recalculate the signature. Example: 97d275ee9f774315a7885ba7347acbd9How to obtain or fill in: Generate uuid.uuid4().hex anew for each request. |
Body Request Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| accountUUIDs[*] | string | A single target account UUID string, not a Workspace UUID. Example: acnt_example001How to obtain or fill in: Obtain each item from content.data[].uuid in the Account List. |
|
| brandKey | string | Y | Required string; not the brand website URL. Allows null: False Example: guanceHow to obtain or fill in: Confirm with the site administrator the brand identifier allowed for the target site. |
| accountUUIDs | array | Y | Array of target account UUIDs; the client should first verify the scope and send a non-empty list of strings. An empty array does not affect all accounts in a batch, and unknown or deleted UUIDs are ignored. Allows null: False Example: ["acnt_example001"]How to obtain or fill in: Obtain each item from content.data[].uuid in the Account List; do not enter a wksp_ Workspace UUID. |
Supplementary Parameter Description¶
Use site-level External API credentials. For authentication, see External API Signature Authentication. The following example uses signature version v20240417. The signature path, query encoding, and original request body must be exactly the same as what is actually sent. Repeatedly submitting the same target brandKey may still update the timestamp; this operation does not forcibly revoke existing login tokens.
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/account/change_brand_key'
query = {}
data = {'accountUUIDs': ['acnt_example001'], 'brandKey': 'guance'}
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:
detail = error.read().decode("utf-8")
print("HTTP", error.code, detail) # Check errorCode, message, content, and traceId; do not print AK/SK.
raise SystemExit(1)
except (URLError, TimeoutError):
print("Request result unknown; for write operations, query the current account status first, and decide whether to retry after confirmation.")
raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))
Response¶
HTTP 200, unified application/json envelope; External does not automatically add declaration. On success, content=true, and the new account profile is not returned.
| Field | Type | Description |
|---|---|---|
| content | boolean | true on success; an empty array, unknown UUID, or deleted UUID does not modify any account and may also return true. |
{
"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.
| 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 | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The top level of the request body JSON is not an object | Some JSON file format error | Use a JSON object; do not send an array, string, or null as the top level. |
| 406 | ft.InvalidBrandKey | brandKey is not in the set allowed for the target site | Brand identifier {} is invalid. |
Confirm with the site administrator the brand identifiers allowed for the site, then enter the original value. |
| 500 | ft.InternalServerError | Database, cache, asynchronous task delivery, or an unhandled field exception | Internal error | Save the traceId and contact the administrator; for write requests, query the current account status again first, and decide whether to retry after confirmation. Do not directly treat a 500 as not taking effect. |