Skip to content

Script variables

Script variables are key/value pairs available to scripts as ctx.env.

const TOKEN = "hv_..."; // your API key
const headers = { Authorization: `Bearer ${TOKEN}` };
GET /admin/script-variables

Requires 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"
}
]
POST /admin/script-variables

Requires 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: "..." }),
});

Response: 204 No Content

DELETE /admin/script-variables/{key}

Requires script-variables:delete.

Response: 204 No Content. Returns 404 Not Found for an unknown key.