> ## Documentation Index
> Fetch the complete documentation index at: https://ppio.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 更新模板

## 请求头

<ParamField header="Content-Type" type="string" required={true}>
  枚举值：application/json。
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer 身份验证格式，例如：Bearer \{\{API 密钥}}。
</ParamField>

## 请求体

<ParamField body="template" type="object" required={true}>
  模板信息对象，用于定义实例模板配置。

  <Expandable title="properties" defaultOpen={true}>
    <ParamField body="Id" type="string" required={true}>
      模板 ID。长度：\[1-255]。
    </ParamField>

    <ParamField body="name" type="string" required={true}>
      模板名称。长度：\[1-255]。
    </ParamField>

    <ParamField body="type" type="string" required={true}>
      模板类型。可选值：

      * `instance`
    </ParamField>

    <ParamField body="channel" type="string" required={true}>
      模板可见性。可选值：

      * `private`
    </ParamField>

    <ParamField body="readme" type="string" required={false}>
      模板说明，支持 Markdown。长度：\[0-102400]。
    </ParamField>

    <ParamField body="image" type="string" required={true}>
      镜像地址，可为公共镜像或私有镜像。长度：\[1-500]。
    </ParamField>

    <ParamField body="imageAuth" type="string" required={false}>
      私有镜像认证信息 ID。长度：\[0-255]。
    </ParamField>

    <ParamField body="startCommand" type="string" required={false}>
      启动命令。长度：\[0-2047]。
    </ParamField>

    <ParamField body="entrypoint" type="string" required={false}>
      实例启动 entrypoint。该配置会覆盖 Docker 镜像的 ENTRYPOINT。长度：\[0-2047]。
    </ParamField>

    <ParamField body="rootfsSize" type="integer" required={true}>
      系统盘大小（单位：GB）。取值范围：> 0。
    </ParamField>

    <ParamField body="ports" type="object[]" required={false}>
      端口配置列表，用于定义暴露的服务端口。

      <Expandable title="properties" defaultOpen={false}>
        <ParamField body="type" type="string" required={true}>
          端口类型。可选值：`tcp`、`http`。
        </ParamField>

        <ParamField body="ports" type="integer[]" required={true}>
          端口号数组。取值范围：\[1-65535]；其中 2222、2223、2224 为内部端口，不可使用。
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="envs" type="object[]" required={false}>
      实例环境变量。最多创建 100 组。

      <Expandable title="properties" defaultOpen={false}>
        <ParamField body="key" type="string" required={false}>
          环境变量名。长度：\[0-511]。
        </ParamField>

        <ParamField body="value" type="string" required={false}>
          环境变量值。长度：\[0-4095]。
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="minCudaVersion" type="string" required={false}>
      模板支持的最小 CUDA 版本，需填写指定格式，例如：11.8、12.4。长度：\[0-255]。
    </ParamField>
  </Expandable>
</ParamField>

## 响应参数

<ResponseField name="templateId" type="string" required={true}>
  模板 ID。
</ResponseField>

## 示例

### 请求示例

```bash theme={null}
curl --location --request POST 'https://api.ppio.com/gpu-instance/openapi/v1/template/update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{API 密钥}}' \
--data-raw '{
  "template": {
    "Id": "101036",
    "name": "test",
    "type": "instance",
    "channel": "private",
    "readme": "test create template",
    "image": "nginx",
    "imageAuth": "",
    "startCommand": "echo test",
    "entrypoint": "",
    "rootfsSize": 60,
    "ports": [
      {"type": "http", "ports": [80, 443]},
      {"type": "tcp", "ports": [90, 95]}
    ],
    "envs": [
      {"key": "test1", "value": "template1"},
      {"key": "test2", "value": "test2"}
    ],
    "minCudaVersion": "11.8"
  }
}'
```

### 响应示例

```json theme={null}
{
  "templateId": "101036"
}
```
