Skip to main content

Getting Started with SmartSuite Script Engine

Create, run, schedule and monitor JavaScript scripts with the Script Management API on Enterprise and Signature.

Written by Jon Darbyshire

Script Engine runs your own JavaScript in a managed environment, with no servers to run. You create scripts, run them on demand or on a schedule, and read their run history, all through the Script Management API.

Use it for data syncs, bulk record updates, calls to other systems and recurring jobs.

Example: a compliance team needs control evidence pulled from a cloud provider every night. A script named nightly-evidence-sync calls the provider's API, writes the results into the Evidence table and runs on a daily schedule. Each morning, its run history shows whether the pull worked.

Plan Availability

Enterprise and Signature.

Permissions

Administrators.

Platform

API

Related Reading


What Script Engine is for

Script Engine fits work that needs more control than one automation step gives:

  • Batched imports.

  • Syncs with other systems through their APIs.

  • Scheduled reconciliation jobs.

  • Processing driven by webhooks.

  • Bulk record updates.

  • Background jobs that check their own time and progress.

The API is built around five resources:

  • Scripts hold the code and its settings.

  • Executions run a script now.

  • Runs record each execution.

  • Schedules are set on the script itself.

  • Runtimes list the supported environments and their installed libraries.

Workspace Administrators can also create and monitor scripts in the app. See Managing Scripts in Script Engine.


Before you begin

Every request to the Script Management API carries two headers:

Authorization: ApiKey YOUR_API_KEY
Account-Id: YOUR_WORKSPACE_ID

Scripts belong to one workspace. The Account-Id header keeps every request inside that workspace.

Every endpoint starts with https://app.smartsuite.com/v1/scripting/. The supported runtime is nodejs20.

The full reference is the Script Engine API documentation.


Step 1: Write the handler

Your script exports a handler function whose name matches the script's entry_point. Both of these export styles work:

exports.handler = async (payload, context) => {
return {
message: "hello", input: payload
};
};

module.exports.handler = async (payload, context) => {
return {
message: "hello",
input: payload
};
};

If the entry point is not exported, validation rejects the script.

The handler receives two arguments:

  • payload: the JSON object sent in the execute request.

  • context: details about the run and helper methods.

The context includes:

  • context.secrets

  • context.runId

  • context.workspaceId

  • context.scriptUuid

  • context.getRemainingTimeMs()

  • context.isTimingOut()

  • context.writeArtifact(name, data)

With these, a script can read its secrets, check how much time is left, and save files to inspect later. A minimal handler:

exports.handler = async (payload, context) => {
const name = payload.name || "World";
return {
message: `Hello, ${name}!`,
runId: context.runId,
workspaceId: context.workspaceId
};
};

Step 2: Encode and hash the script

When you create or update a script, the API expects:

  • script_content: the script source, base64-encoded.

  • script_hash: the SHA-256 hash of the raw source.

In Bash:

SCRIPT_RAW='exports.handler = async (payload) => { return { message: "hello" }; };'
CONTENT=$(echo -n "$SCRIPT_RAW" | base64)
HASH=$(echo -n "$SCRIPT_RAW" | shasum -a 256 | cut -d' ' -f1)

Warning: Hash the raw JavaScript, not the base64 value. The API decodes the base64 first, then checks the hash against the decoded source.


Step 3: Create the script

Send POST /scripts to create a script. The main fields are:

Field.

What it holds.

id.

A readable script ID, unique in the workspace.

display_name.

The name people see.

description.

Optional description.

runtime.

nodejs20.

script_content.

The base64-encoded source.

script_hash.

The SHA-256 hash of the raw source.

entry_point.

The handler the script exports.

memory_mb.

128 to 1024. Default 256.

timeout_seconds.

5 to 900. Default 30.

schedule.

Optional preset or cron or rate expression.

secrets.

Key-value map of secrets.

tags.

Optional labels.

A script ID must:

  • Be 3 to 63 characters long.

  • Use only lowercase letters, numbers and hyphens.

  • Start and end with a letter or a number.

  • Match ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$.

For example, nightly-evidence-sync is valid. Nightly_Sync is not.

curl -X POST https://app.smartsuite.com/v1/scripting/scripts \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"id": "my-script",
"display_name": "My First Script",
"description": "Simple test script",
"runtime": "nodejs20",
"script_content": "'$CONTENT'",
"script_hash": "'$HASH'",
"entry_point": "handler",
"memory_mb": 256,
"timeout_seconds": 30
}'

A successful create returns 201 Created with the full script, including its uuid, script_version, status, timestamps and secret references.


Step 4: Give the script its secrets

Many scripts need credentials for other systems. You pass them in the script's secrets object:

{
"secrets": {
"API_KEY": "sk-abc123",
"DB_PASSWORD": "super-secret-password"
}
}

The API stores raw values in AWS Secrets Manager. When you read the script back, secrets holds references that start with secret://, never the values.

Your handler reads the values from context.secrets:

