Skip to content

Delete



POST /api/v1/workspace/accesskey/{ak_uuid}/delete

Overview

Delete the specified API Key and invalidate its AK/SK.

Before You Call and Usage Steps

Requires an External credential with w permission. First verify the Key name and its workspace from the API Key list or API Key details, and replace all clients that depend on this credential before deletion. This External path locates the resource by UUID; you do not need to pass workspaceUUID again, and it does not accept parameters for deleting an entire workspace. It performs a soft delete, cleans up its role associations, and marks the AK/SK cache as invalid. Normal non-system Keys and disabled but undeleted non-system Keys can both be processed; Agent-bound Keys are rejected. Keys that do not exist, have already been deleted, or are system Keys are ignored, and true may still be returned; you cannot use true to determine that each target previously existed. This operation does not delete the workspace or the collection Token.

Route Parameters

Parameter Type Required Description
ak_uuid string Y API Key record UUID (often with the wsak_ prefix), not the ak/sk calling credential; this External path locates the resource across workspaces by UUID. Verify workspaceUUID before execution.
Example: wsak_example001
How to obtain or enter: Obtain it from content.data[].uuid in the API Key list or from content.uuid after successful creation.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Signature version for the original path and request body; do not omit it and then continue using the algorithm on this page.
Example: v20240417
How to obtain or enter: The example on this page uses this fixed version, which matches the example signing algorithm.
X-Df-Access-Key string Y The list in this module accepts r or w permission; all other endpoints, including GET details, require an External credential with w permission.
Example: <external-access-key>
How to obtain or enter: 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 original UTF-8 request body with spaces, then compute HMAC-SHA256 and take the hex digest.
Example: <hmac-sha256-hex>
How to obtain or enter: Calculate it with 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 enter: When sending, use str(int(time.time())) to generate the current Unix seconds string.
X-Df-Nonce string Y Temporary serial number; when resending after a failure, also generate a new value and recompute the signature.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or enter: Generate a new uuid.uuid4().hex for each request.

Additional Parameter Notes

Use the site-level External API AK/SK. For signing, see External API Signature Authentication. The workspace API Key generated on this page and the External signing credential are not the same set of credentials. External currently returns the AK/SK in plaintext and does not apply the masking policy used on the UI page; all response examples use placeholder values, so actual responses should be safeguarded as credentials. There is no entry point to undo deletion or restore an old credential. After a failure, first verify the Key status and actual authentication; do not determine that a Key is still enabled based solely on a cache refresh anomaly.

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/wsak_example001/delete'
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 according to errorCode, content, and traceId; do not output the AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print('The request result is unknown. First verify the target\'s current status and whether the write already occurred before deciding whether to 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 unified envelope, with the business result in content; External does not automatically add declaration, and list pagination is in content.pageInfo.

Field Type Description
content boolean Always returns true on success; also returns true when the target does not exist, has been deleted, or is an ignored system Key.
{
  "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 confirmed request and business branches. Ordinary database/cache/audit 5xx errors are globally wrapped as ft.InternalServerError; when a write endpoint returns an error, the name, Owner flag, role, or deletion status may already have been saved. Query the current state before deciding the next step.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed Request field missing, or field value violates the declared validation conditions Parameter parsing failed Verify the parameter location, field name, type, and value.
400 ft.AgentWorkspaceAKCanNotDelete The target is a Key with createdWay=agent that is bound to an account The API Key bound to the Agent cannot be deleted Handle this credential through the Agent management process.
500 ft.InternalServerError Database, cache invalidation, audit, or unhandled field exception Internal error Keep the traceId and verify the Key's current name, role, and status. Data may be committed before the failure occurs; do not treat an HTTP 500 alone as the operation not taking effect.

Feedback

Is this page helpful?