Create a credential
curl --request POST \
--url https://api.example.com/v1/vaults/{vault_id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": [
"<string>"
]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
},
"token": "<string>"
},
"display_name": "<string>"
}
'import requests
url = "https://api.example.com/v1/vaults/{vault_id}/credentials"
payload = {
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": ["<string>"]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
},
"token": "<string>"
},
"display_name": "<string>"
}
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_secret',
scope: {match: 'exact', targets: ['<string>']},
send: {type: 'header', name: '<string>', value: '<string>'},
token: '<string>'
},
display_name: '<string>'
})
};
fetch('https://api.example.com/v1/vaults/{vault_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.example.com/v1/vaults/{vault_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_secret',
'scope' => [
'match' => 'exact',
'targets' => [
'<string>'
]
],
'send' => [
'type' => 'header',
'name' => '<string>',
'value' => '<string>'
],
'token' => '<string>'
],
'display_name' => '<string>'
]),
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.example.com/v1/vaults/{vault_id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\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.example.com/v1/vaults/{vault_id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/vaults/{vault_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_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "vault_credential",
"vault_id": "<string>",
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": [
"<string>"
]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
}
},
"display_name": "<string>",
"custody": "storing",
"created_at": "<string>",
"updated_at": "<string>",
"archived_at": "<string>"
}{
"id": "<string>",
"type": "vault_credential",
"vault_id": "<string>",
"pending": true
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "authentication_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_found_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_acceptable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "conflict_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "payload_too_large",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "unsupported_media_type",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "internal_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "service_unavailable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}Create a credential
Store a credential in a vault. Its secret is never returned.
POST
/
v1
/
vaults
/
{vault_id}
/
credentials
Create a credential
curl --request POST \
--url https://api.example.com/v1/vaults/{vault_id}/credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": [
"<string>"
]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
},
"token": "<string>"
},
"display_name": "<string>"
}
'import requests
url = "https://api.example.com/v1/vaults/{vault_id}/credentials"
payload = {
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": ["<string>"]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
},
"token": "<string>"
},
"display_name": "<string>"
}
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_secret',
scope: {match: 'exact', targets: ['<string>']},
send: {type: 'header', name: '<string>', value: '<string>'},
token: '<string>'
},
display_name: '<string>'
})
};
fetch('https://api.example.com/v1/vaults/{vault_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.example.com/v1/vaults/{vault_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_secret',
'scope' => [
'match' => 'exact',
'targets' => [
'<string>'
]
],
'send' => [
'type' => 'header',
'name' => '<string>',
'value' => '<string>'
],
'token' => '<string>'
],
'display_name' => '<string>'
]),
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.example.com/v1/vaults/{vault_id}/credentials"
payload := strings.NewReader("{\n \"auth\": {\n \"type\": \"static_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\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.example.com/v1/vaults/{vault_id}/credentials")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"auth\": {\n \"type\": \"static_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/vaults/{vault_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_secret\",\n \"scope\": {\n \"match\": \"exact\",\n \"targets\": [\n \"<string>\"\n ]\n },\n \"send\": {\n \"type\": \"header\",\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n },\n \"token\": \"<string>\"\n },\n \"display_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "vault_credential",
"vault_id": "<string>",
"auth": {
"type": "static_secret",
"scope": {
"match": "exact",
"targets": [
"<string>"
]
},
"send": {
"type": "header",
"name": "<string>",
"value": "<string>"
}
},
"display_name": "<string>",
"custody": "storing",
"created_at": "<string>",
"updated_at": "<string>",
"archived_at": "<string>"
}{
"id": "<string>",
"type": "vault_credential",
"vault_id": "<string>",
"pending": true
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "authentication_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_found_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_acceptable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "conflict_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "payload_too_large",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "unsupported_media_type",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "internal_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "service_unavailable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}Headers
Body
application/json
Response
VaultCredential
- Option 1
- Option 2