customScript input lets you run an inline JavaScript snippet against every captured event before it is written to storage. Use it to normalize payloads from different providers, strip PII, inject debug metadata, or remap fields — all without modifying the sender or adding a separate processing step.
How scripts run
Each script executes inside a sandboxed worker thread. The worker is shared for the lifetime of the actor run, so the sandbox is persistent but isolated from the main server process. The runtime enforces a bounded execution timeout and memory ceiling so a runaway script cannot block request handling or exhaust host resources. If a script fails or times out, the error is logged and the webhook capture continues normally — the event is still stored and the sender still receives the configured response.Script context
Your script receives four injected values:The event object
These fields on event are writable and affect what is stored:
The req object
req is a reduced, read-only snapshot of the incoming request — not the live request object. It gives your script access to query parameters, the original URL, and the remote IP for use in transformation logic. You cannot call methods on req or modify it; changes have no effect.
What scripts cannot do
Scripts run in a restricted sandbox. The following are not available:process— no access to the Node.js process object or environment variablesrequire/import— no module loading- Filesystem APIs — no
fs,path, or similar - Network APIs — no
fetch,http,https, orXMLHttpRequest eval()andFunction()— code generation from strings is disabled
Common use cases
1. Parse and normalize a JSON body
WhenenableJSONParsing is off or the body arrives as a raw string, parse it yourself and add a debug flag:
2. Strip PII before storage
Remove sensitive fields from the payload so they are never written to the dataset:3. Add debug metadata
Inject custom fields for easier filtering in/logs queries:
4. Remap fields for a downstream schema
Flatten or rename fields before the event is forwarded or stored:Adjusting worker memory
If your scripts process large payloads and hit memory limits, you can raise the worker heap ceilings with two environment variables:
See Environment variables for how to set these in a local
.env or Docker run command.