Skip to main content

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 eval or process
  • Requires no dependencies - No npm packages or external imports needed
Custom integration code runs in a secure sandboxed environment. You cannot install or import external libraries (npm, pip, etc.) - only the built-in JavaScript/Node.js APIs documented here are available. For advanced processing (e.g., PDF parsing, image manipulation), use external APIs or services and call them from your integration code.

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.
Returns (default):
Returns (with 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.
Example: GET Request
Example: POST Request with Body
Example: File Download
Example: Form Data Upload
The body parameter is automatically stringified if you pass an object. For application/x-www-form-urlencoded content type, the body is automatically converted to the appropriate format.
Response bodies are capped at 100 MB. Requests that return more data — including chunked responses without a Content-Length header and oversized error responses — fail with a Response too large error. If you need to fetch larger files, stream them to external storage (for example, S3) instead of returning them through ld.request().
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:
Example: S3 File Upload

Data Format Conversions

ld.csv2parquet()

Convert CSV text to Parquet format with optional compression and array support. Parameters:
Returns: { 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:
Returns: { base64: string, success: boolean } Example:

ld.arrow2parquet()

Convert Arrow IPC Stream format to Parquet. Parameters:
Returns: Base64-encoded Parquet file Example:

ld.json2csv()

Convert JSON data to CSV format using the nodejs-polars library. Parameters:
Returns: CSV text Example:

Database & SQL

ld.validateSqlQuery()

Validate SQL query syntax to ensure it’s non-empty and contains a single statement. Parameters:
Returns: The trimmed query string if valid, throws error otherwise Example:

ld.ensureReadOnlySqlQuery()

Enforce that a SQL query is read-only by checking its execution type. Parameters:
Returns: The trimmed query string if read-only, throws error otherwise Example:
This function checks the query execution type to ensure it’s LISTING or INFORMATION only. Queries that modify data (INSERT, UPDATE, DELETE) will be rejected.

Cryptography

ld.signWithRS256()

Create RSA-SHA256 digital signatures, commonly used for JWT signing and OAuth flows. Function Signature:
Parameters:
  • data (string): Data to sign
  • privateKey (string): PEM-formatted RSA private key
  • options (object, optional):
    • encoding (string): Output encoding - 'base64' (default) or 'hex'
Returns: { signature: string } — object containing the signature in specified encoding Example: JWT Signing
The private key must be in PEM format. Invalid keys will throw user-friendly error messages. Never expose private keys in logs or return values.

Utility Functions

ld.log()

Output debugging information to the execution logs, visible below the “Test Action” button. Parameters:
Example:
Use ld.log() liberally during development to debug your integration code. Logs are automatically redacted to hide sensitive authentication values.

ld.wait()

Pause execution for a specified number of milliseconds. Useful for rate limiting or retry logic. Parameters:
Example:

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 Decoding
Example: Basic Authentication

Buffer.from()

A minimal polyfill for converting between typed array formats. It accepts a single argument (an Array, Uint8Array, or ArrayBuffer) and returns a Uint8Array.
This is NOT the full Node.js Buffer. It only accepts Array, Uint8Array, or ArrayBuffer — not strings. Passing a string like Buffer.from("hello") will throw an error. The returned Uint8Array does not have a .toString("base64") method. For base64 encoding/decoding, use btoa()/atob() instead.
Example: Convert ArrayBuffer from ld.request()
Example: Base64 encode a downloaded file

FormData

Create multipart form data for file uploads and complex request bodies. Example: File Upload with Metadata

Standard JavaScript APIs

The sandbox also provides access to standard JavaScript built-ins: JSON
  • JSON.stringify() - Convert objects to JSON strings
  • JSON.parse() - Parse JSON strings to objects
Date
  • new Date() - Create date objects
  • Date.now() - Get current timestamp
  • All standard Date methods
Math
  • Math.floor(), Math.ceil(), Math.round()
  • Math.random(), Math.max(), Math.min()
  • All standard Math methods
RegExp
  • new RegExp() - Create regular expressions
  • String regex methods: match(), replace(), test()
Array & Object
  • All standard Array methods: map(), filter(), reduce(), etc.
  • All standard Object methods: keys(), values(), entries(), etc.
Example: Data Transformation

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 Calls
Use Pagination

Security Considerations

Never Hardcode Secrets
Sanitize User Input
Handle Rate Limits

Common Pitfalls

1. Not Handling Async/Await Properly
2. Accessing Nested Properties Without Checks
3. Not Parsing JSON Strings
4. Modifying Frozen Objects

Next Steps

FAQ

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.
Check whether you are using the function in a supported context, whether the function name and arguments are correct, and whether the runtime supports the behavior you need.