set_config
PUT
/api/v1/admin/config/{key}
const url = 'https://example.com/api/v1/admin/config/example';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"value":["example"],"visibility":"private"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use std::str::FromStr;use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/admin/config/example";
let payload = json!({ "value": ("example"), "visibility": "private" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.request(reqwest::Method::from_str("PUT").unwrap(), url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request PUT \ --url https://example.com/api/v1/admin/config/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "value": [ "example" ], "visibility": "private" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”key
required
string
Config key
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
Set a system configuration value.
object
value
required
One of:
Scalar string value.
string
JSON string-list value.
Array<string>
Responses
Section titled “Responses”Config value set
Media typeapplication/json
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
code
required
string
data
object
category
required
string
description
required
string
id
required
integer format: int64
is_sensitive
required
boolean
key
required
string
namespace
required
string
requires_restart
required
boolean
source
required
Origin of a stored configuration value.
string
updated_at
required
string
updated_by
integer | null format: int64
value
required
One of:
Scalar string value.
string
JSON string-list value.
Array<string>
value_type
required
Supported system configuration value types.
string
visibility
required
Consumer visibility for a stored configuration value.
string
error
msg
required
string
Example
{ "code": "success", "data": { "source": "system", "value_type": "string", "visibility": "private" }}Invalid request
Unauthorized
Forbidden