Skip to content

Script variables

Script variables are key/value pairs available to scripts as ctx.env. Use them for secrets such as API tokens: values are encrypted at rest with TOKEN_ENCRYPTION_KEY and never returned by the API. On an instance without that key they’re stored unencrypted, and the first boot with one encrypts them.

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. preview is always ****, whatever the value. unreadable is true for a value this instance’s TOKEN_ENCRYPTION_KEY can’t decrypt, usually because the key changed; scripts see such a variable as unset, and setting it again replaces it.

Response: 200 OK

[
{
"key": "API_TOKEN",
"preview": "****",
"unreadable": false,
"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.