Script Variables
Script variables are encrypted key/value pairs available to Lua scripts as ctx.env. Use them for secrets like API tokens.
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 keytoken := "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 a list of variable keys (values are not returned).
Upsert a script variable
Section titled “Upsert a script variable”POST /admin/script-variablesRequires script-variables:create.
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 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)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": "..." }'The value is encrypted at rest using TOKEN_ENCRYPTION_KEY.
Delete a script variable
Section titled “Delete a script variable”DELETE /admin/script-variables/{key}Requires script-variables:delete.

