Replace Environment Secrets
curl --request PUT \
--url https://sdk.localops.co/v1/environments/{envId}/secrets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"secrets": [
{
"key": "DB_URL",
"value": "postgres://user:pass@host:5432/db",
"description": "primary db",
"is_sensitive": true,
"expose_to_chart": false,
"chart_default_val": null,
"dep_export": false
}
]
}
'import requests
url = "https://sdk.localops.co/v1/environments/{envId}/secrets"
payload = { "secrets": [
{
"key": "DB_URL",
"value": "postgres://user:pass@host:5432/db",
"description": "primary db",
"is_sensitive": True,
"expose_to_chart": False,
"chart_default_val": None,
"dep_export": False
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
secrets: [
{
key: 'DB_URL',
value: 'postgres://user:pass@host:5432/db',
description: 'primary db',
is_sensitive: true,
expose_to_chart: false,
chart_default_val: null,
dep_export: false
}
]
})
};
fetch('https://sdk.localops.co/v1/environments/{envId}/secrets', 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://sdk.localops.co/v1/environments/{envId}/secrets"
payload := strings.NewReader("{\n \"secrets\": [\n {\n \"key\": \"DB_URL\",\n \"value\": \"postgres://user:pass@host:5432/db\",\n \"description\": \"primary db\",\n \"is_sensitive\": true,\n \"expose_to_chart\": false,\n \"chart_default_val\": null,\n \"dep_export\": false\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"message": "<string>",
"data": {
"secrets": [
{
"key": "<string>",
"value": "<string>",
"description": "<string>",
"is_sensitive": true,
"expose_to_chart": true,
"chart_default_val": "<string>",
"dep_export": true,
"updated_at": "2023-11-07T05:31:56Z"
}
]
}
}Secrets
Replace Environment Secrets
Replace the environment’s entire secret set. This is a full write and not a merge - any key you omit is removed. Read the current set, modify it, then write the whole set back.
Keys must be non empty after trimming and unique within the array. Validation runs before anything is written.
PUT
/
v1
/
environments
/
{envId}
/
secrets
Replace Environment Secrets
curl --request PUT \
--url https://sdk.localops.co/v1/environments/{envId}/secrets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"secrets": [
{
"key": "DB_URL",
"value": "postgres://user:pass@host:5432/db",
"description": "primary db",
"is_sensitive": true,
"expose_to_chart": false,
"chart_default_val": null,
"dep_export": false
}
]
}
'import requests
url = "https://sdk.localops.co/v1/environments/{envId}/secrets"
payload = { "secrets": [
{
"key": "DB_URL",
"value": "postgres://user:pass@host:5432/db",
"description": "primary db",
"is_sensitive": True,
"expose_to_chart": False,
"chart_default_val": None,
"dep_export": False
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
secrets: [
{
key: 'DB_URL',
value: 'postgres://user:pass@host:5432/db',
description: 'primary db',
is_sensitive: true,
expose_to_chart: false,
chart_default_val: null,
dep_export: false
}
]
})
};
fetch('https://sdk.localops.co/v1/environments/{envId}/secrets', 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://sdk.localops.co/v1/environments/{envId}/secrets"
payload := strings.NewReader("{\n \"secrets\": [\n {\n \"key\": \"DB_URL\",\n \"value\": \"postgres://user:pass@host:5432/db\",\n \"description\": \"primary db\",\n \"is_sensitive\": true,\n \"expose_to_chart\": false,\n \"chart_default_val\": null,\n \"dep_export\": false\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"message": "<string>",
"data": {
"secrets": [
{
"key": "<string>",
"value": "<string>",
"description": "<string>",
"is_sensitive": true,
"expose_to_chart": true,
"chart_default_val": "<string>",
"dep_export": true,
"updated_at": "2023-11-07T05:31:56Z"
}
]
}
}Authorizations
Your account API token, sent as Authorization: Bearer <api_token>. Owners and admins can read the token from the LocalOps console.
Path Parameters
The unique identifier of the environment
Body
application/json
Show child attributes
Show child attributes
Was this page helpful?
⌘I