创建或更新密钥
curl --request PUT \
--url https://api-datahub.bazhuayu.com/v1/secrets/{name} \
--header 'Content-Type: application/json' \
--data '
{
"value": "<string>"
}
'import requests
url = "https://api-datahub.bazhuayu.com/v1/secrets/{name}"
payload = { "value": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({value: '<string>'})
};
fetch('https://api-datahub.bazhuayu.com/v1/secrets/{name}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({value: '<string>'})
};
fetch('https://api-datahub.bazhuayu.com/v1/secrets/{name}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/secrets/{name}"
payload := strings.NewReader("{\n \"value\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
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.put("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"<string>\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/secrets/{name}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'value' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/secrets/{name}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"value\": \"<string>\"\n}", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"value\": \"<string>\"\n}")
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
.put(body)
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()false{
"name": "<string>",
"masked": "<string>",
"scope": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}凭证密钥
创建或更新密钥
写入一个密钥的值,已存在则覆盖(轮换)。
PUT
/
v1
/
secrets
/
{name}
创建或更新密钥
curl --request PUT \
--url https://api-datahub.bazhuayu.com/v1/secrets/{name} \
--header 'Content-Type: application/json' \
--data '
{
"value": "<string>"
}
'import requests
url = "https://api-datahub.bazhuayu.com/v1/secrets/{name}"
payload = { "value": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({value: '<string>'})
};
fetch('https://api-datahub.bazhuayu.com/v1/secrets/{name}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({value: '<string>'})
};
fetch('https://api-datahub.bazhuayu.com/v1/secrets/{name}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/secrets/{name}"
payload := strings.NewReader("{\n \"value\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
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.put("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"<string>\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/secrets/{name}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'value' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/secrets/{name}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"value\": \"<string>\"\n}", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"value\": \"<string>\"\n}")
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/secrets/{name}")
.put(body)
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()false{
"name": "<string>",
"masked": "<string>",
"scope": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}端点
PUT https://api-datahub.bazhuayu.com/v1/secrets/{name}
Authorization: Bearer <API Key>)。
写入密钥值,已存在则覆盖,即轮换。名称是 manifest runtime.env 里引用的那个。
请求
路径参数
string
必填
密钥名称,大写字母、数字与下划线。
请求体
string
必填
密钥明文。只写不读。
示例请求
curl -X PUT \
-H "Authorization: Bearer $BAZHUAYU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "sk-example"}' \
"https://api-datahub.bazhuayu.com/v1/secrets/EXAMPLE_API_KEY"
响应
200 成功
{
"data": {
"name": "EXAMPLE_API_KEY",
"masked": "********mple",
"scope": "publisher",
"created_at": "2026-09-15T07:45:42.285442+00:00",
"updated_at": "2026-09-15T07:45:42.285442+00:00"
}
}
data 字段中,其内容如下。
string
必填
—
string
必填
—
string
—
string
必填
—
string
必填
—
错误
| HTTP | code | category | 说明 |
|---|---|---|---|
| 401 | unauthorized | forbidden | 缺少或无效的 API Key。 |
{"error": {code, category, message, retryable}},见错误。
