Skip to content

Create Dashboard



POST /api/v1/dashboards/create

Overview

Create a dashboard in the specified workspace.

Before You Call and Usage Steps

Use site-level External API write permission. Obtain the workspace UUID from content.data[].uuid in the Workspace List. You must provide exactly one of the config object and templateUUID. Obtain the template UUID from content.data[].uuid in the Template List, filtering by type=dashboard. If name is omitted, it is taken from config.templateInfo.title or the template meta.title, with a maximum of 128 characters. config.isPublic defaults to 1 and allows -1, 0, and 1. config.name, config.recoverIdentifier, and the top-level isCover and isIndexDashboard fields are not supported. Creation does not overwrite resources with duplicate names and does not automatically set the home dashboard. If you need to set it, use the content.dashboardUUID returned by this API to call Set Home Dashboard.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Signature version. The example in this document uses v20240417.
X-Df-Access-Key string Y Request AK information
Example: <external-access-key>
How to obtain or fill in: Obtain the External API Access Key from the target site administrator.
X-Df-Signature string Y Signature information
Example: <computed-signature>
How to obtain or fill in: Compute using the actual method, request URL, and original request body according to External API Signature Authentication.
X-Df-Timestamp string Y Signature timestamp
Example: 1785427200
How to obtain or fill in: Generate a current Unix seconds string before sending, computed using the actual time each time.
X-Df-Nonce string Y Request nonce
Example: b3b3564d4bb34c16be011e0cb85357c1
How to obtain or fill in: Generate a new random string for each request and use the same value to compute the signature.
Content-Type string Y Request body type. Use application/json.

Body Request Parameters

Parameter Type Required Description
workspaceUUID string Y Target workspace UUID
Empty string allowed: False
Example: wksp_example
How to obtain or fill in: Take content.data[].uuid from the Workspace List.
config json Creation configuration; mutually exclusive with templateUUID
Example: {"templateInfo":{"title":"业务看板"}}
How to obtain or fill in: When creating a regular dashboard, fill it in according to the call instructions on this page; omit it when using a template.
templateUUID string Admin Console template UUID; mutually exclusive with config
Empty string allowed: False
Example: itgr_dashboard_example
How to obtain or fill in: Take the content.data[].uuid of a type=dashboard entry in the Template List.
name string Resource name; if omitted, read from the configuration or template
Empty string allowed: False
Example: 业务看板
How to obtain or fill in: Enter the display name of the new dashboard.

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/dashboards/create'
query = {}
data = {'workspaceUUID': 'wksp_example', 'name': '业务看板', 'config': {}}
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 AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print('请求结果未知,请先核对目标当前状态及是否已经写入,再决定是否重新签名重试;不要自动重复写请求。')
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200, application/json.

Field Type Description
content.workspaceUUID string Target workspace UUID.
content.dashboardUUID string UUID of the new dashboard.
content.templateUUID string Returned when created using a template.
content.name string Dashboard name.
content.status string succeeded on success.
content.action string created on success.
{
  "code": 200,
  "content": {
    "workspaceUUID": "wksp_example",
    "dashboardUUID": "dsbd_example",
    "name": "业务看板",
    "status": "succeeded",
    "action": "created"
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

See Common Error Definitions for authentication, rate limiting, and common request errors.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
400 ft.RequestJsonFormatError The request body is not valid JSON The response may contain content.reason/line/column Fix the JSON syntax.
400 ft.JsonFormatError The top level of the request body is not a JSON object JSON format error Submit a JSON object.
400 ft.InvalidParameter A required parameter is missing or an unsupported field is included Invalid parameter Check the parameter location and field description.
403 ft.WorkspaceIsLocked / ft.Forbidden The workspace is locked or the current credentials do not have write permission Access forbidden Confirm the workspace status and the write permission of the site credentials.
404 ft.WKSPNotExistOrReleased The target workspace does not exist or has been released Workspace unavailable Select a valid workspace from the site's workspace list.
400 ft.InvalidParameter The template category does not match, or the template meta is missing or malformed Invalid parameter; the field is templateUUID Select a valid template again according to the API requirements.
404 ft.NotFoundTemplateUUID The template does not exist or is not active Template not found Query valid dashboard templates again.
409 ft.ObjectParmeterExists A dashboard with the same name or a conflicting dashboard already exists in the target workspace content.errors[] may contain the conflicting field and identifier Check the current status and use a different name.
500 ft.InternalServerError The creation submission result cannot be confirmed content.status=unknown, stage=commit First check by name whether it has already been created in the target workspace, then decide whether to retry.

Feedback

Is this page helpful?