Return
| Parameter | Purpose | Example |
|---|---|---|
| value | The value to return from the function | "Hello World", 123, {key: "value"} |
Example
Example
- Returns a value from the function execution
- Can return any data type (string, number, object, array, etc.)
- Terminates function execution
Debug Log
| Parameter | Purpose | Example |
|---|---|---|
| value | The value to output to the debug log | "Debug message", $variable, `response |
Example
Example
- Outputs a value to the debug log
- Useful for development and troubleshooting
- Can log any data type
- Does not affect function execution
Precondition
| Parameter | Purpose | Example |
|---|---|---|
| error_type | The type of error to throw | Can be one of the following: |
| error | The error message to display | "Resource not found", "Access denied" |
| payload | Additional data to include with the error | "Error details", {reason: "Invalid input"} |
Example
Example
Try / Catch
- Executes code in the
tryblock - If an error occurs, the
catchblock runs - The
finallyblock always runs (optional)
Throw Error
- Immediately stops execution and throws an error
- Can be caught by a surrounding
try_catchblock
Post Process
- Executes after the main response is sent
- Useful for logging, cleanup, or async side effects
Send Email
-
Use
api.requestto send emails via external providers (e.g., SendGrid, Mailgun) - Set API keys in environment variables
-
Check
$email_responsefor status - Checks a condition and throws an error if the condition is true
- Allows specifying error type, message, and additional payload
- Useful for validation and access control
- Stops execution if condition is met
Stop and Debug
| Parameter | Purpose | Example |
|---|---|---|
| value | The value to return when stopping execution | "Debug stop message", $variable, {status: "stopped"} |
Example
Example
- Immediately stops function execution
- Returns the specified value
- Useful for debugging and development
- Can return any data type
Group
| Parameter | Purpose | Example |
|---|---|---|
| group | Container for organizing operations | group { ... } |
| stack | Executes operations in sequence | stack { ... } |
| value | Duration to sleep in seconds | 1, 2, 0.5 |
Example
Example
- Groups related operations together
- Stack ensures sequential execution
- Sleep pauses execution for specified duration
- Operations in stack execute in order
Sleep
| Parameter | Purpose | Example |
|---|---|---|
| value | Number of seconds to pause execution | 1, 0.5, 2.5 |
Example
Example
- Pauses execution for specified number of seconds
- Accepts decimal values for sub-second precision
- Useful for rate limiting or creating delays
CSV Stream
| Parameter | Purpose | Example |
|---|---|---|
| value | Input CSV data source | $input.csv_input, $file.content |
| separator | Character used to separate fields | ",", ";", "\t" |
| enclosure | Character used to enclose fields | '"', "'" |
| escape_char | Character used to escape special characters | '"', "\" |
| as | Alias to reference the stream | csv_stream |
Example
Example
- Creates a stream from CSV formatted data
- Configurable field separator, enclosure, and escape characters
- Assigns stream to an alias for later reference
- Useful for processing large CSV files
JSONL Stream
| Parameter | Purpose | Example |
|---|---|---|
| value | Input JSONL data source | $input.JSONL_file, $file.content |
| as | Alias to reference the stream | jsonl_stream |
Example
Example
- Creates a stream from JSON Lines formatted data
- Each line must be a valid JSON object
- Assigns stream to an alias for later reference
- Useful for processing large datasets line by line
Set HTTP Header
| Parameter | Purpose | Example |
|---|---|---|
| value | HTTP header value to set | "HTTP 1.1 200 OK", "Content-Type: application/json" |
| duplicates | How to handle duplicate headers | "replace", "append" |
Example
Example
- Sets HTTP response headers
- Controls how duplicate headers are handled
- Useful for customizing API responses
- Common for setting content types, status codes, and custom headers
Get All Variables
| Parameter | Purpose | Example |
|---|---|---|
| as | New variable to contain the returned variables | all_variables, vars |
Example
Example
- Returns an object containing all variables
Get All Inputs
| Parameter | Purpose | Example |
|---|---|---|
| as | Alias to reference the input data | all_input, request_data |
Example
Example
- Retrieves all input data from the current request as defined in the inputs section
Get All Raw Input
| Parameter | Purpose | Example |
|---|---|---|
| encoding | Format of the input data | "json", "raw", "text" |
| exclude_middleware | Whether or not to allow middleware to affect the raw inputs | true, false |
| as | Alias to reference the input | all_raw_input, request_body |
Example
Example
- Retrieves raw input data from the request
Get Environment Variables
| Parameter | Purpose | Example |
|---|---|---|
| as | Alias to reference the environment variables | all_env_vars, env |
Example
Example
- Returns an object containing all environment variables
Calculate Distance
| Parameter | Purpose | Example |
|---|---|---|
| latitude_1 | Latitude of first point | 37.7749, -33.8688 |
| longitude_1 | Longitude of first point | 122.4194, 151.2093 |
| latitude_2 | Latitude of second point | 35.6762, 51.5074 |
| longitude_2 | Longitude of second point | 139.6503, -0.1278 |
| as | Alias to reference the calculated distance | distance, route_length |
Example
Example
- Calculates the distance (straight line) between two geographic coordinates
IP Address Lookup
| Parameter | Purpose | Example |
|---|---|---|
| value | IP address to look up | "1.1.1.1", "192.168.1.1", $request.ip |
| as | Alias to reference the lookup results | ip_location, visitor_location |
Example
Example
- Performs geolocation lookup for an IP address
Set Data Source
| Parameter | Purpose | Example |
|---|---|---|
| value | Name of the datasource to use | "test", "production", "staging" |
Example
Example
- Sets the active database datasource
Async Await
| Parameter | Purpose | Example |
|---|---|---|
| ids | Array of async operation IDs to wait for | [], ["task1", "task2"], $pending_tasks |
| timeout | Maximum time to wait in seconds | 10, 30, 60 |
| as | Alias to reference the results | async_returns, task_results |
Example
Example
- Waits for completion of asynchronous operations
- Specifies maximum wait time
- Collects results from multiple async operations
- Returns results when all operations complete or timeout is reached