Skip to content

Update



POST /api/v1/workspace/inner_accesskey/{workspace_uuid}/refresh

Overview

Reset the AK/SK of the workspace's built-in system Key, and create a new Key if it is missing.

Prerequisites and Usage Steps

Requires w permission. First use Workspace List to confirm the active workspace, then use Initialize and Get Built-in Key to verify the current Key and its dependents. This endpoint does not re-verify the workspace's active status itself. When the Key is missing, it creates one directly, so you cannot pass an arbitrary UUID to probe whether a workspace exists. If a Key already exists, the record uuid is retained, and the AK/SK are regenerated and the update time is refreshed; if it is missing, an Owner system Key is created. There is no request body, no ttl grace period, and no option to change only the name. Each refresh generates new credentials and is not idempotent. After a failure, verify the current credentials first; do not blindly refresh again. The current implementation actively marks the authentication cache for the old AK as invalid but does not also actively clear the old SK cache. If the old SK has a valid authentication cache, do not conclude from a successful response alone that all old credentials have been immediately revoked; an administrator should verify the cache handling and actual authentication results.

Route Parameters

Parameter Name Type Required Description
workspace_uuid string Y Workspace UUID, not the API Key record UUID or the plaintext AK/SK.
Example: wksp_example001
How to obtain or fill in: Obtain from content.data[].uuid in Workspace List, and verify the site and active status.

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: v20240417
How to obtain or fill in: The example on this page uses this fixed version, which matches the sample signing algorithm.
X-Df-Access-Key string Y The list in this module can use r or w permission; the other three items, including GET initialization, all require w permission.
Example: <external-access-key>
How to obtain or fill in: Assigned by the site administrator as the External API AK; do not use a workspace OpenAPI Key.
X-Df-Signature string Y Concatenate 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: Compute 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: 1785427200
How to obtain or fill in: Generate the current Unix seconds string with str(int(time.time())) when sending.
X-Df-Nonce string Y Temporary nonce; when resending after a failure, also generate a new value and recompute the signature.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or fill in: Regenerate uuid.uuid4().hex for each request.

Additional Parameter Notes

Use site-level External API credentials; for authentication, see External API Signature Authentication. The list allows r or w permission, and the other three items, including GET initialization, require w permission. All responses may return plaintext high-privilege credentials; do not apply the masking rules used for ordinary frontend pages. Examples use placeholder values; actual credentials should be stored securely. In the branch where a missing Key is created, the returned snapshot is taken before flush, so id, callCount, and lastCallAt may be null; the branch where the Key already exists returns the original record data and new credentials.

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/inner_accesskey/wksp_example001/refresh'
query = {}
data = None
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, with a unified application/json envelope; the business result is in content. External does not automatically add declaration, and list pagination retains content.pageInfo.

Field Type Description
content.id integer or null Internal record sequence number; API calls use uuid. The creation snapshot is taken before flush, so this field may be null.
content.uuid string API Key record UUID, different from the calling credential ak/sk.
content.status integer Built-in Key status; queries and deletions in this module select status=0.
content.creator string Creator identity; for External creation, this is usually external.
content.updator string Updater identity; may be empty when not modified.
content.createAt integer Creation time in Unix seconds.
content.deleteAt integer Deletion time in Unix seconds; usually -1 if not deleted.
content.updateAt integer Update time in Unix seconds; usually -1 if not yet modified.
content.name string Built-in Key name; inner during initialization.
content.ak string Plaintext built-in system Access Key; store it as a high-privilege credential. This is not the External signing AK.
content.sk string Plaintext built-in system Secret Key; store it as a high-privilege credential. This is not the External signing SK.
content.workspaceUUID string UUID of the workspace it belongs to.
content.accountUUID string Bound account identifier; for an initialized system Key, this is usually an empty string.
content.createdWay string Creation source; usually manual during initialization. The system scope is distinguished by isSystem/businessType.
content.businessType string This module manages only the inner sys type.
content.isSystem integer This module manages only system built-in Keys; initialized to 1.
content.isOwnerRole integer Initialized to 1, with Owner role semantics; managed separately from ordinary manual Owner Keys.
content.remark string Existing remark; this module has no request parameter for modifying remarks.
content.isBurnAfterReading integer Retained burn-after-reading flag; this module does not destroy credentials after reading, and you should not rely on it to revoke credentials.
content.callCount integer or null Persistent cumulative call count; asynchronous statistics, not a real-time count. The creation snapshot may be null before flush.
content.lastCallAt integer or null Last call time in Unix seconds; usually -1 means no record yet. The creation snapshot may be null.
{
  "code": 200,
  "content": {
    "id": 1001,
    "uuid": "wsak_inner_example001",
    "status": 0,
    "creator": "external",
    "updator": "external",
    "createAt": 1785427200,
    "deleteAt": -1,
    "updateAt": 1785427200,
    "name": "inner",
    "ak": "<refreshed-inner-access-key>",
    "sk": "<refreshed-inner-secret-key>",
    "workspaceUUID": "wksp_example001",
    "accountUUID": "",
    "createdWay": "manual",
    "businessType": "inner sys",
    "isSystem": 1,
    "isOwnerRole": 1,
    "remark": "",
    "isBurnAfterReading": 0,
    "callCount": 0,
    "lastCallAt": -1
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Example snapshot when a missing Key is created:

{
  "code": 200,
  "content": {
    "id": null,
    "uuid": "wsak_inner_example001",
    "status": 0,
    "creator": "external",
    "updator": "",
    "createAt": 1785427200,
    "deleteAt": -1,
    "updateAt": -1,
    "name": "inner",
    "ak": "<inner-access-key>",
    "sk": "<inner-secret-key>",
    "workspaceUUID": "wksp_example001",
    "accountUUID": "",
    "createdWay": "manual",
    "businessType": "inner sys",
    "isSystem": 1,
    "isOwnerRole": 1,
    "remark": "",
    "isBurnAfterReading": 0,
    "callCount": null,
    "lastCallAt": null
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

When parameters do not match the declaration, a common request error is returned. Ordinary internal exceptions such as database and cache errors are ultimately unified as 500 ft.InternalServerError. After a write request fails, verify the persistent state and cache first; there is no guarantee that none of it took effect.

HTTP Status errorCode Trigger Condition Message or Response Description Handling Method
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.
500 ft.InternalServerError Database, cache failure, or an internal exception that is not explicitly handled Internal error Save the traceId and verify the current Key state and actual call results before deciding to retry; the database may already have committed, and you cannot conclude from the error response that no change occurred.

Feedback

Is this page helpful?