Skip to content

Create Site Account



POST /api/v1/account/add

Overview

Create a local account or create a connected account based on a third-party exterId.

Before Calling and Usage Steps

Requires External credentials with w permission. For local accounts, omit exterId. For third-party SSO accounts, provide a stable exterId and explicitly set password="". source is not a public input parameter of this API; it is fixed to local for local accounts and defaults to unknown for third-party accounts. After success, save content.uuid; account creation does not automatically add the account to a Workspace. To associate a Workspace, use the corresponding member management capability. After a timeout or 500, first use Account List or Account Details to confirm whether the account has been created, and then retry; the underlying creation commits the account first and does not have an idempotency key.

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 fill in: The example on this page uses this fixed version, which is paired with the example signature algorithm.
X-Df-Access-Key string Y Read APIs can use r or w credentials; write APIs require w credentials.
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 Perform HMAC-SHA256 on the uppercase method, nonce, original full path, timestamp, and original UTF-8 request body joined by spaces, then take the hex digest.
Example: <hmac-sha256-hex>
How to obtain or fill in: Compute using the paired 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, 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 fill in: Regenerate uuid.uuid4().hex for each request.

Body Request Parameters

Parameter Type Required Description
brandKey string Optional; if omitted, the site default brand is used. Cannot be null; do not assume that all brand sites allow this value.
Allow null: False
Example: guance
How to obtain or fill in: Obtain the allowed brand identifier from the site administrator.
username string Y Required. When exterId is absent, it is unique within the empty namespace; when exterId is present, duplicates are allowed, and third parties may pass an empty string. Do not pass null; the underlying database does not accept null.
Allow null: True
Allow empty string: True
Example: xxx@guance.com
How to obtain or fill in: For local accounts, use an unused login name, preferably a valid email address; for third-party accounts, use your own login name.
password string Y Required. When exterId is absent, at least 8 characters and at least three of the four categories: digits, uppercase letters, lowercase letters, and special characters; when exterId is present, this strength check is not performed, and an empty string is allowed. Do not pass null: when exterId is absent, 400 ft.InvalidPasswordRule is returned; when exterId is present, hashing is performed, which may return 500 ft.InternalServerError.
Allow empty string: True
Allow null: True
Example: Example!2026a
How to obtain or fill in: The caller generates it for local accounts and delivers it securely; third-party SSO accounts explicitly use an empty string.
name string Y Required nickname; provide a meaningful non-empty string.
Allow null: False
Allow empty string: False
Example: 示例成员
How to obtain or fill in: Use the member display name from the identity system.
email string Y Required; when a value is present, the email format is validated; when it is an empty string and username is in email format, it is automatically filled with username. Cannot be null.
Allow null: False
Allow empty string: True
$isEmail: True
Example: xxx@guance.com
How to obtain or fill in: Use a valid email address where the member can receive notifications; if there is no email address, explicitly pass an empty string.
mobile string The mobile field consists of two parts: countryCode and the local mobile number. It supports + international numbers or international numbers with a 00 prefix. Legacy 11-digit domestic numbers starting with 1 can default to 86. When a country code is provided, the validity of the complete number is checked. If omitted, it defaults to empty; do not pass null.
Allow null: False
Allow empty string: False
Example: 2025550123
How to obtain or fill in: Use the member's real, valid local mobile number, paired with countryCode; omit it when not configured.
countryCode string String country/region code; if omitted and mobile is a legacy 11-digit domestic number, 86 can be inferred; when mobile is empty, it is ultimately cleared to empty as well.
Allow null: False
Allow empty string: True
Example: 1
How to obtain or fill in: Obtain it from the country/region to which the member's mobile number belongs, for example, 86 for China and 1 for the United States.
exterId string Optional; a non-empty value enables the third-party creation branch and is unique within the empty namespace; in this case, source automatically becomes unknown. Omit it to create a local account. Do not pass null or an empty value to express third-party identity.
Allow null: False
Allow empty string: False
Example: sso-user-1001
How to obtain or fill in: Obtain it from the stable user ID of your SSO/identity provider; do not use a nickname that may change.
extend json Optional object or null; the current creation implementation does not save this field, and the response is still usually null.
Allow null: True
Example: {}
How to obtain or fill in: Provided only for compatibility with the current declaration; do not rely on this field to store additional information. Put business custom data in customAttributes.
language string Optional; omission, null, or an empty string all default to zh; if a value is provided, it must be within the declared enumeration.
Allow null: True
Allow empty string: True
Allowed values: ['zh', 'en', 'zh-hant', 'id', 'ja', 'ko']
Example: zh
How to obtain or fill in: Choose one of zh, en, zh-hant, id, ja, or ko according to the member's preference.
isDisable boolean This optional boolean field currently does not change the creation status; a new account is still status=0. Do not rely on isDisable=true to create a disabled account.
Allow null: False
Allowed values: [True, False]
Example: false
How to obtain or fill in: If you need to disable a new account, after creation succeeds and you obtain the uuid, call Enable/Disable.
attributes json Optional object; defaults to {} if omitted. The entire object is stored. String values are recommended; subsequent SSO logins may overwrite them. Cannot be null.
Allow null: False
Example: {"部门": "研发部"}
How to obtain or fill in: Obtain the KV object from SSO mapping rules or the enterprise identity system; field names are agreed upon by both integrating parties.
customAttributes json Optional object; defaults to {} if omitted. Maintained on the business side; string values are recommended. Cannot be null.
Allow null: False
Example: {"costCenter": "CC-1001"}
How to obtain or fill in: Obtain the KV object from your business account attributes, for example, cost center.

