Skip to content

Import



POST /api/v1/tag/import

Overview

Bulk import global tag templates, supporting duplicate name checking, skipping, and overwriting.

Body Request Parameters

Parameter Name Type Required Description
tags array Y List of tag templates
Allow empty: False
tags[*] None
tags[*].name string Y Tag name
Allow empty: False
tags[*].description string Tag description
Allow empty: False
tags[*].colour string Tag color
Allow empty: False
repeatTagNameOp string Duplicate tag name handling strategy
Allow empty: False
Optional values: ['check', 'skip', 'recover']

Parameter Supplementary Description

This API is used to import global tag templates individually.

Calling Process

  1. Prepare the tags array, where each element represents a tag template.
  2. Specify the handling strategy for encountering duplicate tag names via repeatTagNameOp.
  3. If the strategy is check and duplicate tag names exist, the API will directly return repeat_name without performing database operations.

repeatTagNameOp Description

Value Description
check Only check for duplicates; returns repeat_name if duplicate tag names exist
skip Skip existing duplicate tag names, only import non-existent tags
recover When a duplicate tag name exists in the target workspace, overwrite its description and colour

Template Fields

Field type Required Description
name string Yes Tag name
description string No Tag description
colour string No Tag color

Return Description

  • Returns successCount, failCount upon successful import execution.
  • If some objects fail to execute, the response will additionally include failedNames.
  • Returns repeat_name if duplicates are found in check mode.

Request Example

curl 'https://openapi.truewatch.com/api/v1/tag/import' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"repeatTagNameOp":"recover","tags":[{"name":"核心服务","description":"核心服务标签","colour":"style_key3"}]}'

Response

{
    "code": 200,
    "content": {
        "successCount": 2,
        "failCount": 0
    },
    "errorCode": "",
    "message": "",
    "success": true,
    "traceId": "TRACE-EXAMPLE"
}