更新凭据
curl --request PATCH \
--url https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "Updated MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-02T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}重命名凭据或轮换其秘密设置。
字段按字段合并(见 UpdateVaultCredentialRequest):秘密值不能清空为空,凭据类型及其标识字段不可变更。刷新出现终态失败后,轮换 access_token 或 refresh_token 可恢复托管刷新。更新已归档的凭据返回 404。
PATCH
/
v1
/
vaults
/
{id}
/
credentials
/
{credential_id}
更新凭据
curl --request PATCH \
--url https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/vaults/{id}/credentials/{credential_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "Updated MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-02T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}路径参数
凭据库(Vault)ID。
Pattern:
^vlt_[0-9a-hjkmnp-tv-z]{26}$凭据 ID。
Pattern:
^vcrd_[0-9a-hjkmnp-tv-z]{26}$请求体
application/json
轮换或重命名凭据的部分更新请求体。字段按字段合并:提供的值替换已存储的值,省略、null 或空值保留原值——秘密值无法通过更新清空。对于 environment_variable 凭据,networking 为整体替换、injection_location 按字段合并。对于 mcp_oauth,refresh 块按字段合并。认证类型及其标识字段(secret_name、mcp_server_url、token_endpoint、client_id)不可变。
响应
更新后的凭据,秘密值不返回。
凭据库(Vault)中存储的一条凭据。唯一键——mcp_oauth/static_bearer 为规范化后的 mcp_server_url,environment_variable 为 secret_name——在同一凭据库的活跃凭据中不可重复。
凭据 ID。
Pattern:
^vcrd_[0-9a-hjkmnp-tv-z]{26}$所属凭据库(Vault)的 ID。
Pattern:
^vlt_[0-9a-hjkmnp-tv-z]{26}$人类可读的凭据名称。
MCP 服务器的 OAuth 2.0 凭据。
- MCP OAuth 凭据
- 静态 Bearer 凭据
- 环境变量凭据
Show child attributes
Show child attributes
创建时间戳。
最后更新时间戳。
归档时间戳。活跃期间不含此字段。
此页面对您有帮助吗?