Overview
When writing JavaScript code for integrations, actions, triggers, or workflow code nodes, you have access to a set of built-in utility functions. These functions run in a secure sandboxed JavaScript environment that provides essential capabilities without requiring external libraries.These utilities are available in JavaScript code only. Python Code nodes use a
separate runtime and do not support
ld.* functions. For Python behavior, see
the Code node page.What is the Sandbox?
The sandbox is a secure, isolated JavaScript execution environment that:- Runs untrusted code safely - Memory-limited and timeout-enforced execution
- Provides essential utilities - HTTP requests, data conversions, cryptography
- Prevents security risks - No file system access, no dangerous globals like
evalorprocess - Requires no dependencies - No npm packages or external imports needed
Where These Utilities Are Available
The sandbox utilities are available in:- Custom integration actions - Code that interacts with external APIs
- Custom integration triggers - Code that monitors for events
- Authentication flows - OAuth and API key validation code
- Workflow code nodes - Custom JavaScript in workflow automations. For Python, see the Code node page.
HTTP & Networking
ld.request()
Make HTTP requests to external APIs with automatic JSON handling and error management. Parameters:By default,
ld.request() strips the Authorization header and other credential headers when a request is redirected to a different origin. Set preserveAuthOnRedirect: true to keep them across cross-origin redirects. Only enable this for APIs where you trust the redirect target.responseType: "stream" or "binary"):
The response shape depends on
responseType. By default, you get json and text properties. When using responseType: "stream" or "binary", you get a buffer property instead — json and text are not available in this mode.Requests to private and internal network addresses are blocked by default. On dedicated deployments that need to reach internal endpoints, operators can disable this check by setting the environment variable
URL_VALIDATION_ENABLED=false. This also applies to workflow HTTP Request nodes.ld.awsRequest()
Make AWS SigV4-signed requests to AWS services like S3, API Gateway, or custom AWS APIs. Parameters:Data Format Conversions
ld.csv2parquet()
Convert CSV text to Parquet format with optional compression and array support. Parameters:{ base64: string, success: boolean }
Example:
CSV columns containing array-like strings (e.g.,
"[Python,JavaScript]") are
automatically detected and converted to Parquet List columns.ld.parquet2csv()
Convert Parquet format to CSV text, handling List columns appropriately. Parameters:{ base64: string, success: boolean }
Example:
ld.arrow2parquet()
Convert Arrow IPC Stream format to Parquet. Parameters:ld.json2csv()
Convert JSON data to CSV format using the nodejs-polars library. Parameters:Database & SQL
ld.validateSqlQuery()
Validate SQL query syntax to ensure it’s non-empty and contains a single statement. Parameters:ld.ensureReadOnlySqlQuery()
Enforce that a SQL query is read-only by checking its execution type. Parameters:Cryptography
ld.signWithRS256()
Create RSA-SHA256 digital signatures, commonly used for JWT signing and OAuth flows. Function Signature:data(string): Data to signprivateKey(string): PEM-formatted RSA private keyoptions(object, optional):encoding(string): Output encoding -'base64'(default) or'hex'
{ signature: string } — object containing the signature in specified encoding
Example: JWT Signing
Utility Functions
ld.log()
Output debugging information to the execution logs, visible below the “Test Action” button. Parameters:ld.wait()
Pause execution for a specified number of milliseconds. Useful for rate limiting or retry logic. Parameters:atob() / btoa()
Base64 encoding and decoding functions, available globally without imports. atob() - Decode base64 string to binary string btoa() - Encode binary string to base64 Example: Base64 URL DecodingBuffer.from()
A minimal polyfill for converting between typed array formats. It accepts a single argument (an Array, Uint8Array, or ArrayBuffer) and returns aUint8Array.
Example: Convert ArrayBuffer from ld.request()
FormData
Create multipart form data for file uploads and complex request bodies. Example: File Upload with MetadataStandard JavaScript APIs
The sandbox also provides access to standard JavaScript built-ins: JSONJSON.stringify()- Convert objects to JSON stringsJSON.parse()- Parse JSON strings to objects
new Date()- Create date objectsDate.now()- Get current timestamp- All standard Date methods
Math.floor(),Math.ceil(),Math.round()Math.random(),Math.max(),Math.min()- All standard Math methods
new RegExp()- Create regular expressions- String regex methods:
match(),replace(),test()
- All standard Array methods:
map(),filter(),reduce(), etc. - All standard Object methods:
keys(),values(),entries(), etc.
Best Practices
Error Handling
Always wrap API calls in try-catch blocks and provide helpful error messages:Input Validation
Validate user inputs before using them:Performance Tips
Minimize API CallsSecurity Considerations
Never Hardcode SecretsCommon Pitfalls
1. Not Handling Async/Await ProperlyNext Steps
- Creating Custom Integrations - Build your first integration
- File Support for Actions - Handle file inputs and outputs
- Integration Agent - Get help writing integration code
- Workflow Code Node - Write custom code in workflows
FAQ
When should I use sandbox utility functions?
When should I use sandbox utility functions?
Use sandbox utility functions when building custom integrations, actions, triggers, or workflow code nodes that need common helper behavior. They can reduce boilerplate and make custom logic easier to maintain.