Skip to content

Initialize and Retrieve



GET /api/v1/workspace/inner_accesskey/{workspace_uuid}/get

Overview

Retrieves the built-in Owner system Key of a workspace, and automatically initializes it if it is missing.

Before Calling and Usage Steps

Although the method is GET, this endpoint requires w permission and may create a Key, so it cannot be used as a read-only probe. First select an active workspace from the Workspace List. If an active inner sys Key already exists, the existing credentials are returned; if it is missing, a system Key named inner with isSystem=1 and isOwnerRole=1 is created, and then the plaintext AK/SK is returned. If you only need to view without allowing initialization, use the Built-in Key List. This endpoint does not refresh existing credentials, and a successful response returns only the fixed ten fields, without role/permission details or the complete entity.

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: Get it from content.data[].uuid in the 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; do not omit it and continue using 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 signing algorithm.
X-Df-Access-Key string Y The list endpoint of this module accepts r or w permission; the other three, including GET initialization, require w permission.
Example: <external-access-key>
How to obtain or fill in: Assigned by the site administrator as the External API AK; the workspace OpenAPI Key cannot be used.
X-Df-Signature string Y Concatenates the uppercase method, nonce, original full path, timestamp, and the original UTF-8 request body with spaces, computes HMAC-SHA256, and takes the hex digest.
Example: <hmac-sha256-hex>
How to obtain or fill in: Compute it with the matching SK as described in 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 serial number; 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 endpoint allows r or w permission, and the other three, including GET initialization, require w permission. All responses may return high-privilege credentials in plaintext, so the masking display rules of ordinary front-end pages should not be applied; the examples use placeholder values, and actual credentials should be stored securely.

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 = 'GET'
path = '/api/v1/workspace/inner_accesskey/wksp_example001/get'
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('Read failed; you can back off, re-sign, and retry, keeping the traceId and query conditions.')
    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 keeps content.pageInfo.

Field Type Description
content.uuid string API Key record UUID, which differs from the calling credentials ak/sk.
content.createAt integer Creation time in Unix seconds.
content.updateAt integer Update time in Unix seconds; usually -1 if not yet modified.
content.name string Built-in Key name; inner when initialized.
content.ak string Plaintext Access Key of the built-in system; store it as a high-privilege credential. It is not the External signing AK.
content.sk string Plaintext Secret Key of the built-in system; store it as a high-privilege credential. It is not the External signing SK.
content.workspaceUUID string UUID of the workspace it belongs to.
content.businessType string This module only manages the inner sys type.
content.isSystem integer This module only manages system built-in Keys; 1 when initialized.
content.isOwnerRole integer 1 when initialized, carrying Owner role semantics; managed separately from ordinary manually created Owner Keys.
{
  "code": 200,
  "content": {
    "uuid": "wsak_inner_example001",
    "ak": "<inner-access-key>",
    "sk": "<inner-secret-key>",
    "name": "inner",
    "businessType": "inner sys",
    "workspaceUUID": "wksp_example001",
    "isSystem": 1,
    "isOwnerRole": 1,
    "createAt": 1785427200,
    "updateAt": -1
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

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

If parameters do not match 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, verify the persisted state and cache first; it is not guaranteed that nothing took effect.

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 Verify the parameter location, field name, type, and value.
401 ft.WKSPNotExistOrReleased The target workspace does not exist or is not active with status=0 Workspace does not exist or has been released Select an active workspace from the Workspace List; this endpoint cannot be used to create a Key for a deleted workspace.
500 ft.InternalServerError Database or cache failure, or an internal exception that is not explicitly handled Internal error Save the traceId, check the current state of the Key and the actual call result before deciding to retry; the database may already have committed, so do not assume there was no change based on the error response.

Feedback

Is this page helpful?