What a script can call#

$http calls out through the proxy, $env reads workspace variables so secrets stay out of the code, and console writes to the panel below.

A script runs in a sandbox with a small set of APIs you can call from your code. The header comment of the starter template lists the namespaces that are in scope.

// Available APIs: $http, $env, console

$http#

$http gives you a network client to call another endpoint from inside a script. The most common use is a fetch of a token or a config value before you modify the current request.

The client supports the standard verbs (get, post, put, patch, delete) and returns a response object with status, headers, and body. Each call goes out through the same proxy, so it appears in the entries list as a new request alongside the originals.

$env#

$env gives you the user-set environment variables that are scoped to the GraphDagger workspace. Use it to keep secrets out of the script body.

const token = $env.AUTH_TOKEN;
request.headers["Authorization"] = `Bearer ${token}`;
return request;

Set the values in the workspace settings before you rely on them. An unset variable returns undefined.

console#

console.log and console.error write to the console panel at the bottom of the script editor. Each entry has a timestamp and the script name, so two scripts that log at the same time stay separate.

What is not available#

The script sandbox is deliberately narrow. Browser globals (window, document, localStorage), Node modules (require, process, fs), and arbitrary network APIs are not available. To talk to a system outside the proxy, use $http.