Mirra
IntegrationsOther

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 script
  • description (string, optional): Description of what the script does
  • runtime (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:

FieldTypeDescription
idstringCreated script ID
namestringScript name
descriptionstringScript description
runtimestringLambda runtime (e.g., nodejs18)
timeoutnumberTimeout in seconds
memorynumberMemory in MB
activeVersionnumberActive version number
isPublishedbooleanWhether published
isPrivatebooleanWhether private
statusstringScript status
deploymentStatusstringDeployment status
apiKeystringAPI key for script execution (only returned on creation)
installationIdstringAuto-created installation ID
createdAtstringCreated timestamp (ISO 8601)

Example:

const result = await mirra.scripts.createScript({
  name: "example",
  code: "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:

FieldTypeDescription
deletedbooleanWhether deletion succeeded
scriptIdstringDeleted script ID
hardDeletedbooleanWhether script was permanently deleted
installationsRemovednumberNumber of installations removed
preservedInstallationsnumberNumber of installations preserved (soft delete)

Example:

const result = await mirra.scripts.deleteScript({
  scriptId: "abc123"
});

createVersion

Create a new version of an existing script. Returns flat version details.

Arguments:

  • scriptId (string, required): ID of the script
  • code (string, required): Updated code for the new version
  • commitMessage (string, optional): Description of changes in this version

Returns:

object - Returns FLAT structure: { id, scriptId, version, isActive, commitMessage, codeHash, createdAt, deployedAt }

Response Fields:

FieldTypeDescription
idstringVersion document ID
scriptIdstringParent script ID
versionnumberVersion number
isActivebooleanWhether this version is active
commitMessagestringCommit message for this version
codeHashstringHash of the code
createdAtstringCreated timestamp (ISO 8601)
deployedAtstringDeployed timestamp (ISO 8601) or empty

Example:

const result = await mirra.scripts.createVersion({
  scriptId: "abc123",
  code: "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:

FieldTypeDescription
countnumberNumber of versions
versionsScriptVersion[]List of script versions
versions item fields (ScriptVersion)
FieldTypeDescription
idstringVersion document ID
scriptIdstringParent script ID
versionnumberVersion number
isActivebooleanWhether this version is active
commitMessagestringCommit message for this version
codeHashstringHash of the code
createdAtstringCreated timestamp (ISO 8601)
deployedAtstringDeployed timestamp (ISO 8601) or empty

Example:

const result = await mirra.scripts.listVersions({
  scriptId: "abc123"
});

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:

FieldTypeDescription
scriptIdstringDeployed script ID
versionnumberDeployed version number
lambdaFunctionNamestringAWS Lambda function name
lambdaArnstringAWS Lambda ARN
deployedAtstringDeployment timestamp (ISO 8601)

Example:

const result = await mirra.scripts.deployScript({
  scriptId: "abc123"
});

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 script
  • trigger (object, optional): Trigger information (type, source, event)

Returns:

object - Returns FLAT structure: { executionId, scriptId, status, output, duration, logs[], error, createdAt }

Response Fields:

FieldTypeDescription
executionIdstringUnique execution ID
scriptIdstringExecuted script ID
statusstringExecution status
outputanyScript output data
durationnumberExecution duration in milliseconds
logsstring[]Execution logs
errorstringError message (empty if no error)
createdAtstringExecution timestamp (ISO 8601)

Example:

const result = await mirra.scripts.executeScript({
  scriptId: "abc123"
});

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:

FieldTypeDescription
idstringScript ID
namestringScript name
descriptionstringScript description
runtimestringLambda runtime
timeoutnumberTimeout in seconds
memorynumberMemory in MB
activeVersionnumberActive version number
isPublishedbooleanWhether published
isPrivatebooleanWhether private
statusstringScript status
deploymentStatusstringDeployment status
lambdaFunctionNamestringLambda function name
lambdaArnstringLambda ARN
totalExecutionsnumberTotal executions
totalCostnumberTotal cost in USD
avgDurationnumberAverage duration in ms
errorRatenumberError rate (0-1)
createdAtstringCreated timestamp (ISO 8601)
deployedAtstringDeployed timestamp (ISO 8601) or empty
publishedAtstringPublished timestamp (ISO 8601) or empty
lastExecutedAtstringLast execution timestamp (ISO 8601) or empty

Example:

const result = await mirra.scripts.getScript({
  scriptId: "abc123"
});

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:

FieldTypeDescription
countnumberNumber of scripts
scriptsScriptSummary[]List of scripts
scripts item fields (ScriptSummary)
FieldTypeDescription
idstringUnique script ID
namestringScript name
descriptionstringScript description
activeVersionnumberCurrently active version number
isPublishedbooleanWhether script is published to marketplace
statusstringScript status (draft, published, archived)
deploymentStatusstringDeployment status (pending, deploying, deployed, failed)
totalExecutionsnumberTotal number of executions
createdAtstringCreated timestamp (ISO 8601)

Example:

const result = await mirra.scripts.listScripts();

getExecutions

Get execution history for a script. Returns flat execution summaries.

Arguments:

  • scriptId (string, required): ID of the script
  • status (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:

FieldTypeDescription
scriptIdstringScript ID
countnumberNumber of executions
executionsScriptExecutionSummary[]List of executions
executions item fields (ScriptExecutionSummary)
FieldTypeDescription
executionIdstringUnique execution ID
scriptIdstringScript that was executed
statusstringExecution status (running, completed, failed)
durationnumberExecution duration in milliseconds
createdAtstringExecution timestamp (ISO 8601)
hasErrorbooleanWhether execution had an error

Example:

const result = await mirra.scripts.getExecutions({
  scriptId: "abc123"
});

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:

FieldTypeDescription
executionIdstringExecution ID
scriptIdstringScript ID
statusstringExecution status
outputanyScript output
durationnumberDuration in milliseconds
logsstring[]Execution logs
errorstringError message (empty if no error)
createdAtstringExecution timestamp (ISO 8601)

Example:

const result = await mirra.scripts.getExecution({
  executionId: "abc123"
});

publishScript

Publish a script to the marketplace. Returns flat publish confirmation.

Arguments:

  • scriptId (string, required): ID of the script to publish
  • pricing (object, optional): Pricing configuration for the marketplace

Returns:

object - Returns FLAT structure: { scriptId, isPublished, status, publishedAt }

Response Fields:

FieldTypeDescription
scriptIdstringPublished script ID
isPublishedbooleanPublication status (true)
statusstringScript status
publishedAtstringPublish timestamp (ISO 8601)

Example:

const result = await mirra.scripts.publishScript({
  scriptId: "abc123"
});

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:

FieldTypeDescription
scriptIdstringUnpublished script ID
unpublishedbooleanWhether unpublish succeeded

Example:

const result = await mirra.scripts.unpublishScript({
  scriptId: "abc123"
});

listMarketplaceScripts

Search and list published scripts in the marketplace. Returns flat script summaries with pagination.

Arguments:

  • name (string, optional): Exact match on script name
  • system (boolean, optional): Filter by system scripts (scope="system") when true, user scripts when false
  • search (string, optional): Text search on name and description
  • tags (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 true
  • minRating (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:

FieldTypeDescription
totalnumberTotal number of matching scripts
limitnumberPage size limit
offsetnumberCurrent offset
scriptsScriptSummary[]List of marketplace scripts
scripts item fields (ScriptSummary)
FieldTypeDescription
idstringUnique script ID
namestringScript name
descriptionstringScript description
activeVersionnumberCurrently active version number
isPublishedbooleanWhether script is published to marketplace
statusstringScript status (draft, published, archived)
deploymentStatusstringDeployment status (pending, deploying, deployed, failed)
totalExecutionsnumberTotal number of executions
createdAtstringCreated timestamp (ISO 8601)

Example:

const result = await mirra.scripts.listMarketplaceScripts({});

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:

FieldTypeDescription
scriptIdstringScript ID
totalExecutionsnumberTotal number of executions
totalCostnumberTotal cost in USD
avgDurationnumberAverage duration in ms
successRatenumberSuccess rate (0-1)
errorRatenumberError rate (0-1)
lastExecutedAtstringLast execution timestamp (ISO 8601) or empty

Example:

const result = await mirra.scripts.getMetrics({
  scriptId: "abc123"
});

createWebhook

Create a webhook endpoint for the script. Returns flat webhook details.

Arguments:

  • scriptId (string, required): ID of the script
  • name (string, required): Name of the webhook
  • enabled (boolean, optional): Whether webhook is enabled (default: true)

Returns:

object - Returns FLAT structure: { scriptId, webhookUrl, webhookSecret, name, enabled }

Response Fields:

FieldTypeDescription
scriptIdstringScript ID
webhookUrlstringWebhook URL endpoint
webhookSecretstringWebhook secret for verification
namestringWebhook name
enabledbooleanWhether webhook is enabled

Example:

const result = await mirra.scripts.createWebhook({
  scriptId: "abc123",
  name: "example"
});

createSchedule

Create a cron schedule for the script. Returns flat schedule details.

Arguments:

  • scriptId (string, required): ID of the script
  • name (string, required): Name of the schedule
  • cronExpression (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:

FieldTypeDescription
scheduleIdstringSchedule ID
scriptIdstringScript ID
namestringSchedule name
cronExpressionstringCron expression
enabledbooleanWhether schedule is enabled

Example:

const result = await mirra.scripts.createSchedule({
  scriptId: "abc123",
  name: "example",
  cronExpression: "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:

FieldTypeDescription
codestringScript source code
versionnumberActive version number
scriptIdstringScript ID
scriptNamestringScript name
descriptionstringScript description
isOwnedbooleanWhether user owns the script

Example:

const result = await mirra.scripts.getFlowScript({
  flowId: "abc123"
});

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 modify
  • newCode (string, required): New code to deploy
  • commitMessage (string, optional): Description of changes

Returns:

object - Returns FLAT structure: { copied, scriptId, versionId, version }

Response Fields:

FieldTypeDescription
copiedbooleanWhether a copy was created (user did not own original)
scriptIdstringScript ID (new if copied, original if owned)
versionIdstringNew version ID
versionnumberNew version number

Example:

const result = await mirra.scripts.modifyFlowScript({
  flowId: "abc123",
  newCode: "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:

FieldTypeDescription
validbooleanWhether script is valid
issueCountnumberNumber of issues found
issuesLintIssue[]List of lint issues
issues item fields (LintIssue)
FieldTypeDescription
severitystringIssue severity (error, warning)
messagestringIssue description
linenumberLine number where issue was found
suggestionstringSuggested fix

| callAdapterCallsCount | number | Number of callAdapter calls found | | mirraSDKCallsCount | number | Number of mirra SDK calls found |

Example:

const result = await mirra.scripts.lintScript({
  code: "example"
});

On this page