const axios = require('axios');
exports.handler = async (payload, context) => {
const apiKey = context.secrets.API_KEY;
if (!apiKey) {
throw new Error("Missing required secret: API_KEY");
}
const response = await axios.get("https://api.example.com/data", {
headers: {
Authorization: `Bearer ${apiKey}`
}
});
return {
count: Array.isArray(response.data) ? response.data.length : null
};
};

When you update a script, include every secret you want to keep. Keys you leave out are removed. To change one secret, send the existing secret:// references for the others:

{
"secrets": {
"SMARTSUITE_API_KEY": "secret://aws-secrets-manager/scripts/ws-123/my-script",
"EXTERNAL_API_KEY": "new-rotated-api-key",
"TARGET_TABLE_ID": "secret://aws-secrets-manager/scripts/ws-123/my-script"
}
}

To remove all secrets, send an empty object:

{
"secrets": {}
}

Good habits for secrets:

  • Never put credentials in the script source.

  • Check required secrets at the start of the handler.

  • Never print a secret in logs or return it from the script.

  • Keep separate secrets for test and production.


Step 5: Run the script

Send POST /scripts/{scriptId}/execute to run a script now. The request takes:

  • mode: sync or async.

  • payload: any JSON object, passed to the handler.

  • trigger_type: http, scheduled or manual.

  • caller_ip: optional caller IP address.

Run and wait: sync

Use sync when you need the result right away, for example in a SmartSuite automation that uses the script's return value in a later step.

curl -X POST https://app.smartsuite.com/v1/scripting/scripts/my-script/execute \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"mode": "sync",
"trigger_type": "manual",
"caller_ip": "127.0.0.1",
"payload": {
"name": "SmartSuite"
}
}'

A sync run returns 200 with run_id, status, result, duration, and error if the run did not succeed.

Run in the background: async

Use async for longer jobs. The API returns 202 Accepted at once with a run_id and the status pending. Then check the run until it finishes.

curl -X POST https://app.smartsuite.com/v1/scripting/scripts/my-script/execute \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"mode": "async",
"trigger_type": "manual",
"caller_ip": "127.0.0.1",
"payload": {
"batchSize": 50
}
}'

Here is the response.

{
"run_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending"
}

Step 6: Schedule the script

The schedule lives on the script. Set it in the create request, or change it with PUT /scripts/{scriptId}.

Accepted schedules:

  • The presets hourly, daily and weekly.

  • EventBridge expressions such as rate(6 hours) or cron(0 12 * * ? *).

Create a scheduled script:

curl -X POST https://app.smartsuite.com/v1/scripting/scripts \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"id": "daily-sync",
"display_name": "Daily Sync",
"runtime": "nodejs20",
"script_content": "'$CONTENT'",
"script_hash": "'$HASH'",
"schedule": "daily",
"timeout_seconds": 600,
"memory_mb": 512
}'

Change the schedule:

{
"schedule": "rate(6 hours)"
}

Remove the schedule by sending an empty string:

{
"schedule": ""
}

Note: Leaving the schedule field out of an update keeps the schedule as it is. Only an empty string removes it.


Step 7: Check runs and logs

Each run records how it started in trigger_type: http, scheduled or manual.

  • List runs: GET /scripts/{scriptId}/runs lists a script's runs, in pages.

  • Get a run: GET /scripts/{scriptId}/runs/{runId} returns one run. Use it to follow an async run.

  • Get run logs: GET /scripts/{scriptId}/runs/{runId}/logs returns a link to the run's log file.

Each run carries fields such as id, trigger_type, execution_mode, status, script_version, started_at, completed_at, duration_ms, error, result_summary, logs_s3_key and output_s3_key.

The log link expires after 15 minutes. The endpoint returns 404 when a run has no logs.

curl https://app.smartsuite.com/v1/scripting/scripts/my-script/runs/550e8400-e29b-41d4-a716-446655440000/logs \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID"

Here is the response.

{
"url": "https://presigned-s3-url.example.com/..."
}

Managing scripts

  • List scripts: GET /scripts lists scripts, 20 per page by default and up to 100, with a cursor for the next page.

  • Get a script: GET /scripts/{scriptId} returns a script's settings, version, runtime, schedule, tags and secret references. Raw secret values are never returned.

  • Update a script: PUT /scripts/{scriptId} updates only the fields you send: the code, timeout, memory, secrets, schedule, tags or description.

  • Delete a script: DELETE /scripts/{scriptId} deletes a script and returns 204.


Runtimes and libraries

  • List runtimes: GET /runtimes lists the runtimes and their libraries.

  • List libraries: GET /runtimes/{runtime}/libraries lists the libraries of one runtime.

nodejs20 comes with smartsuite-sdk, axios, node-fetch, lodash, dayjs and uuid.

curl https://app.smartsuite.com/v1/scripting/runtimes/nodejs20/libraries \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Account-Id: YOUR_WORKSPACE_ID"

Examples

Three scripts show the common patterns: a first deployment, a call to another service, and a batched import.

Hello World

The simplest script, and a good first deployment:

exports.handler = async (payload) => {
const name = payload.name || "World";
return {
message: `Hello, ${name}!`,
timestamp: new Date().toISOString()
};
};

