Skip to main content
POST
/
api
/
vault
/
get-secrets
Get Secret(s)
curl --request POST \
  --url http://localhost:3000/api/vault/get-secrets \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: text/plain' \
  --data '
{
  "key": "OPENAI_API_KEY",
  "tags": [
    "openai"
  ]
}
'
import requests

url = "http://localhost:3000/api/vault/get-secrets"

payload = {
"key": "OPENAI_API_KEY",
"tags": ["openai"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "text/plain"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'text/plain'},
body: JSON.stringify({key: 'OPENAI_API_KEY', tags: ['openai']})
};

fetch('http://localhost:3000/api/vault/get-secrets', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/api/vault/get-secrets",
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([
'key' => 'OPENAI_API_KEY',
'tags' => [
'openai'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: text/plain"
],
]);

$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 := "http://localhost:3000/api/vault/get-secrets"

payload := strings.NewReader("{\n \"key\": \"OPENAI_API_KEY\",\n \"tags\": [\n \"openai\"\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "text/plain")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("http://localhost:3000/api/vault/get-secrets")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "text/plain")
.body("{\n \"key\": \"OPENAI_API_KEY\",\n \"tags\": [\n \"openai\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:3000/api/vault/get-secrets")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'text/plain'
request.body = "{\n \"key\": \"OPENAI_API_KEY\",\n \"tags\": [\n \"openai\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "err": {},
  "res": {
    "OPEN_API_KEY": "OPEN_API_VALUE"
  }
}

Cross-origin browser requests

POST /api/vault/get-secrets is an API-key authenticated endpoint for retrieving Vault secrets. Browser requests from a different origin are blocked unless the calling origin is explicitly allowed. To allow a browser application hosted on another domain, configure the OpenLIT deployment with a comma-separated origin allowlist:
OPENLIT_ALLOWED_CORS_ORIGINS="https://app.example.com,https://admin.example.com"
OPENLIT_ALLOWED_ORIGINS is also supported as a backward-compatible alias. NEXTAUTH_URL is automatically treated as an allowed same-site origin. Use complete origins such as https://app.example.com. Do not configure wildcard origins for this endpoint.
Server-to-server SDK or REST requests usually do not need CORS configuration because CORS is enforced by browsers.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

text/plain
key
string
Example:

"OPENAI_API_KEY"

tags
string[]
Example:
["openai"]

Response

200 - application/json

Successfully retrieved secret(s).

err
object | null
res
object
Example:
{ "OPEN_API_KEY": "OPEN_API_VALUE" }