Skip to content

Batch Delete



POST /api/v1/workspace/inner_accesskey/batch_delete

Overview

Batch delete active inner sys system Keys by Workspace UUID.

Before Calling and Usage Steps

You need w permission. First use Workspace List to verify each Workspace, then confirm the corresponding inner sys Key and its dependents from Built-in Key List. The request workspaceUUIDs must be an array of Workspace UUIDs, not Key record UUIDs and not plaintext AK/SK. Only Keys with isSystem=1, businessType=inner sys, and status=0 in matching Workspaces are soft-deleted; regular API Keys and other system business Keys are unaffected by this operation. Unknown Workspaces, no active built-in Keys, or an empty array may all return true; per-Workspace match counts are not provided. The current implementation actively marks the authentication cache for old AKs as invalid but does not also actively clear the old SK cache. If an old SK already has a valid authentication cache, a successful response alone cannot be used to conclude that all old credentials have been immediately revoked; administrators should verify cache handling and actual authentication results. After deletion, calling Initialize and Get Built-in Key will reinitialize the Key, so it cannot be used to verify "still does not exist"; to verify deletion, query the list and actual credential authentication.

Request Headers

Parameter Name Type Required Description
X-Df-SVersion string Signature version for the original path and request body; cannot be omitted if you continue to use the algorithm on this page.
Example: v20240417
How to obtain or fill: This page's example uses this fixed version, which is paired with the example signature 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: Assigned by the site administrator as an External API AK; a Workspace OpenAPI Key cannot be used.
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: 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 on the site; do not reuse the example time.
Example: 1785427200
How to obtain or fill: When sending, use str(int(time.time())) to generate the current Unix seconds string.
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: Regenerate uuid.uuid4().hex for each request.

Request Body Parameters

Parameter Name Type Required Description
workspaceUUIDs[*] string A single Workspace UUID, not a wsak_ record UUID.
Example: wksp_example001
How to obtain or fill: Obtain a single workspace uuid from Workspace List.
workspaceUUIDs array Y Required string array; deletion is by Workspace UUID; null is invalid; [] does not delete any Key.
Allows null: False
Example: ["wksp_example001"]
How to obtain or fill: Obtain the Workspaces to process item by item from content.data[].uuid in Workspace List, and first verify the corresponding built-in Keys.

Additional Parameter Notes

Use site-level External API credentials; for authentication, see External API Signature Authentication. The list allows r or w permission; the other three items, including GET initialization, require w permission. All responses may return high-privilege credentials in plaintext; do not apply the masking display rules of regular frontend pages; the examples use placeholder values, and actual credentials should be stored securely. The database deletion state and subsequent cache processing are performed in separate steps. On error, first confirm the scope that has been deleted to avoid repeatedly switching credentials through initialization/deletion.

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/batch_delete'
query = {}
data = {'workspaceUUIDs': ['wksp_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 according to errorCode, content, and traceId; do not output AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print('The request result is unknown. First verify the current state of the target and whether it has already been written, then decide whether to re-sign and retry; do not automatically repeat the write request.')
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200, application/json unified envelope; business results are located in content; External does not automatically add declaration, and list pagination retains content.pageInfo.

Field Type Description
content boolean Always returns true; no match or an empty array 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.

When parameters do not conform to the declaration, a common request error is returned; ordinary internal exceptions such as database and cache failures are ultimately unified as 500 ft.InternalServerError. After a write request fails, first verify the persistent state and cache; it is not guaranteed that none of the changes took effect.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed Request field is missing, or the field value violates the declared validation conditions Parameter parsing failed Verify 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 Top level of the request JSON is not an object Partial JSON file format error The delete request uses a JSON object, and workspaceUUIDs is its array field.
500 ft.InternalServerError Database or cache failure, or an internal exception that is not explicitly handled Internal error Save the traceId; verify the current state of the Key and the actual call result before deciding to retry; the database may have already committed, so do not conclude from an error response that no changes occurred.

Feedback

Is this page helpful?