Skip to content

Batch Delete



POST /api/v1/workspace/accesskey/batch_delete

Overview

Batch deletes API Keys by an array of UUIDs.

Prerequisites and Usage Steps

Requires an External credential with w permission. The request is not filtered by workspaceUUID, so a single batch can hit multiple workspaces; verify each Key's workspace, name, and client dependencies item by item before submitting. Unknown, deleted, and system Keys are ignored; an empty array deletes no Keys but still succeeds. If any matching Key in the batch is bound to an Agent source, the entire batch is rejected, and the other Keys already marked are not submitted first. In the normal flow, matching Keys are soft-deleted and the corresponding role associations are cleaned up; after commit, an AK/SK invalidation cache entry is written for each Key. A cache anomaly may return 500 only after the batch has already been deleted.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Signature version for the original path and request body; you cannot omit it and continue to use the algorithm on this page.
Example: v20240417
How to obtain or fill in: The examples on this page use this fixed version, which matches the example signature algorithm.
X-Df-Access-Key string Y The list endpoint in this module accepts r or w permission; all other endpoints, including the GET details endpoint, require an External credential with w permission.
Example: <external-access-key>
How to obtain or fill in: Assigned by the site administrator as an External API AK; workspace OpenAPI Keys cannot be used.
X-Df-Signature string Y Concatenate the uppercase method, nonce, original full path, timestamp, and raw UTF-8 request body separated by spaces, then compute HMAC-SHA256 and take the hex digest.
Example: <hmac-sha256-hex>
How to obtain or fill in: Compute with the matching SK according to External API Signature Authentication; see the complete runnable template below.
X-Df-Timestamp string Y Must fall 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 serial number; generate a new value and recompute the signature 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
akUUIDs[*] string UUID of a single Key record; it is not the plaintext ak/sk and not the workspace UUID.
Example: wsak_example001
How to obtain or fill in: Obtain the UUID of a single Key record from content.data[].uuid in the API Key List.
akUUIDs array Y Required string array; cannot be null. [] deletes nothing, and duplicate UUIDs match only the same record; unknown/deleted/system Keys are ignored.
Allows null: False
Example: ["wsak_example001"]
How to obtain or fill in: Obtain the target from content.data[].uuid in the API Key List or content.uuid in API Key Details, and confirm the workspace each item belongs to.

Additional Parameter Notes

Use the site-level External API AK/SK; for the signature method, see External API Signature Authentication. The workspace API Key generated on this page and the External signature credential are two different sets of credentials. External currently returns the AK/SK in plaintext and does not apply the masking policy of the console UI; all response examples use placeholder values, so store the actual response as a credential. Both batch delete and single delete affect subsequent OpenAPI calls that use the deleted AK/SK; prepare replacement credentials first.

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/accesskey/batch_delete'
query = {}
data = {'akUUIDs': ['wsak_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('The request result is unknown. Check the target current state and whether it has already been written before deciding whether to re-sign and retry; do not automatically repeat write requests.')
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200, application/json with a unified envelope; the business result is in content; External does not automatically add declaration, and list pagination is in content.pageInfo.

Field Type Description
content boolean The route always returns true and does not return the match count or per-Key results; it can be true even for an empty array or when all UUIDs are ignored.
{
  "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 table below lists confirmed request and business branches. Common database/cache/audit 5xx errors are globally wrapped as ft.InternalServerError; when a write endpoint returns an error, the name, Owner flag, roles, or deletion state may already be saved, so query the current state first before deciding the next step.

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 Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The JSON top level is not an object Some json file format error Use a JSON object; do not use an array or null as the entire request body.
400 ft.AgentWorkspaceAKCanNotDelete The matching batch contains a Key with createdWay=agent that is bound to an account API Keys bound to an agent cannot be deleted Remove that Key and handle it through the corresponding Agent management entry.
500 ft.InternalServerError Database, cache invalidation, audit, or an unhandled field exception Internal error Keep the traceId and check the Key's current name, roles, and status. Data may be committed before the failure, so do not treat a 500 alone as meaning nothing took effect.

Feedback

Is this page helpful?