Script variables are key/value pairs available to scripts as ctx.env.
const TOKEN = "hv_..."; // your API keyconst headers = { Authorization: `Bearer ${TOKEN}` };const TOKEN = "hv_..."; // your API keyconst headers = { Authorization: `Bearer ${TOKEN}` };let token = "hv_..."; // your API keyconst token = "hv_..." // your API key# All examples assume $TOKEN is an API key (hv_...)AUTH="Authorization: Bearer $TOKEN"List script variables
Section titled “List script variables”GET /admin/script-variablesRequires script-variables:read. Returns the variables ordered by key. Values are never returned, only a masked preview: the value’s first four characters followed by ****, or only asterisks for a value of four characters or fewer.
Response: 200 OK
[ { "key": "API_TOKEN", "preview": "sk_l****", "created_at": "2026-03-01T00:00:00Z", "updated_at": "2026-03-01T00:00:00Z" }]Upsert a script variable
Section titled “Upsert a script variable”POST /admin/script-variablesRequires script-variables:create. Sets value for key, creating the variable or replacing its value. Both fields are required strings.
const response = await fetch("http://127.0.0.1:3000/admin/script-variables", { method: "POST", headers: { ...headers, "Content-Type": "application/json", }, body: JSON.stringify({ key: "ALGOLIA_API_KEY", value: "..." }),});const response = await fetch("http://127.0.0.1:3000/admin/script-variables", { method: "POST", headers: { ...headers, "Content-Type": "application/json", }, body: JSON.stringify({ key: "ALGOLIA_API_KEY", value: "..." }),});let client = reqwest::Client::new();let response = client .post("http://127.0.0.1:3000/admin/script-variables") .bearer_auth(token) .json(&serde_json::json!({ "key": "ALGOLIA_API_KEY", "value": "..." })) .send() .await?;body := bytes.NewBufferString(`{ "key": "ALGOLIA_API_KEY", "value": "..." }`)req, _ := http.NewRequest("POST", "http://127.0.0.1:3000/admin/script-variables", body)req.Header.Set("Authorization", "Bearer "+token)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil { log.Fatal(err)}defer resp.Body.Close()curl -X POST http://127.0.0.1:3000/admin/script-variables \ -H "$AUTH" \ -H "Content-Type: application/json" \ -d '{ "key": "ALGOLIA_API_KEY", "value": "..." }'Response: 204 No Content
Delete a script variable
Section titled “Delete a script variable”DELETE /admin/script-variables/{key}Requires script-variables:delete.
Response: 204 No Content. Returns 404 Not Found for an unknown key.
© HappyProto