Calling another service with a secret

A script that calls an outside API with a key from its secrets:

const axios = require('axios');
exports.handler = async (payload, context) => {
const apiKey = context.secrets.WEATHER_API_KEY;
if (!apiKey) {
return { error: "WEATHER_API_KEY secret not configured" };
}
const city = payload.city || "New York";
const url = `https://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${encodeURIComponent(city)}`;
const response = await axios.get(url);
return {
city: response.data.location.name,
temp_f: response.data.current.temp_f,
condition: response.data.current.condition.text
};
};

Batched outbound import

This script fetches rows from a source API, shapes them, splits them into batches of 25 and posts each batch to a destination. It stops early and reports progress when time runs short.

const SOURCE_URL = "https://jsonplaceholder.typicode.com/posts?_limit=50";
const DESTINATION_URL = "https://httpbin.org/post";
const MAX_BULK = 25;
const ACCOUNT_ID = "spyv9knb"; // Sample 8-character Account-Id
function safeParseJson(text) {
try {
return JSON.parse(text);
} catch {
return text;
}
}
function chunkArray(items, size) {
const chunks = [];
for (let i = 0; i < items.length; i += size) {
chunks.push(items.slice(i, i + size));
}
return chunks;
}
async function fetchSourceItems() {
const response = await fetch(SOURCE_URL, {
method: "GET",
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`Source fetch failed with status ${response.status}: ${errorText || "No response body"}`
);
}
const posts = await response.json();
return posts.map((post, index) => ({
title: String(post.title || "").slice(0, 120) || `Post ${index + 1}`,
body: post.body || "",
}));
}
async function postBatch(items, token) {
const response = await fetch(DESTINATION_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Token ${token}`,
"Account-Id": ACCOUNT_ID,
},
body: JSON.stringify({ items }),
});
const responseText = await response.text();
const parsedResponse = safeParseJson(responseText);
return {
ok: response.ok,
status: response.status,
itemCount: items.length,
response: parsedResponse,
};
}
exports.handler = async (payload, context) => {
const token = context?.secrets?.DESTINATION_TOKEN;
if (!token) {
throw new Error(
"Missing required secret: DESTINATION_TOKEN"
);
}
const maxBulk =
Number.isInteger(payload?.maxBulk) && payload.maxBulk > 0
? payload.maxBulk
: MAX_BULK;
const items = await fetchSourceItems();
const batches = chunkArray(items, maxBulk);
const results = [];
let successCount = 0;
let failureCount = 0;
for (let i = 0; i < batches.length; i++) {
const batchNumber = i + 1;
const batch = batches[i];
const result = await postBatch(batch, token);
results.push({
batchNumber,
...result,
});
if (result.ok) {
successCount++;
} else {
failureCount++;
}
if (context?.isTimingOut?.()) {
return {
partial: true,
message: "Execution stopped early because the script is approaching timeout.",
totalItems: items.length,
processedBatches: results.length,
remainingBatches: batches.length - results.length,
successfulBatches: successCount,
failedBatches: failureCount,
results,
};
}
}
return {
partial: false,
totalItems: items.length,
batchSize: maxBulk,
totalBatches: batches.length,
successfulBatches: successCount,
failedBatches: failureCount,
results,
};
};

In the evidence example, the same pattern pushes new evidence records to an auditor's system in batches.


Size and resource rules

  • The raw script can be up to 5 MB. Base64 adds size, so keep scripts under about 4 MB.

  • memory_mb runs from 128 to 1024.

  • timeout_seconds runs from 5 to 900.

Validation rejects these patterns:

  • eval()

  • new Function()

  • require('child_process')

  • require('fs')

  • require('net')

  • process.exit()

  • VM and process-control modules, and prototype-chain escape patterns.


Response codes to expect

Problems come back in one envelope:

{
"error": {
"code": "VALIDATION_FAILED",
"message": "description of what went wrong",
"details": []
}
}

Code.

When it happens.

400 VALIDATION_FAILED.

The request or the script did not pass validation.

404 NOT_FOUND.

The script or run does not exist.

409 CONFLICT.

A script with that ID already exists.

422 BUSINESS_RULE_VIOLATION.

For example, running a script that is not active.

503 WORKSPACE_NOT_READY.

The workspace runtime is not ready yet.


Frequently asked questions

Which plans include Script Engine?

Enterprise and Signature. Administrators create and manage scripts.

Which languages can I use?

JavaScript, on the nodejs20 runtime.

How long can a script run?

Up to 900 seconds, set in timeout_seconds. The default is 30 seconds.

How do I run a script every night?

Set schedule to daily, or to a cron expression, in the create or update request.

Can I see a script's output after it runs?

Yes. List its runs with GET /scripts/{scriptId}/runs, then open the run or download its log. The log link lasts 15 minutes.

Need more help? Ask the SmartSuite Community, where builders, administrators and the SmartSuite team answer questions about building on SmartSuite. For your account, billing or data, select the chat button in the lower-right corner of SmartSuite to reach support.

Last verified 1 Nov 2026.

Did this answer your question?