Create¶
POST /api/v1/tag/create
Overview¶
Create a business tag and its applicable scope.
Before Calling and Usage Steps¶
Check whether the name is already in use in the target workspace, then create a tag with a clear scope. Names are case-sensitive. The server-side string declaration does not guarantee non-empty validation, so callers should provide a non-empty business name. By default, scope=["all"], colour=default, and description is an empty string. Creating a tag does not automatically tag any resource or grant resource permissions; bind it by using the tag name/UUID in the corresponding resource API.
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or enter: Obtain an OpenAPI Key with the required permissions from API Key Management in the target workspace. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| scope[*] | string | Array member. Do not mix all with specific values. Example: monitorHow to obtain or enter: Select a single scope from the enum above. |
|
| scope | any | Non-empty scope array. The enum includes all (global), scene (scene), monitor (monitoring), dialing (Synthetic Testing), security (security), infrastructure (infrastructure), and catalog (Unified Catalog); legacy single-value strings are supported. all cannot be mixed with other values; duplicate values are deduplicated and returned in the fixed enum order. []/null/unknown values are not accepted. If omitted when creating/importing, the default is ["all"]; if omitted when modifying, the old value is retained. scope only restricts the tag's applicable scope and does not grant resource permissions; name bindings for infrastructure/Unified Catalog are not rewritten by entity reference cleanup here. Null allowed: False Example: ["scene", "monitor"]How to obtain or enter: Select based on the business type of the resource to which the tag needs to be bound. |
|
| name | string | Y | Required when creating, optional when modifying; a non-empty value is recommended. Maximum 50 counting units (1 for ASCII/half-width katakana, 2 for other characters). Non-deleted duplicate names are determined case-sensitively; do not treat the display name as a UUID. Existing tags that contain colons are allowed; this public list does not perform Front normal/KV dispatch. Null allowed: False Maximum length: 50 Example: productionHow to obtain or enter: A custom business tag name. First check for an already used name in the tag list. |
| description | string | Optional. If omitted when creating, an empty string is used; if omitted when modifying, the existing value is retained, and an explicit empty string clears it. Maximum 100 of the same counting units. Null allowed: False Maximum length: 100 Example: Unified tag for production resources.How to obtain or enter: The business side describes the purpose of the tag. |
|
| colour | string | Optional string. Defaults to default when creating; if omitted when modifying, the existing value is retained, and an empty string is saved as the new value. Maximum 50 of the same counting units. The server does not define a fixed color enum; you need to select a color representation supported by the customer interface. Null allowed: False Maximum length: 50 Example: defaultHow to obtain or enter: You can reuse an existing colour from the list or use default as the default value. |
Additional Parameter Notes¶
Data Notes
- Request parameter description
| Parameter | type | Description |
|---|---|---|
| name | string | Tag name |
| description | string | Field description information |
| color | string | Color type agreed between the frontend and backend, default, style_key1, style_key2 ~~ |
- Color type mapping for the color field:
{ "default": {"background": "#CCE6FF", "color": "rgba(0,0,0,0.8)"}, "style_key1": {"background": "#3333FE", "color": "#FFFFFF"}, "style_key2": {"background": "#428BCA", "color": "#FFFFFF"}, "style_key3": {"background": "#364450", "color": "#FFFFFF"}, "style_key4": {"background": "#E0E1FF", "color": "rgba(0,0,0,0.8)"}, "style_key5": {"background": "#9400D3", "color": "#FFFFFF"}, "style_key6": {"background": "#EDDBFF", "color": "rgba(0,0,0,0.8)"}, "style_key7": {"background": "#CC328B", "color": "#FFF"}, "style_key8": {"background": "#FCDEF0", "color": "rgba(0,0,0,0.8)"}, "style_key9": {"background": "#DC143D", "color": "#FFFFFF"}, "style_key10": {"background": "#FCBABA", "color": "rgba(0,0,0,0.8)"}, "style_key11": {"background": "#BD0B48", "color": "#FFFFFF"}, "style_key12": {"background": "#FDECD2", "color": "rgba(0,0,0,0.8)"}, "style_key13": {"background": "#FFC29C", "color": "rgba(0,0,0,0.8)"}, "style_key14": {"background": "#ED9120", "color": "#FFFFFF"}, "style_key15": {"background": "#CD5B44", "color": "#FFFFFF"}, "style_key16": {"background": "#FAF570", "color": "rgba(0,0,0,0.8)"}, "style_key17": {"background": "#C29953", "color": "#FFFFFF"}, "style_key18": {"background": "#02B140", "color": "#FFFFFF"}, "style_key19": {"background": "#D5F4D5", "color": "rgba(0,0,0,0.8)"}, "style_key20": {"background": "#009966", "color": "#FFFFFF"}, "style_key21": {"background": "#023220", "color": "#FFFFFF"}, "style_key22": {"background": "#E7E7E7", "color": "rgba(0,0,0,0.8)"}, "style_key23": {"background": "#808080", "color": "#FFFFFF"} }
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/tag/create' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"name":"production","description":"Unified tag for production resources.","colour":"default","scope":["scene","monitor"]}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content.id | integer | Entity record number; the list id is a UUID string, as described in the list fields. |
| content.uuid | string | Tag UUID with the tag_ prefix. |
| content.workspaceUUID | string | Workspace to which the tag belongs. |
| content.name | string | Tag name. |
| content.description | string | Usage description. |
| content.colour | string | Color representation. |
| content.scope | array<string> |
Normalized scope. Historical null/empty scope is returned as ["all"]. |
| content.scope[] | string | One of all/scene/monitor/dialing/security/infrastructure/catalog. |
| content.status | integer | 0 for valid, 3 for deleted; other historical statuses are subject to actual data. |
| content.creator | string | Creator identity. |
| content.updator | string | Identity of the latest modifier. |
| content.createAt | integer | Creation time in Unix seconds. |
| content.updateAt | integer | Update time in Unix seconds; -1 if not updated. |
| content.deleteAt | integer | Deletion time in Unix seconds; -1 if not deleted. |
| content.declaration | object | Public declaration. |
{
"code": 200,
"content": {
"id": 100,
"uuid": "tag_example",
"workspaceUUID": "wksp_example",
"name": "production",
"description": "Unified tag for production resources.",
"colour": "default",
"scope": [
"scene",
"monitor"
],
"status": 0,
"creator": "wsak_example",
"updator": "",
"createAt": 1785427200,
"updateAt": -1,
"deleteAt": -1,
"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 | Verify the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Invalid request JSON syntax | Request JSON format error | Correct the JSON according to content.reason, line, and column. |
| 406 | ft.TagNameExists | A non-deleted tag with the same name exists in this workspace | A tag with the same name already exists | Change the name or check the original tag first. |
| 500 | ft.InternalServerError | Database, tag/permission structure, cache, or response formatting failed | Internal error | After verifying the request, read back the current tag state. The write may already have been committed, so avoid blind retries; if the failure persists, provide the traceId. |