Skip to content

Set the Workspace Homepage Dashboard



POST /api/v1/workspace/{workspace_uuid}/dashboard/index/set

Overview

Set a dashboard in the specified workspace as the homepage.

Prerequisites and Usage Steps

Use site-level External API write permission. Obtain the workspace UUID in the path from the Workspace List. The dashboard UUID can be obtained from content.dashboardUUID returned by Create Dashboard. The dashboard must belong to the same active workspace, have type ownerType=node, be public (isPublic=1), and have custom permissions disabled. Setting the same dashboard repeatedly returns already_set and does not create a new dashboard.

Path Parameters

Parameter Type Required Description
workspace_uuid string Y UUID of the target workspace
Example: wksp_example
How to obtain or provide: Use content.data[].uuid from the Workspace List.

Request Headers

Parameter Type Required Description
X-Df-SVersion string Signature version. This example uses v20240417.
X-Df-Access-Key string Y Request AK information
Example: <external-access-key>
How to obtain or provide: 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 provide: Compute it according to External API Signature Authentication using the actual method, request URL, and raw request body.
X-Df-Timestamp string Y Signature timestamp
Example: 1785427200
How to obtain or provide: Generate the current Unix seconds string before sending, and calculate it based on the actual time each time.
X-Df-Nonce string Y Request nonce
Example: b3b3564d4bb34c16be011e0cb85357c1
How to obtain or provide: Generate a new random string for each request, and use the same value to calculate the signature.
Content-Type string Y Request body type. Use application/json.

Body Request Parameters

Parameter Type Required Description
dashboardUUID string Y UUID of a public dashboard with regular permissions in the target workspace
Empty string allowed: False
Example: dsbd_example
How to obtain or provide: Use content.dashboardUUID from the successful response of Create Dashboard, or obtain the UUID of an existing eligible dashboard from the target workspace.

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/wksp_example/dashboard/index/set'
query = {}
data = {'dashboardUUID': 'dsbd_example'}
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 based on errorCode, content, and traceId; do not output AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print('The request result is unknown. Check the current target status and whether the write has already occurred before deciding whether to re-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.

Field Type Description
content.workspaceUUID string UUID of the target workspace.
content.dashboardUUID string UUID of the dashboard being set.
content.status string succeeded on success.
content.homepageStatus string set indicates it has been set; already_set indicates it was already the same homepage.
{
  "code": 200,
  "content": {
    "workspaceUUID": "wksp_example",
    "dashboardUUID": "dsbd_example",
    "status": "succeeded",
    "homepageStatus": "set"
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

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

HTTP Status errorCode Trigger Condition Message or Response Description Resolution
400 ft.RequestJsonFormatError Request body is not valid JSON Response may include content.reason/line/column Fix the JSON syntax.
400 ft.JsonFormatError Request body top level is not a JSON object JSON format error Submit a JSON object.
400 ft.InvalidParameter Required parameter is missing or an unsupported field is included Invalid parameter Check the parameter location and field descriptions.
403 ft.WorkspaceIsLocked / ft.Forbidden Workspace is locked or current credentials have no write permission Access denied Confirm the workspace status and the write permission of the site credentials.
404 ft.WKSPNotExistOrReleased Target workspace does not exist or has been released Workspace unavailable Select a valid workspace from the site workspace list.
404 ft.NotFoundView Dashboard has been deleted, is cross-workspace, does not exist, or is not node Dashboard not found Check the workspace and dashboard UUID.
400 ft.ForbiddenSetIndexDashboard Dashboard is not public Cannot set as homepage Use a public dashboard.
400 ft.ForbiddenOpenPermissionSetIndexDashboard Dashboard has custom permissions enabled Cannot set as homepage Use a dashboard without custom permissions enabled.
500 ft.InternalServerError Workspace homepage configuration write or commit result is unknown content.stage may indicate set_homepage or commit Check the current homepage configuration before deciding whether to retry.

Feedback

Is this page helpful?