Additional Parameter Notes

Use site-level External API credentials; for authentication, see External API Signature Authentication. The following example uses the v20240417 signature version. The signature path, Query encoding, and original request body must exactly match what is actually sent. The returned account profile does not include the password field; mfaSecret is only a fixed mask, not a key that can be used for login.

Minimal request body example for a third-party account:

{
  "username": "",
  "password": "",
  "name": "SSO示例成员",
  "email": "",
  "exterId": "sso-user-1001"
}

The local password uses the plaintext string over HTTPS; this API does not use the RSA password wrapping used by the management console.

In the table, null/empty strings and omission should be distinguished. The current string type validation does not uniformly reject empty strings; callers should provide meaningful non-empty content for login names, nicknames, and similar fields, and should not rely on empty values to obtain implicit defaults.

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/account/add'
query = {}
data = {'username': 'xxx@guance.com', 'password': 'Example!2026a', 'name': '示例成员', 'email': 'xxx@guance.com', 'language': 'zh', 'attributes': {'部门': '研发部'}, 'customAttributes': {'costCenter': 'CC-1001'}}
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 the 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 with a unified application/json envelope; External accounts are not automatically added to declaration. content is the newly created account profile object; for nullable fields, refer to the field table.

Field Type Description
content.id integer Account record sequence number within the site, returned only as profile data; use uuid when calling other APIs.
content.uuid string Account UUID; use this field for subsequent queries, modifications, disabling, and deletion.
content.status integer Account status: 0 normal, 2 disabled; list filtering uses 3 for deleted, and other historical statuses may appear.
content.creator string Creation identity identifier; External creation is usually SYS.
content.updator string Most recent modification identity identifier; may be empty when there has been no modification.
content.createAt number Creation time, Unix seconds.
content.updateAt number Update time, Unix seconds; may be -1 when there is no update time.
content.deleteAt number Status operation time field, usually -1 initially; enable/disable operations also write this value. Do not use it alone to determine deletion; use status.
content.name string Display nickname.
content.username string Login account name. For third-party accounts, it may be empty or duplicate another account.
content.email string Account contact email; if it is empty at creation and username is in email format, it is filled with username.
content.mobile string Mobile phone local number, displayed decrypted, excluding the country code; empty string if not set.
content.countryCode string Mobile phone country/region code as a numeric string, such as 86; empty string if not set.
content.exterId string Unique ID in the third-party identity system; usually empty for local accounts.
content.extend object or null Existing extension profile, which may contain the user_icon avatar URL; the extend passed during creation by this API is currently not saved, and the modification API does not expose this input parameter either.
content.extend.user_icon string Optional avatar URL or static resource file name; may appear when reading historical profiles and is not a writable parameter on this page.
content.source string Identity source identifier, such as local, unknown, oidc, or ldap; historical internal sources such as agent may also exist.
content.nameSpace string Identity namespace; defaults to empty for External creation and cannot be set through public parameters of this module.
content.isUsed integer or boolean Flag indicating whether the account has been used.
content.agreeTerms integer Terms agreement flag.
content.canaryPublic boolean Canary flag.
content.enableMFA boolean Whether MFA is enabled.
content.mfaSecret string Fixed mask *********************, does not contain a usable MFA key.
content.language string Language identifier: zh, en, zh-hant, id, ja, ko.
content.tokenHoldTime integer Account inactivity session hold duration in seconds; new accounts are initialized according to the site security session configuration, and the value is not guaranteed to be the example value.
content.tokenMaxValidDuration integer Maximum account session validity period in seconds; new accounts are initialized according to the site security session configuration.
content.timezone string Timezone identifier; empty if not set.
content.attributes object SSO synchronization attribute KV object; may be overwritten by subsequent SSO logins. Keys and values are agreed upon by the integrating parties.
content.attributes.{attributeName} Any JSON value Custom attribute value; strings are recommended, for example, Department=R&D.
content.customAttributes object Attribute KV object maintained on the business side.
content.customAttributes.{attributeName} Any JSON value Business custom value; strings are recommended, for example, costCenter=CC-1001.
content.statusPageSubs integer Status page subscription flag.
content.defaultWorkspace string Account default Workspace UUID; empty if not configured.
content.brandKey string Current account brand identifier, determined by the set of brands allowed for the site.
content.scheduleMobile string Scheduling dedicated mobile phone local number; empty if not set.
content.scheduleEmail string Scheduling dedicated email; empty if not set.
content.ifScheduleMobileEnable boolean Whether the scheduling mobile number is enabled.
content.ifScheduleEmailEnable boolean Whether the scheduling email is enabled.
content.accountStatus string Additional account status identifier; empty if not set.
{
  "code": 200,
  "content": {
    "id": 1001,
    "uuid": "acnt_example001",
    "status": 0,
    "creator": "SYS",
    "updator": "",
    "createAt": 1785427200,
    "deleteAt": -1,
    "updateAt": -1,
    "name": "示例成员",
    "username": "xxx@guance.com",
    "email": "xxx@guance.com",
    "mobile": "",
    "countryCode": "",
    "exterId": "",
    "extend": null,
    "source": "local",
    "nameSpace": "",
    "isUsed": 0,
    "agreeTerms": 0,
    "canaryPublic": false,
    "enableMFA": false,
    "mfaSecret": "*********************",
    "language": "zh",
    "tokenHoldTime": 86400,
    "tokenMaxValidDuration": 604800,
    "timezone": "",
    "attributes": {
      "部门": "研发部"
    },
    "customAttributes": {
      "costCenter": "CC-1001"
    },
    "statusPageSubs": 0,
    "defaultWorkspace": "",
    "brandKey": "guance",
    "scheduleMobile": "",
    "scheduleEmail": "",
    "ifScheduleMobileEnable": false,
    "ifScheduleEmailEnable": false,
    "accountStatus": ""
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

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

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 Request JSON syntax is invalid Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The top level of the request body JSON is not an object Partial JSON file format error Use a JSON object; do not send an array, string, or null as the top level.
400 ft.InvalidPasswordRule When no valid exterId is provided and the local account creation branch is used, the password is null, an empty string, or does not meet the strength rules Invalid password rule The password must be at least 8 characters and contain at least three of the four categories: digits, uppercase letters, lowercase letters, and special characters.
406 ft.InvalidBrandKey brandKey is not in the allowed set for the target site Brand identifier {} is invalid. Confirm with the site administrator the brand identifiers allowed for the site, then enter the original value.
400 ft.ObjectParmeterExists A local username or third-party exterId already exists as an undeleted account <username or exterId> already exists Query the existing account first; use the modification API for updates. Do not treat duplicate creation as an idempotent success.
429 ft.OperationTooFrequently The local creation lock for the same username has not been released Your operation is too frequent, please try again later Wait, then query the existing account first; after confirming it was not created, regenerate the signed request.
500 ft.InternalServerError Database, cache, asynchronous task delivery, or a field exception that is not explicitly handled Internal error Save the traceId and contact the administrator; for write requests, re-query the current account state first and decide whether to retry after confirmation. Do not directly treat a 500 as not taking effect.

Feedback

Is this page helpful?