Skip to content

Create an Admin Console Account



POST /api/v1/super-account/create

Overview

Create a site Admin Console account.

Prerequisites and Usage Steps

Requires w permission and External credentials. First check the username in the Admin Console account list, then explicitly select admin or dev and set a strong password. name/email/mobile can be provided as needed; no Workspace or regular business account is created automatically. The persisted resetPasswordAt for a new account is usually -1, and standard login may require a first password reset. Creation is not an idempotent request, and a duplicate username returns an error; after a timeout, first query whether the account has been created. isDisable and extend currently have no effect. If you need to disable the account, call enable/disable separately after creation.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Signature version for the raw 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 and is paired with the example signing algorithm.
X-Df-Access-Key string Y Read endpoints can use r or w credentials; write endpoints require w credentials.
Example: <external-access-key>
How to obtain or fill in: Assigned by the site administrator as External API AK; a Workspace OpenAPI Key cannot be used.
X-Df-Signature string Y Concatenate the uppercase method, nonce, raw full path, timestamp, and raw 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: When sending, generate the current Unix seconds string with str(int(time.time())).
X-Df-Nonce string Y Temporary nonce; when resending after a failure, generate a new value and recompute the signature.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or fill in: Generate uuid.uuid4().hex again for each request.

Body Request Parameters

Parameter Type Required Description
username string Y Required string. Callers should use a non-empty username; the current declaration does not enforce non-empty. The storage column is 128 characters, so 128 or fewer is recommended.
Allows null: False
Example: api-doc-admin
How to obtain or fill in: Check existing usernames in the Admin Console account list, then specify a new unused value.
password string Y Required plaintext string, transmitted over HTTPS; at least 8 characters and at least three of the four categories: digits, uppercase letters, lowercase letters, and special characters. This is not the RSA-wrapped field used on the Admin Console page, and null is invalid.
Allows null: False
Example: Example!2026a
How to obtain or fill in: The caller generates a secure initial password and delivers it to the account owner through an appropriate channel.
email string Optional; if omitted, saved as empty. If explicitly provided, it must be a valid email address; an empty string fails format validation. The model column is 64 characters, so 64 or fewer is recommended. Do not pass null or non-string values; the old declaration lacked type checking and may cause a 500.
Allows null: False
$isEmail: True
Example: xxx@guance.com
How to obtain or fill in: Enter a valid email address string that can receive notifications.
name string Optional; if omitted, an empty string. The model column is 64 characters, so 64 or fewer is recommended; null is invalid.
Allows null: False
Example: 示例管理员
How to obtain or fill in: Enter the account display nickname.
role string Y Required role identifier. It is recommended to use only the defined admin/dev. The current declaration does not restrict the enum, and other values do not have stable permission semantics; dev cannot log in with a standard Admin Console account password.
Allows null: False
Example: admin
How to obtain or fill in: Select admin or dev according to the purpose of the Admin Console account; do not use a Workspace role UUID.
mobile string Optional; if omitted, empty. This module only stores the value encrypted and does not perform the countryCode splitting/full number validation used for regular business accounts; null is invalid.
Allows null: False
Example: 13800138000
How to obtain or fill in: Enter the account mobile number string; omit it or use an empty string when not configured.
extend json Optional JSON object; the current ManageAccount has no corresponding persisted field, so creation does not save it or return it. It is recommended to omit it.
Allows null: False
Example: {}
How to obtain or fill in: For compatibility with the old declaration only; do not use this field to save business data.
isDisable boolean Optional Boolean; the current creation implementation ignores this field, and new accounts still have status=0. You cannot rely on true to create a disabled account.
Allows null: False
Allowed values: [True, False]
Example: false
How to obtain or fill in: To disable the account, after successful creation obtain the uuid and call Enable/Disable.

Additional Parameter Notes

For authentication, see External API Signature Authentication. This module manages site Admin Console accounts. UUIDs usually start with mact_; they are not Workspace business member acnt_ IDs and are not the Workspace Owner. List/detail endpoints can use r or w permissions; the rest require w permission. External executes as sys and does not apply the operation restrictions that regular Admin Console accounts have for the initial super administrator. Before operations, verify the target account and a management account that can still log in. Creation returns a snapshot taken before flush, so id and resetPasswordAt may be null; use the detail endpoint to read persisted data. The response does not include password or passworHistory.

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/super-account/create'
query = {}
data = {'username': 'api-doc-admin', 'password': 'Example!2026a', 'name': '示例管理员', 'email': 'xxx@guance.com', 'role': 'admin'}
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:
    detail = error.read().decode("utf-8")
    print("HTTP", error.code, detail)  # Check errorCode, message, content, and traceId; do not print AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print("Request result unknown; for write operations, query the current account state first and decide whether to retry after confirmation.")
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200, application/json unified envelope; External does not automatically add declaration. content is the created Admin Console account profile object.

Field Type Description
content.id integer or null Admin account record sequence number; id=1 is the initial super administrator. The snapshot returned by creation may be null; use uuid for calls.
content.uuid string Admin account UUID, usually with the mact_ prefix.
content.status integer Account status: 0 enabled, 2 disabled, 3 deleted; list and detail exclude 3 but may still return 2.
content.creator string Creator identity; External is usually sys.
content.updator string Identity of the most recent update; may be empty if never updated.
content.createAt integer Creation Unix seconds.
content.deleteAt number Deletion Unix seconds; usually -1 if not deleted.
content.updateAt number Update Unix seconds; some modifications only update updator, so you cannot determine whether profile data changed based only on this value.
content.name string Display nickname.
content.username string Admin Console username.
content.email string Email address; may be empty if not configured.
content.mobile string Admin account mobile number displayed after decryption; empty if not set. There is no separate countryCode field.
content.role string Admin Console role identifier; defined usages are admin/dev. dev is rejected in the standard Admin Console account password login flow and cannot be regarded as a regular read-only role.
content.resetPasswordAt integer or null Unix seconds of the most recent password reset; the creation snapshot may be null, and the persisted initial value is usually -1, which triggers the standard Admin Console first-reset prompt.
content.mfaSecret string Internal MFA binding field that the current implementation may return; it is not for business integration use. Do not use it to construct authentication, and actual values should not be logged or disclosed. An empty example does not mean all existing accounts are empty.
{
  "code": 200,
  "content": {
    "id": null,
    "uuid": "mact_example001",
    "status": 0,
    "creator": "sys",
    "updator": "",
    "createAt": 1785427200,
    "deleteAt": -1,
    "updateAt": -1,
    "name": "示例管理员",
    "username": "api-doc-admin",
    "email": "xxx@guance.com",
    "mobile": "",
    "role": "admin",
    "resetPasswordAt": null,
    "mfaSecret": ""
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

Authentication, rate limiting, and common request errors are described in Common Error Definitions.

This table lists only errors currently reachable on the External creation path. Database and subsequent audit steps are not a single atomic operation; on a normal 5xx, first confirm from the Admin Console account list by username whether the account has been created, then handle the incomplete parts.

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 Check parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError JSON top level is not an object Some JSON files have a format error Submit a JSON object as described in the table.
400 ft.InvalidPasswordRule Password is empty or does not meet strength rules when creating an Admin Console account Invalid password rule At least 8 characters and at least three of the four categories: digits, uppercase letters, lowercase letters, and special characters.
400 ft.ObjectParmeterExists An undeleted account already uses the same username {} already exists First check existing Admin Console accounts; use the update endpoint when an update is needed.
500 ft.InternalServerError Database, cache, audit, or unhandled field exception; email passed as null/non-string, or a field exceeds the actual storage length Internal error Creation may be committed before a subsequent step such as audit fails. First query the Admin Console account list by username to confirm whether it already exists, avoid duplicate creation, and retain the traceId to handle subsequent failures.

Feedback

Is this page helpful?