Create a Vault credential
Stores one credential in the Vault. Secret values are write-only: accepted in the request, encrypted at rest, and omitted from every response.
- The credential’s unique key is the normalized
mcp_server_urlformcp_oauth/static_bearer,secret_nameforenvironment_variable. It must not collide with another active credential in the Vault (409conflict_error). - A Vault holds at most 20 active credentials (400
failed_precondition_error), and an archived Vault rejects new credentials.
curl --request POST \
--url https://api.moonshot.ai/v1/vaults/{id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
}
}
'import requests
url = "https://api.moonshot.ai/v1/vaults/{id}/credentials"
payload = { "auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
auth: {
type: 'static_bearer',
mcp_server_url: 'https://example.invalid/mcp',
token: 'sk-example'
}
})
};
fetch('https://api.moonshot.ai/v1/vaults/{id}/credentials', 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.ai/v1/vaults/{id}/credentials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'auth' => [
'type' => 'static_bearer',
'mcp_server_url' => 'https://example.invalid/mcp',
'token' => 'sk-example'
]
]),
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.ai/v1/vaults/{id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.moonshot.ai/v1/vaults/{id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/vaults/{id}/credentials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "conflict_error",
"message": "The resource changed since it was read. Reload it before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}Headers
API version for this request, in YYYY-MM-DD form. Send 2026-09-01-beta
for the version documented here. Required outside /v1/files*: a missing
header there is rejected with 400 invalid_request_error; on /v1/files*
its absence selects the compatibility behavior. An unknown value is
rejected with 400 invalid_request_error on every endpoint.
API versions served by the platform. New dated versions are added as they
ship; a version is removed after its announced Sunset date.
2026-09-01-beta Body
Display name and authentication settings for the credential to create.
Request body for adding a credential to a Vault.
Each credential has a unique key among the Vault's active credentials.
The key is the normalized mcp_server_url for mcp_oauth and
static_bearer, or secret_name for environment_variable.
Response
The created credential, with secret values omitted.
A credential stored in a Vault. Active credentials in the same Vault must
have distinct keys. The key is the normalized mcp_server_url for
mcp_oauth and static_bearer, or secret_name for
environment_variable.
Was this page helpful?
curl --request POST \
--url https://api.moonshot.ai/v1/vaults/{id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
}
}
'import requests
url = "https://api.moonshot.ai/v1/vaults/{id}/credentials"
payload = { "auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp",
"token": "sk-example"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
auth: {
type: 'static_bearer',
mcp_server_url: 'https://example.invalid/mcp',
token: 'sk-example'
}
})
};
fetch('https://api.moonshot.ai/v1/vaults/{id}/credentials', 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.ai/v1/vaults/{id}/credentials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'auth' => [
'type' => 'static_bearer',
'mcp_server_url' => 'https://example.invalid/mcp',
'token' => 'sk-example'
]
]),
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.ai/v1/vaults/{id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.moonshot.ai/v1/vaults/{id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/vaults/{id}/credentials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"auth\": {\n \"type\": \"static_bearer\",\n \"mcp_server_url\": \"https://example.invalid/mcp\",\n \"token\": \"sk-example\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "vcrd_01h455vb4pex5vsknk084sn02q",
"vault_id": "vlt_01h455vb4pex5vsknk084sn02q",
"display_name": "MCP access",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://example.invalid/mcp"
},
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "conflict_error",
"message": "The resource changed since it was read. Reload it before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}