---
title: "更新 Credential"
method: POST
path: "/agent/managed/v1/vaults/{vaultId}/credentials/{credentialId}"
tags: ["Managed Agents - Vault"]
---

# 更新 Credential

`POST /agent/managed/v1/vaults/{vaultId}/credentials/{credentialId}`

## Request

- Base URL: `https://agent-api.bigmodel.cn/api`
- URL: `https://agent-api.bigmodel.cn/api/agent/managed/v1/vaults/{vaultId}/credentials/{credentialId}`
- Auth: HTTP bearer

更新指定 Credential 的展示信息或认证材料，可用于轮换 Token、Secret 和 OAuth 刷新配置；敏感值只写不回显。

## Path parameters

- `vaultId` string, required
- `credentialId` string, required

## Headers

- `zai-version` '2026-05-26', required
- `zai-beta` string, required

## Request body

- ManagedCredentialUpdateRequest
  - `display_name` string, nullable: 替换显示名称；null 表示清为空字符串，省略时保持不变。
  - `metadata` ManagedMetadataPatch, nullable: 元数据补丁；省略整个字段时保持不变，键值为 null 时删除对应键。最多 16 个键，键名长度不超过 64 字符，字符串值不超过 512 字符。
  - `auth` union
    - object
      - `type` 'mcp_oauth', required
      - `access_token` string, nullable
      - `expires_at` string, date-time, nullable
      - `refresh` ManagedOAuthRefreshUpdate
        - `scope` string, nullable: 替换 scope；null 表示清空，省略时保持不变。
        - `refresh_token` string, nullable: 轮换 refresh token；null 或省略时保留现有 secret。
        - `token_endpoint_auth` ManagedTokenEndpointAuthUpdate
          - `type` 'client_secret_basic' | 'client_secret_post', required: 必须与已有 Token Endpoint 认证类型一致。
          - `client_secret` string, nullable: 轮换 Client Secret；null 或省略时保留现有 secret。
    - object
      - `type` 'static_bearer', required
      - `token` string, nullable
    - object
      - `type` 'oauth', required
      - `access_token` string, nullable
      - `expires_at` string, date-time, nullable
      - `refresh` ManagedOAuthRefreshUpdate
        - `scope` string, nullable: 替换 scope；null 表示清空，省略时保持不变。
        - `refresh_token` string, nullable: 轮换 refresh token；null 或省略时保留现有 secret。
        - `token_endpoint_auth` ManagedTokenEndpointAuthUpdate
          - `type` 'client_secret_basic' | 'client_secret_post', required: 必须与已有 Token Endpoint 认证类型一致。
          - `client_secret` string, nullable: 轮换 Client Secret；null 或省略时保留现有 secret。
    - object
      - `type` 'bearer', required
      - `token` string, nullable
    - object
      - `type` 'environment_variable', required
      - `secret_value` string, nullable
      - `networking` union
        - object
          - `type` 'unrestricted', required
        - object
          - `type` 'limited', required
          - `allowed_hosts` string[], required: 允许注入凭据的目标 host，最多 16 个；支持 IPv4、hostname 或 *.example.com 通配形式，不得包含协议、端口或路径。
      - `injection_location` ManagedVaultInjectionLocationInput
        - `header` boolean: 是否允许注入到请求头；省略时为 true。
        - `body` false: 当前不支持请求体注入，只能为 false；省略时为 false。

## Response `200`

请求成功。

- ManagedCredential
  - `type` 'vault_credential', required
  - `id` string, required
  - `display_name` string, required
  - `vault_id` string, required
  - `metadata` ManagedMetadata, required: 客户端自定义元数据；省略时默认为空对象。最多 16 个键，键名长度不超过 64 字符，值必须是长度不超过 512 字符的字符串。
  - `auth` union, required
    - object
      - `type` 'mcp_oauth', required
      - `mcp_server_url` string, uri, nullable, required: 公开 HTTPS Streamable HTTP URL；不得包含凭据、fragment、空 query 或旧式 SSE 路径。
      - `expires_at` string, date-time, nullable, required
      - `refresh` ManagedOAuthRefreshResponse, required
        - `token_endpoint` string, uri, required: HTTPS URL；不得包含凭据或 fragment。
        - `client_id` string, required
        - `token_endpoint_auth` object, required
          - `type` 'none' | 'client_secret_basic' | 'client_secret_post', required
        - `scope` string, nullable, required
        - `resource` string, nullable, required
    - object
      - `type` 'static_bearer', required
      - `mcp_server_url` string, uri, nullable, required: 公开 HTTPS Streamable HTTP URL；不得包含凭据、fragment、空 query 或旧式 SSE 路径。
    - object
      - `type` 'oauth', required
      - `host` string, uri, nullable, required: HTTPS origin；不得包含路径、query、fragment 或凭据。
      - `expires_at` string, date-time, nullable, required
      - `refresh` ManagedOAuthRefreshResponse, required
        - `token_endpoint` string, uri, required: HTTPS URL；不得包含凭据或 fragment。
        - `client_id` string, required
        - `token_endpoint_auth` object, required
          - `type` 'none' | 'client_secret_basic' | 'client_secret_post', required
        - `scope` string, nullable, required
        - `resource` string, nullable, required
    - object
      - `type` 'bearer', required
      - `host` string, uri, nullable, required: HTTPS origin；不得包含路径、query、fragment 或凭据。
    - object
      - `type` 'environment_variable', required
      - `secret_name` string, nullable, required
      - `networking` union, required
        - object
          - `type` 'unrestricted', required
        - object
          - `type` 'limited', required
          - `allowed_hosts` string[], required: 允许注入凭据的目标 host，最多 16 个；支持 IPv4、hostname 或 *.example.com 通配形式，不得包含协议、端口或路径。
      - `injection_location` ManagedVaultInjectionLocationResponse, required
        - `header` boolean, required
        - `body` false, required
  - `created_at` string, date-time, required: 创建时间。
  - `updated_at` string, date-time, required: 更新时间。
  - `archived_at` string, nullable, required: 归档时间。

## Other responses

- `default`: 请求失败。

## Changes

- **2026-11-03** `7fd61aa7f811`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/changes/agent/managed/v1/vaults/:vaultId/credentials/:credentialId/post.md)

---

[API](https://skmtc.dev/bigmodel/apis/zhipu-ai-api.md) - [All operations](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/revisions/f2be7c0fcbb9?raw)
