创建服务级账号

最近更新时间: 2026-10-10 00:11:03

1. 接口描述

接口请求域名: tcr.api3.fincloud.tencent.com。

创建服务级账户

默认接口请求频率限制:20次/秒。

接口更新时间:2023-09-11 02:44:07。

接口既验签名又鉴权。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见公共请求参数。

参数名称 必选 允许NULL 类型 描述
Action 是 否 String 公共参数,本接口取值:CreateServiceAccount
Version 是 否 String 公共参数,本接口取值:2019-09-24
Region 是 否 String 公共参数,地域信息本接口不需要传递此参数。
RegistryId 是 否 String 实例Id
示例值:
Name 是 否 String 服务级账号名
示例值:
Description 否 否 String 服务级账号描述
示例值:
Duration 否 否 Int64 有效期(单位:天),从当前时间开始计算,优先级高于ExpiresAt
示例值:
ExpiresAt 否 否 Int64 过期时间(时间戳,单位:毫秒)
示例值:
Disable 否 否 Bool 是否禁用服务级账号
示例值:
Permissions 是 否 Array of Permission 策略列表
示例值:查看

3. 输出参数

参数名称 类型 描述
Name String 服务级账号名(会自动加上前缀tcr$)
示例值:
Password String 服务级账号密码,仅展示一次,请注意留存
示例值:
ExpiresAt Int64 服务级账号失效时间(时间戳)
示例值:
CreateTime Datetime_iso 服务级账号创建时间
示例值:
RequestId String 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。

4. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见公共错误码。

错误码 描述
InvalidParameter
UnsupportedOperation
UnknownParameter
OperationDenied 操作被拒绝。
FailedOperation
OperationDenied.QuotaOverLimit 配额超限。
FailedOperation.DbError 数据库错误。

5. 示例

示例1 创建服务级账号

创建服务级账号

输入示例

POST / HTTP/1.1
Host: tcr.api3.fincloud.tencent.com
Content-Type: application/json
X-TC-Action: CreateServiceAccount
<公共请求参数>

{
  "RegistryId": "abc",
  "Name": "abc",
  "Description": "abc",
  "Duration": 0,
  "ExpiresAt": 0,
  "Disable": true,
  "Permissions": [
    {
      "Resource": "abc",
      "Actions": [
        "abc"
      ]
    }
  ]
}

输出示例

{
  "Response": {
    "Name": "tcr@abc",
    "Password": "abc",
    "ExpiresAt": 0,
    "CreateTime": "2020-09-22T00:00:00+00:00",
    "RequestId": "abc"
  }
}

示例2 使用Duration创建ServiceAccount

使用Duration创建ServiceAccount

输入示例

POST / HTTP/1.1
Host: tcr.api3.fincloud.tencent.com
Content-Type: application/json
X-TC-Action: CreateServiceAccount
<Common Parameters>

{
  "RegistryId": "tcr-45uu7ras",
  "Name": "test",
  "Description": "for test",
  "Duration": 10,
  "Permissions": [
    {
      "Resource": "test",
      "Actions": [
        "tcr:PullRepository",
        "tcr:PushRepository",
        "tcr:CreateRepository"
      ]
    }
  ]
}

输出示例

{
  "Response": {
    "CreateTime": "2023-03-28T15:48:31+08:00",
    "ExpiresAt": 1680853711137,
    "Name": "tcr$test",
    "Password": "oNKUtqrB5Eb68JufkVanSwuhmC4Ergn7",
    "RequestId": "20b67612-28a0-4c51-8efb-0fe14bc23a64"
  }
}