# GearTrain Documentation > GearTrain runs JavaScript on a schedule. Write a script, give it a cron expression, and GearTrain executes it in a sandbox with a live console, run history, and a persistent file system. This file and every page under `/llms/` are plain Markdown for LLM consumption. Resolve root-relative links against this documentation site. Do not fetch the HTML pages. Generated 2026-11-16. The complete corpus is also available in [llms-full.txt](/llms-full.txt). It is large; prefer the page links below. ## Execution Context & Agent Rules GearTrain runs a job's entry script top to bottom in a sandbox. The entry script can import built-in modules and your own local files. - **Script format.** Write raw top-to-bottom JavaScript. Do not wrap the entry script in `export default`, `module.exports`, or `async function main()`. - **Top-level `await`.** `await` works at the top level, so asynchronous code reads top to bottom. - **Imports.** Import built-in modules by name (`import fs from "fs";`, `import env from "env";`) and your own files with relative paths (`import { formatDate } from "./format.js";`). There is no third-party module system, so do not install or import npm packages. - **File system paths.** Every `fs` path must be absolute and start with `/`, such as `/data/state.json`. Relative paths, `.` segments, `..` segments, and trailing slashes are rejected. - **Secrets and environment.** Read values with `env.get("KEY_NAME")`. `process.env` is not available. `env.get` throws when the name does not exist. - **Web APIs.** `fetch`, `crypto`, `URL`, `TextEncoderStream`, and the other documented Web APIs are globals. Use them without importing. Core pages: - [Getting Started](/llms/guide/index.md) - [fs](/llms/api/js/fs.md) - [env](/llms/api/js/env.md) - [context](/llms/api/js/context.md) - [Webhooks](/llms/guide/webhooks.md) - [Webhook Verification](/llms/guide/webhook-verification.md) - [The Sandbox](/llms/guide/sandbox.md) ## Start Here - [Writing Jobs](/llms/guide/writing-jobs.md): A job pairs a script with one or more triggers: a schedule, a webhook, or manual runs. This guide covers the script side: where scripts live, what they look... - [fs](/llms/api/js/fs.md): Read, write, and manage files in the sandbox file system. The module works in bytes and web streams. Files are read as Uint8Arrays (or strings with... - [env](/llms/api/js/env.md): Environment variables available to this run. Provides read-only access to named values supplied for the current run — your saved secrets plus any variables set... - [context](/llms/api/js/context.md): Facts about the current run. Use this module to find out what started the script and, when a webhook payload is available, to read the request body and whether... - [Hello, World](/llms/examples/hello-world.md): Log a message to the run console and watch it appear live. ## Guide - [Getting Started](/llms/guide/index.md): GearTrain automates work that runs on a schedule or when an event arrives. You write a script, choose how it starts, and GearTrain executes it with a live... - [Writing Jobs](/llms/guide/writing-jobs.md): A job pairs a script with one or more triggers: a schedule, a webhook, or manual runs. This guide covers the script side: where scripts live, what they look... - [Running and Debugging](/llms/guide/running-and-debugging.md): Every execution of a job is a run. GearTrain records each run with its status, duration, and console output, so you can see what your jobs did and why. This... - [Webhooks](/llms/guide/webhooks.md): A webhook starts a job when another service sends an event. This guide shows how to add an endpoint, read the delivery in your script, and handle the common... - [Webhook Verification](/llms/guide/webhook-verification.md): Every endpoint verifies a delivery before it starts a run. The verification method decides which headers, credentials, and replay checks apply. Choose the... - [Secrets and Environment Variables](/llms/guide/secrets-and-env.md): Jobs often need values they should not hardcode: API keys, tokens, endpoints. GearTrain gives you two ways to provide them, and scripts read both the same way,... - [The Sandbox](/llms/guide/sandbox.md): Scripts run in a sandboxed environment: a fixed, small set of building blocks, with no operating system access and nothing to install. This page lists what a... - [Using the REST API](/llms/guide/rest-api.md): The REST API lets your own tools work with the same account as the workbench. Use it from a server, a CI job, or an automation script to manage jobs, read run... - [Connect an AI Agent](/llms/guide/mcp.md): GearTrain runs a remote Model Context Protocol server, so an AI agent can work with your account directly instead of handing you code to paste. An agent you... - [Best Practices](/llms/guide/best-practices.md): Small habits that keep jobs reliable. Most of these come down to the same idea that shapes GearTrain itself: keep it simple. A job should do one thing. A job... ## Examples - [Examples](/llms/examples/index.md): Complete scripts grouped by category. - [Hello, World](/llms/examples/hello-world.md): Log a message to the run console and watch it appear live. - [Run a Job on a Schedule](/llms/examples/run-job-on-a-schedule.md): Turn a script into a job with a cron expression. - [Read and Write Files](/llms/examples/read-and-write-files.md): Store and read files in the built-in file system. - [Keep State Between Runs](/llms/examples/keep-state-between-runs.md): Persist data across runs with a JSON file. - [Fetch JSON From an API](/llms/examples/fetch-json-from-an-api.md): Call an HTTP endpoint and parse the JSON response. - [Send a POST Request With a JSON Body](/llms/examples/send-post-request-with-json.md): Send data to an API with fetch and a JSON body. - [Retry a Failed Request With Backoff](/llms/examples/retry-failed-request-with-backoff.md): Retry a failing request with exponential backoff. - [Send a Signed Webhook With Standard Webhooks](/llms/examples/send-signed-webhook.md): Send a signed webhook with Standard Webhooks so the receiver can verify it. - [Send a Message to Slack](/llms/examples/send-message-to-slack.md): Post to a Slack channel with an incoming webhook. - [Send a Message to Discord](/llms/examples/send-message-to-discord.md): Post to a Discord channel with a webhook. - [Post to a Custom Webhook](/llms/examples/post-to-custom-webhook.md): Send a JSON payload to any webhook endpoint. - [Monitor an Endpoint's Uptime](/llms/examples/monitor-endpoint-uptime.md): Check that an endpoint responds and alert when it fails. - [Check a Web Page for Changes](/llms/examples/check-web-page-for-changes.md): Watch a page and notify when its content changes. - [Parse and Generate CSV](/llms/examples/parse-and-generate-csv.md): Read a CSV file and write a new one. - [Build an HTML Report](/llms/examples/build-html-report.md): Generate an HTML file from your data. - [Scrape a Page With a Service](/llms/examples/scrape-a-page-with-a-service.md): Fetch a page through a scraping service and get structured JSON back. - [Build a Daily Digest](/llms/examples/build-daily-digest.md): Collect items and send a daily summary. - [Back Up Large Data With Streaming](/llms/examples/back-up-large-data-with-streaming.md): Download large data to a file without running out of memory. - [Use S3-Compatible Storage](/llms/examples/use-s3-compatible-storage.md): Sign requests to an S3-compatible bucket and upload a file without an SDK. ## APIs - [APIs](/llms/api/index.md): JS API and REST API reference documentation. - [JS API](/llms/api/js/index.md): Modules and Web APIs available in every script. - [REST API](/llms/api/rest.md): HTTP API for jobs, runs, files, and secrets. ## Modules - [fs](/llms/api/js/fs.md): Read, write, and manage files in the sandbox file system. The module works in bytes and web streams. Files are read as Uint8Arrays (or strings with... - [env](/llms/api/js/env.md): Environment variables available to this run. Provides read-only access to named values supplied for the current run — your saved secrets plus any variables set... - [context](/llms/api/js/context.md): Facts about the current run. Use this module to find out what started the script and, when a webhook payload is available, to read the request body and whether... ## Web APIs - [AbortController](/llms/api/js/abort-controller.md): AbortController and AbortSignal cancel in-progress asynchronous operations. Create a controller, pass its signal to an operation (such as fetch()), and call... - [Blob & File](/llms/api/js/blob-file.md): Blob represents immutable binary data — bytes with a MIME type and a size. File extends Blob with a file name and a last-modified timestamp. Use them to pass... - [btoa / atob](/llms/api/js/btoa-atob.md): btoa() and atob() convert between binary strings and Base64. btoa(data) encodes a string in which every character code is 0–255 into Base64; atob(data) decodes... - [Compression](/llms/api/js/compression.md): CompressionStream compresses a stream of bytes; DecompressionStream decompresses one. Both support brotli, deflate, deflate-raw, and gzip. - new... - [console](/llms/api/js/console.md): console provides logging and debugging output for your scripts. Messages written with it appear in the run's log output, which you can inspect from the run... - [Events](/llms/api/js/events.md): EventTarget is the base class for objects that emit events. Extend it, register listeners with addEventListener(), and send an event with dispatchEvent().... - [fetch](/llms/api/js/fetch.md): fetch() performs HTTP requests and returns a Promise for a Response. Together with the Headers, Request, and Response classes it provides the WHATWG Fetch API... - [FormData](/llms/api/js/formdata.md): FormData represents a set of form fields — name/value pairs that can be sent as a multipart/form-data request body. It is the standard way to upload files or... - [Streams](/llms/api/js/streams.md): The Streams globals handle data that arrives or is produced in pieces rather than all at once: ReadableStream is a source you read from, WritableStream a... - [structuredClone](/llms/api/js/structured-clone.md): structuredClone() creates a deep copy of a value, preserving types and references within the value: nested objects stay nested, two references to the same... - [Encoding](/llms/api/js/encoding.md): TextEncoder converts strings into UTF-8 bytes; TextDecoder converts UTF-8 bytes back into strings. Use them whenever you move between text and raw bytes: file... - [timers](/llms/api/js/timers.md): The timer functions schedule work to run after a delay or on a repeating interval. They are globals — available without importing anything. -... - [URL](/llms/api/js/url.md): URL parses, manipulates, and normalizes URLs; URLSearchParams is a map-like view of a URL query string — the part after ?. Both handle the percent-encoding... - [Web Crypto](/llms/api/js/web-crypto.md): crypto provides cryptographically secure random values and version 4 UUIDs. crypto.subtle provides low-level cryptographic operations: hashing, encryption,... ## Changelog - [Changelog](/llms/changelog.md): Public release notes. The REST API base URL is `https://app.geartrain.dev/api/v1`. ## Machine-readable - [LLM manifest](/llms/manifest.json): Page paths, titles, groups, and descriptions as JSON. - [Full documentation](/llms-full.txt): Every page in one Markdown file. Prefer page-level reads. - [Search index](/search.json): Page titles and headings as JSON. - [REST API OpenAPI specification](/api/openapi.yaml): OpenAPI 3.1 contract for the REST API.