Scripts
SDK reference for scripts operations
Overview
Execute user-defined scripts in AWS Lambda
- Category:
productivity - Auth Required: No
- Supported Modes: standard, delegated, service
Operations
createScript
Create a new script with initial version and API key. Returns flat structure with id field for subsequent operations.
Arguments:
name(string, required): Name of the scriptdescription(string, optional): Description of what the script doesruntime(string, optional): Lambda runtime (default: nodejs18)config(object, optional): Script configuration (timeout, memory, maxCostPerExecution, etc.)code(string, required): Initial JavaScript/TypeScript code for the script
Returns:
object - Returns FLAT structure: { id, name, description, runtime, timeout, memory, activeVersion, isPublished, isPrivate, status, deploymentStatus, apiKey, installationId, createdAt }. Use data.id as scriptId for deployScript.
Response Fields:
| Field | Type | Description |
|---|---|---|
id | string | Created script ID |
name | string | Script name |
description | string | Script description |
runtime | string | Lambda runtime (e.g., nodejs18) |
timeout | number | Timeout in seconds |
memory | number | Memory in MB |
activeVersion | number | Active version number |
isPublished | boolean | Whether published |
isPrivate | boolean | Whether private |
status | string | Script status |
deploymentStatus | string | Deployment status |
apiKey | string | API key for script execution (only returned on creation) |
installationId | string | Auto-created installation ID |
createdAt | string | Created timestamp (ISO 8601) |
Example:
deleteScript
Delete a script and all its versions. Returns flat deletion confirmation.
Arguments:
scriptId(string, required): ID of the script to delete
Returns:
object - Returns FLAT structure: { deleted, scriptId, hardDeleted, installationsRemoved, preservedInstallations }
Response Fields:
| Field | Type | Description |
|---|---|---|
deleted | boolean | Whether deletion succeeded |
scriptId | string | Deleted script ID |
hardDeleted | boolean | Whether script was permanently deleted |
installationsRemoved | number | Number of installations removed |
preservedInstallations | number | Number of installations preserved (soft delete) |
Example:
createVersion
Create a new version of an existing script. Returns flat version details.
Arguments:
scriptId(string, required): ID of the scriptcode(string, required): Updated code for the new versioncommitMessage(string, optional): Description of changes in this version
Returns:
object - Returns FLAT structure: { id, scriptId, version, isActive, commitMessage, codeHash, createdAt, deployedAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
id | string | Version document ID |
scriptId | string | Parent script ID |
version | number | Version number |
isActive | boolean | Whether this version is active |
commitMessage | string | Commit message for this version |
codeHash | string | Hash of the code |
createdAt | string | Created timestamp (ISO 8601) |
deployedAt | string | Deployed timestamp (ISO 8601) or empty |
Example:
listVersions
List all versions of a script. Returns flat version structures.
Arguments:
scriptId(string, required): ID of the script
Returns:
object - Returns { count, versions[] }. Each version has FLAT fields: id, scriptId, version, isActive, commitMessage, codeHash, createdAt, deployedAt.
Response Fields:
| Field | Type | Description |
|---|---|---|
count | number | Number of versions |
versions | ScriptVersion[] | List of script versions |
versions item fields (ScriptVersion)
| Field | Type | Description |
|---|---|---|
id | string | Version document ID |
scriptId | string | Parent script ID |
version | number | Version number |
isActive | boolean | Whether this version is active |
commitMessage | string | Commit message for this version |
codeHash | string | Hash of the code |
createdAt | string | Created timestamp (ISO 8601) |
deployedAt | string | Deployed timestamp (ISO 8601) or empty |
Example:
deployScript
Deploy a script version to AWS Lambda. Must be called after createScript to make the script executable.
Arguments:
scriptId(string, required): ID of the script to deploy (from createScript response at data._id)version(number, optional): Version number to deploy (default: latest)
Returns:
object - Returns { success: true, data: { scriptId, version, lambdaFunctionName, lambdaArn, deployedAt } }
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Deployed script ID |
version | number | Deployed version number |
lambdaFunctionName | string | AWS Lambda function name |
lambdaArn | string | AWS Lambda ARN |
deployedAt | string | Deployment timestamp (ISO 8601) |
Example:
executeScript
Execute a deployed script with custom data. Script must be deployed first via deployScript. Returns flat execution result.
Arguments:
scriptId(string, required): ID of the script to execute (from createScript response at data.id)data(object, optional): Input data to pass to the scripttrigger(object, optional): Trigger information (type, source, event)
Returns:
object - Returns FLAT structure: { executionId, scriptId, status, output, duration, logs[], error, createdAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
executionId | string | Unique execution ID |
scriptId | string | Executed script ID |
status | string | Execution status |
output | any | Script output data |
duration | number | Execution duration in milliseconds |
logs | string[] | Execution logs |
error | string | Error message (empty if no error) |
createdAt | string | Execution timestamp (ISO 8601) |
Example:
getScript
Get details of a specific script. Returns flat normalized structure.
Arguments:
scriptId(string, required): ID of the script
Returns:
object - Returns FLAT structure: { id, name, description, runtime, timeout, memory, activeVersion, isPublished, isPrivate, status, deploymentStatus, lambdaFunctionName, lambdaArn, totalExecutions, totalCost, avgDuration, errorRate, createdAt, deployedAt, publishedAt, lastExecutedAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
id | string | Script ID |
name | string | Script name |
description | string | Script description |
runtime | string | Lambda runtime |
timeout | number | Timeout in seconds |
memory | number | Memory in MB |
activeVersion | number | Active version number |
isPublished | boolean | Whether published |
isPrivate | boolean | Whether private |
status | string | Script status |
deploymentStatus | string | Deployment status |
lambdaFunctionName | string | Lambda function name |
lambdaArn | string | Lambda ARN |
totalExecutions | number | Total executions |
totalCost | number | Total cost in USD |
avgDuration | number | Average duration in ms |
errorRate | number | Error rate (0-1) |
createdAt | string | Created timestamp (ISO 8601) |
deployedAt | string | Deployed timestamp (ISO 8601) or empty |
publishedAt | string | Published timestamp (ISO 8601) or empty |
lastExecutedAt | string | Last execution timestamp (ISO 8601) or empty |
Example:
listScripts
List all scripts owned by the user. Returns flat script summaries.
Returns:
object - Returns { count, scripts[] }. Each script has FLAT fields: id, name, description, activeVersion, isPublished, status, deploymentStatus, totalExecutions, createdAt.
Response Fields:
| Field | Type | Description |
|---|---|---|
count | number | Number of scripts |
scripts | ScriptSummary[] | List of scripts |
scripts item fields (ScriptSummary)
| Field | Type | Description |
|---|---|---|
id | string | Unique script ID |
name | string | Script name |
description | string | Script description |
activeVersion | number | Currently active version number |
isPublished | boolean | Whether script is published to marketplace |
status | string | Script status (draft, published, archived) |
deploymentStatus | string | Deployment status (pending, deploying, deployed, failed) |
totalExecutions | number | Total number of executions |
createdAt | string | Created timestamp (ISO 8601) |
Example:
getExecutions
Get execution history for a script. Returns flat execution summaries.
Arguments:
scriptId(string, required): ID of the scriptstatus(string, optional): Filter by status (completed, failed, running)limit(number, optional): Maximum number of executions to return (default: 100)
Returns:
object - Returns { scriptId, count, executions[] }. Each execution has FLAT fields: executionId, scriptId, status, duration, createdAt, hasError.
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Script ID |
count | number | Number of executions |
executions | ScriptExecutionSummary[] | List of executions |
executions item fields (ScriptExecutionSummary)
| Field | Type | Description |
|---|---|---|
executionId | string | Unique execution ID |
scriptId | string | Script that was executed |
status | string | Execution status (running, completed, failed) |
duration | number | Execution duration in milliseconds |
createdAt | string | Execution timestamp (ISO 8601) |
hasError | boolean | Whether execution had an error |
Example:
getExecution
Get details of a specific execution. Returns flat execution structure.
Arguments:
executionId(string, required): ID of the execution
Returns:
object - Returns FLAT structure: { executionId, scriptId, status, output, duration, logs[], error, createdAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
executionId | string | Execution ID |
scriptId | string | Script ID |
status | string | Execution status |
output | any | Script output |
duration | number | Duration in milliseconds |
logs | string[] | Execution logs |
error | string | Error message (empty if no error) |
createdAt | string | Execution timestamp (ISO 8601) |
Example:
publishScript
Publish a script to the marketplace. Returns flat publish confirmation.
Arguments:
scriptId(string, required): ID of the script to publishpricing(object, optional): Pricing configuration for the marketplace
Returns:
object - Returns FLAT structure: { scriptId, isPublished, status, publishedAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Published script ID |
isPublished | boolean | Publication status (true) |
status | string | Script status |
publishedAt | string | Publish timestamp (ISO 8601) |
Example:
unpublishScript
Remove a script from the marketplace. Returns flat unpublish confirmation.
Arguments:
scriptId(string, required): ID of the script to unpublish
Returns:
object - Returns FLAT structure: { scriptId, unpublished }
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Unpublished script ID |
unpublished | boolean | Whether unpublish succeeded |
Example:
listMarketplaceScripts
Search and list published scripts in the marketplace. Returns flat script summaries with pagination.
Arguments:
name(string, optional): Exact match on script namesystem(boolean, optional): Filter by system scripts (scope="system") when true, user scripts when falsesearch(string, optional): Text search on name and descriptiontags(array, optional): Filter by tags (matches scripts with any of the specified tags)category(string, optional): Filter by UI category (notification, data_sync, automation, utility, reporting)pricingModel(string, optional): Filter by pricing model (free, pay-per-execution, subscription)staffPick(boolean, optional): Filter to only staff-picked scripts when trueminRating(number, optional): Minimum rating threshold (0-5)requiredIntegrations(array, optional): Filter by required integrations (e.g., ["telegram", "gmail"])sortBy(string, optional): Sort field: rating, installCount, trendingScore, publishedAt, name (default: rating)sortOrder(string, optional): Sort order: asc or desc (default: desc)limit(number, optional): Maximum number of results to return (default: 50, max: 100)offset(number, optional): Number of results to skip for pagination (default: 0)
Returns:
object - Returns { total, limit, offset, scripts[] }. Each script has FLAT fields: id, name, description, activeVersion, isPublished, status, deploymentStatus, totalExecutions, createdAt.
Response Fields:
| Field | Type | Description |
|---|---|---|
total | number | Total number of matching scripts |
limit | number | Page size limit |
offset | number | Current offset |
scripts | ScriptSummary[] | List of marketplace scripts |
scripts item fields (ScriptSummary)
| Field | Type | Description |
|---|---|---|
id | string | Unique script ID |
name | string | Script name |
description | string | Script description |
activeVersion | number | Currently active version number |
isPublished | boolean | Whether script is published to marketplace |
status | string | Script status (draft, published, archived) |
deploymentStatus | string | Deployment status (pending, deploying, deployed, failed) |
totalExecutions | number | Total number of executions |
createdAt | string | Created timestamp (ISO 8601) |
Example:
getMetrics
Get execution metrics for a script. Returns flat metrics structure.
Arguments:
scriptId(string, required): ID of the script
Returns:
object - Returns FLAT structure: { scriptId, totalExecutions, totalCost, avgDuration, successRate, errorRate, lastExecutedAt }
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Script ID |
totalExecutions | number | Total number of executions |
totalCost | number | Total cost in USD |
avgDuration | number | Average duration in ms |
successRate | number | Success rate (0-1) |
errorRate | number | Error rate (0-1) |
lastExecutedAt | string | Last execution timestamp (ISO 8601) or empty |
Example:
createWebhook
Create a webhook endpoint for the script. Returns flat webhook details.
Arguments:
scriptId(string, required): ID of the scriptname(string, required): Name of the webhookenabled(boolean, optional): Whether webhook is enabled (default: true)
Returns:
object - Returns FLAT structure: { scriptId, webhookUrl, webhookSecret, name, enabled }
Response Fields:
| Field | Type | Description |
|---|---|---|
scriptId | string | Script ID |
webhookUrl | string | Webhook URL endpoint |
webhookSecret | string | Webhook secret for verification |
name | string | Webhook name |
enabled | boolean | Whether webhook is enabled |
Example:
createSchedule
Create a cron schedule for the script. Returns flat schedule details.
Arguments:
scriptId(string, required): ID of the scriptname(string, required): Name of the schedulecronExpression(string, required): Cron expression (e.g., "0 9 * * *" for daily at 9am)enabled(boolean, optional): Whether schedule is enabled (default: true)data(object, optional): Data to pass to the script on scheduled execution
Returns:
object - Returns FLAT structure: { scheduleId, scriptId, name, cronExpression, enabled }
Response Fields:
| Field | Type | Description |
|---|---|---|
scheduleId | string | Schedule ID |
scriptId | string | Script ID |
name | string | Schedule name |
cronExpression | string | Cron expression |
enabled | boolean | Whether schedule is enabled |
Example:
getFlowScript
Get the script code for a specific flow. Returns flat flow script structure.
Arguments:
flowId(string, required): ID of the flow to get script code for
Returns:
object - Returns FLAT structure: { code, version, scriptId, scriptName, description, isOwned }
Response Fields:
| Field | Type | Description |
|---|---|---|
code | string | Script source code |
version | number | Active version number |
scriptId | string | Script ID |
scriptName | string | Script name |
description | string | Script description |
isOwned | boolean | Whether user owns the script |
Example:
modifyFlowScript
Modify the script code for a flow. Automatically creates a copy if user does not own the original, deploys to Lambda, and updates the flow. Returns flat modification result.
Arguments:
flowId(string, required): ID of the flow to modifynewCode(string, required): New code to deploycommitMessage(string, optional): Description of changes
Returns:
object - Returns FLAT structure: { copied, scriptId, versionId, version }
Response Fields:
| Field | Type | Description |
|---|---|---|
copied | boolean | Whether a copy was created (user did not own original) |
scriptId | string | Script ID (new if copied, original if owned) |
versionId | string | New version ID |
version | number | New version number |
Example:
lintScript
Validate script code BEFORE creating or deploying. Checks for: 1) Missing async handler wrapper (top-level await errors), 2) Invalid adapter operations. Returns flat validation results with suggestions for fixes. ALWAYS use this before createScript/modifyFlowScript.
Arguments:
code(string, required): The script code to validate
Returns:
object - Returns FLAT structure: { valid, issueCount, issues[], callAdapterCallsCount, mirraSDKCallsCount }. Each issue has: severity, message, line, suggestion.
Response Fields:
| Field | Type | Description |
|---|---|---|
valid | boolean | Whether script is valid |
issueCount | number | Number of issues found |
issues | LintIssue[] | List of lint issues |
issues item fields (LintIssue)
| Field | Type | Description |
|---|---|---|
severity | string | Issue severity (error, warning) |
message | string | Issue description |
line | number | Line number where issue was found |
suggestion | string | Suggested fix |
| callAdapterCallsCount | number | Number of callAdapter calls found |
| mirraSDKCallsCount | number | Number of mirra SDK calls found |
Example: