Create¶
POST /api/v1/viewer/add
Overview¶
Create an Explorer. Blank creation, templates, or copying an existing view are supported.
Before Calling and Usage Steps¶
The minimal request only requires name. When copying from a source view, first verify the source UUID from Explorer List or Dashboard List. The selection order is non-empty sourceDashboardUUID, non-empty templateInfos, then templateUUID. If the source view is not found, an empty Explorer may be created; check the layout and content after copying. On a name conflict, HTTP 200 returns repeatInfo; the client must check whether there is a new uuid.
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | Workspace OpenAPI authentication credential. Example: <DF-API-KEY>How to obtain or fill: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace. |
Body Request Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| ownerType | string | Compatibility field. The current creation route is fixed to viewer. Null allowed: False Example: viewerHow to obtain or fill: Can be omitted for new integrations; the actual resource is created through this Explorer entry point. |
|
| templateUUID | string | Integration template UUID, with lower priority than an existing source view and template object. Null allowed: False Empty string allowed: True Maximum length: 128 Example: tmpl_exampleHow to obtain or fill: Fill this in when the integration template UUID is available. If you only have the template name, first export an existing view and use the returned object to fill templateInfos. |
|
| sourceDashboardUUID | string | UUID of the source view to copy. Takes precedence when non-empty. Null allowed: False Empty string allowed: True Maximum length: 128 Example: dsbd_source_exampleHow to obtain or fill: Select an existing source view in the current workspace from Explorer List or Dashboard List. |
|
| name | string | Y | Explorer name, up to 64 characters. Null allowed: False Maximum length: 64 Example: 主机巡检查看器How to obtain or fill: Choose a name that is not used by other Explorers in this workspace. |
| desc | string | Explorer description. Null allowed: False Empty string allowed: True Maximum length: 2048 Example: 主机巡检与状态核对How to obtain or fill: Describe the purpose of the new Explorer. If omitted or empty, the template summary can be inherited. |
|
| type | string | This type is used when creating an empty Explorer; the default is CUSTOM. When a template is used, its dashboardType is used. Null allowed: False Maximum length: 32 Example: CUSTOMHow to obtain or fill: Generally use CUSTOM. To modify it, obtain and reuse content.type from the details. |
|
| extend | json | Extension information for blank creation. When using a template, take the template's dashboardExtend. Null allowed: False Example: {}How to obtain or fill: Obtain from content.extend in Explorer details or dashboardExtend in the template. |
|
| templateInfos | json | Explorer template JSON object; main declares charts, variables, and groups. Null allowed: False Empty string allowed: False Example: {"title": "主机巡检查看器", "summary": "主机巡检与状态核对", "identifier": "", "dashboardType": "CUSTOM", "dashboardExtend": {}, "dashboardMapping": [], "dashboardBindSet": [], "iconSet": {}, "main": {"type": "template", "charts": [], "vars": [], "groups": [], "chartGroupPos": []}}How to obtain or fill: First call Export Explorer to obtain the content object. Use it as is or modify the template fields that need adjustment. |
|
| isImport | boolean | Marks the source as an import for use by list filter=import. The selected content is still determined by template-related fields. Null allowed: False Example: falseHow to obtain or fill: Mark as import based on the creation source; for normal creation, omit it or set it to false. |
|
| tagNames | array | Enter tag names. When empty, the template tagInfo can be inherited. Null allowed: False Example: ["team:ops"]How to obtain or fill: Copy from content.tagInfo[].name in existing Explorer Details, or enter the scenario tags to associate. |
|
| tagNames[*] | string | Single tag name, up to 128 characters. Null allowed: False Maximum length: 128 Example: team:opsHow to obtain or fill: Copy from content.tagInfo[].name in existing Explorer Details, or enter the scenario tags to associate. |
Additional Parameter Notes¶
Templates share the same structure as Dashboard Template Field Description. This API uses templateInfos, and the top-level name determines the name. The top-level identifier, isPublic, and mapping parameters of the Dashboard API do not apply to Explorer creation.
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/viewer/add' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"name":"主机巡检查看器","desc":"主机巡检与状态核对","type":"CUSTOM"}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content.id | integer | Explorer record ID. |
| content.uuid | string | Explorer UUID. |
| content.workspaceUUID | string | Owning workspace. |
| content.name | string | Explorer name. |
| content.desc | string | Explorer description. |
| content.identifier | string | Custom identifier; can be empty. |
| content.ownerType | string | Explorer resource ownership, usually viewer. |
| content.type | string | Explorer type, for example CUSTOM. |
| content.isPublic | integer | Visibility scope of the current resource. 1 is public; 0 is visible only to the creating identity. |
| content.chartPos | array<object> |
Chart layout array, containing chartUUID and layout object pos. |
| content.chartPos[].chartUUID | string | Referenced chart UUID. |
| content.chartPos[].pos | object | Position and size of the layout, such as x, y, w, h. |
| content.chartGroupPos | array<string> |
Chart group order. |
| content.iconSet | object | Icon configuration. |
| content.extend | object | Explorer extension information. |
| content.mapping | array<object> |
Variable field mapping information. |
| content.dashboardBindSet | array | View binding configuration. |
| content.createdWay | string | Resource creation source. |
| content.openPermissionSet | boolean | Permission configuration switch for the entity record. |
| content.permissionSet | array<string> |
Operation permission subject UUIDs in the record. |
| content.readPermissionSet | array<string> |
Read permission subject UUIDs in the record. |
| content.tagInfo | array<object> |
Associated tag information. |
| content.tagInfo[].id | string | Identifier identical to the tag UUID. |
| content.tagInfo[].uuid | string | Tag UUID. |
| content.tagInfo[].name | string | Tag name. |
| content.tagInfo[].description | string | Tag description. |
| content.tagInfo[].colour | string | Tag color. |
| content.tagInfo[].scope | array<string> |
Tag effective scope. |
| content.tagInfo[].tagPermissionInfo | object | Read/write authorization information when present. |
| content.status | integer | Record status. |
| content.creator | string | Creator identity ID. |
| content.updator | string | Most recent updater identity ID; can be empty. |
| content.createAt | number | Creation time, Unix seconds. |
| content.updateAt | number | Update time, Unix seconds. Can be -1 when not updated. |
| content.deleteAt | number | Deletion time, Unix seconds. -1 when not deleted. |
| content.declaration | object or null | Public declaration of the workspace. |
| content.repeatInfo | object | Returned on a name conflict; creation is not completed. Grouped by keys such as name. |
| content.repeatInfo.name | array<object> |
Name conflict records. |
| content.repeatInfo.name[].name | string | Name in the request. |
| content.repeatInfo.name[].importName | string | Name in the request. |
| content.repeatInfo.name[].existName | string | Existing Explorer name. |
| content.repeatInfo.name[].nameConflictUUID | string | UUID of the Explorer with the matching name. |
| content.repeatInfo.name[].conflictUUIDs | array<string> |
Existing Explorer UUIDs involved in this conflict. |
| content.repeatInfo.name[].existNameIdentifier | string | Identifier of the existing Explorer; can be empty. |
| content.repeatInfo.name[].existIdentifier | string | Identifier of the existing conflict item; can be empty. |
| content.repeatInfo.name[].isCrossConflict | boolean | false for a simple name duplicate. |
| content.repeatInfo.name[].identifier | string | Identifier is not passed for conflict matching during Explorer creation, so this value is empty. |
| content.repeatInfo.name[].importIdentifier | string | Identifier of the request matching item; this value is empty. |
| content.repeatInfo.name[].fileName | string | Associated template file name; empty when called directly without a file. |
{
"code": 200,
"content": {
"id": 25,
"uuid": "dsbd_view_example",
"name": "主机巡检查看器",
"desc": "主机巡检与状态核对",
"workspaceUUID": "wksp_example",
"identifier": "",
"ownerType": "viewer",
"type": "CUSTOM",
"isPublic": 1,
"chartPos": [],
"chartGroupPos": [],
"iconSet": {},
"extend": {},
"mapping": [],
"dashboardBindSet": [],
"createdWay": "manual",
"openPermissionSet": false,
"permissionSet": [],
"readPermissionSet": [],
"tagInfo": [],
"status": 0,
"creator": "wsak_example",
"updator": "",
"createAt": 1785427200,
"updateAt": -1,
"deleteAt": -1,
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
HTTP 200 response when the name is duplicated
{
"code": 200,
"content": {
"repeatInfo": {
"name": [
{
"name": "主机巡检查看器",
"identifier": "",
"fileName": "",
"importName": "主机巡检查看器",
"importIdentifier": "",
"existName": "主机巡检查看器",
"existIdentifier": "",
"nameConflictUUID": "dsbd_view_example",
"existNameIdentifier": "",
"isCrossConflict": false,
"conflictUUIDs": [
"dsbd_view_example"
]
}
],
"identifier": [],
"name_and_identifier": []
},
"declaration": {}
},
"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 | Request field is missing, or the 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 | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | JSON syntax is valid but the request top level is not an object | Partial JSON file format error | Pass the parameters as a JSON object. |
| 403 | ft.ForbiddenFreeEditionLimit | Workspace has enabled the quantity limit and reached the upper limit | Free Plan workspace {} has reached the upper limit ({}), so it cannot create. Subscribe to the Commercial Plan to unlock the limit | Confirm the current plan and Explorer count. |
| 400 | ft.TagScopeMismatch | A tag with the same name already exists, but its scope is incompatible with the scenario | The message includes the tag name and the existing and target scopes. | Use a scenario-specific or general tag. |
| 406 | ft.ExceedMaxCharacterLimit | The chart or group name in the template exceeds 256 characters, or the tag name exceeds 128 characters | {} exceeds the maximum character length limit | Modify the template according to the field length limits. |
| 404 | ft.ObjectNotExists | The passed integration template UUID does not exist | The specified object does not exist | Verify the template UUID, or use an exportable existing view or complete template object. |
| 406 | ft.InvalidParameter | Invalid template structure, for example, main is not an object, charts, vars, or groups is not an array, or the chart query structure is invalid | Invalid parameter {} |
Modify the template according to the field path indicated in the error. Prefer the complete template returned by the export API of this version. |