标签

修改标签

PATCH /v1/tags/{id}

写请求需要 Idempotency-Key,填写一个 UUID。同一次操作重试保留原 key、正文和 etag;结果保留 30 天,超过期限先核对数据,不要盲目重试。兼容原时间戳:UUID 格式。

需要 If-Match,原样使用当前 etag(包括引号)。缺失返回 428,冲突返回 412。

请求参数

id

path · 必填

资源、任务或操作标识

类型: string

完整 JSON Schema
{
  "type": "string",
  "minLength": 1,
  "maxLength": 512
}

Idempotency-Key

header · 必填

写请求需要 Idempotency-Key,填写一个 UUID。同一次操作重试保留原 key、正文和 etag;结果保留 30 天,超过期限先核对数据,不要盲目重试。兼容原时间戳:UUID 格式。

类型: string

完整 JSON Schema
{
  "type": "string"
}

If-Match

header · 必填

需要 If-Match,原样使用当前 etag(包括引号)。缺失返回 428,冲突返回 412。

类型: string

完整 JSON Schema
{
  "type": "string"
}

请求体

必填

application/json

类型: object

字段类型必填说明与约束
namestring否名称 {"minLength":1,"maxLength":300}
parentIdstring | null否父标签 ID;根标签为 null
parentId (anyOf 1)string否{"minLength":1,"maxLength":512}
parentId (anyOf 2)null否
archiveTimestring | null否归档时间;null 表示未归档
archiveTime (anyOf 1)string否{"format":"date-time"}
archiveTime (anyOf 2)null否
完整 JSON Schema
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300,
      "description": "名称"
    },
    "parentId": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        {
          "type": "null"
        }
      ],
      "description": "父标签 ID;根标签为 null"
    },
    "archiveTime": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "归档时间;null 表示未归档"
    }
  }
}

调用示例

将路径参数和请求参数替换为实际值。请求体按上述结构保存到 request.json。

curl --fail-with-body --request PATCH 'https://api.treering.cn/v1/tags/{id}' \
  --header "Authorization: Bearer $TREERING_API_TOKEN" \
  --header 'Idempotency-Key: <Idempotency-Key>' \
  --header 'If-Match: <If-Match>' \
  --header 'Content-Type: application/json' \
  --data-binary @request.json

响应

200

成功响应;具体状态取决于操作结果。

application/json

类型: object

字段类型必填说明与约束
idstring是资源、任务或操作标识
versionstring是版本号,十进制字符串,不要转为浮点数 {"pattern":"^(0|[1-9][0-9]*)$"}
etagstring是并发版本标记;保留引号用于 If-Match
updatedAtstring是服务端最后更新时间
operationIdstring否请求回执标识,无需查询状态
deletedAtstring否删除时间
namestring | null否名称
name (anyOf 1)string否
name (anyOf 2)null否
parentIdstring | null否父标签 ID;根标签为 null
parentId (anyOf 1)string否
parentId (anyOf 2)null否
archiveTimestring | null否归档时间;null 表示未归档
archiveTime (anyOf 1)string否
archiveTime (anyOf 2)null否
createTimestring | null否原始创建时间
createTime (anyOf 1)string否
createTime (anyOf 2)null否
sourcestring | null否来源标记
source (anyOf 1)string否
source (anyOf 2)null否
完整 JSON Schema
{
  "type": "object",
  "required": [
    "id",
    "version",
    "etag",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "资源、任务或操作标识"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "description": "版本号,十进制字符串,不要转为浮点数"
    },
    "etag": {
      "type": "string",
      "description": "并发版本标记;保留引号用于 If-Match"
    },
    "updatedAt": {
      "type": "string",
      "description": "服务端最后更新时间"
    },
    "operationId": {
      "type": "string",
      "description": "请求回执标识,无需查询状态"
    },
    "deletedAt": {
      "type": "string",
      "description": "删除时间"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "名称"
    },
    "parentId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "父标签 ID;根标签为 null"
    },
    "archiveTime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "归档时间;null 表示未归档"
    },
    "createTime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "原始创建时间"
    },
    "source": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "来源标记"
    }
  },
  "additionalProperties": false
}

400, 401, 403, 404, 409, 412, 413, 422, 428, 429, 500, 503

错误响应;请按 code 处理。

application/json

类型: object

字段类型必填说明与约束
codestring是机器可读错误码
messagestring否错误说明;请按 code 处理程序逻辑
requestIdstring否请求追踪标识
operationIdstring否请求回执标识,无需查询状态
完整 JSON Schema
{
  "type": "object",
  "required": [
    "code"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "机器可读错误码"
    },
    "message": {
      "type": "string",
      "description": "错误说明;请按 code 处理程序逻辑"
    },
    "requestId": {
      "type": "string",
      "description": "请求追踪标识"
    },
    "operationId": {
      "type": "string",
      "description": "请求回执标识,无需查询状态"
    }
  },
  "additionalProperties": true
}

目录