Skip to main content
POST
/
api
/
v1
/
run-js-code
Run JavaScript code
curl --request POST \
  --url https://app.dumplingai.com/api/v1/run-js-code \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "code": "export default async function main() { return '\''hello'\''; }"
}'
{}

Description

This endpoint allows you to run JavaScript code in a secure sandbox environment. The code is executed using a secure code interpreter and returns both stdout and stderr logs.

Endpoint

POST https://app.dumplingai.com/api/v1/run-js-code

Headers

  • Content-Type: application/json
  • Authorization: Bearer <API_KEY> (required)

Request Body

{
  "commands": "string", // Optional. Install NPM packages before code execution e.g. npm install axios
  "code": "string", // Required. The JavaScript code to be executed
  "parseJson": boolean, // Optional. Whether to parse stdout/stderr as JSON
}

Responses

Success (200)

Returns the output logs from the executed JavaScript code.
{
  "logs": {
    "stdout": string[] | any, // Array of stdout messages or parsed JSON
    "stderr": string[] | any  // Array of stderr messages or parsed JSON
  }
}
  • Content-Type: application/json
  • X-RateLimit-Limit: The rate limit for the user.
  • X-RateLimit-Remaining: The remaining number of requests for the user.

Bad Request (400)

Returned if the request is missing required parameters.
{
  "error": "code parameter is required"
}

Internal Server Error (500)

Returned if there’s an error during code execution.
{
  "error": {
    "name": "string",
    "value": "string",
    "traceback": "string"
  }
}

Example Request

curl -X POST https://app.dumplingai.com/api/v1/run-js-code \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "commands": "npm install axios",
  "code": "console.log(JSON.stringify({ hello: \"world\" }));",
  "parseJson": true
}'

Example Response

{
  "logs": {
    "stdout": { "hello": "world" },
    "stderr": []
  }
}

Notes

  • This endpoint uses 5 credits per request.
  • Code execution timeout is set to 10 seconds
  • The code is executed in a secure sandbox environment
  • When parseJson is true, the system will attempt to parse stdout and stderr as JSON
  • You can install NPM packages by using the commands parameter e.g. npm install axios

Rate Limiting

Rate limit headers (X-RateLimit-Limit and X-RateLimit-Remaining) are included in the response to indicate the user’s current rate limit status.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request payload for sandboxed code execution.

code
string
required

Source code to execute inside the sandbox.

commands
string[]

Shell commands to run before executing the code.

parseJson
boolean

Attempt to parse stdout/stderr as JSON arrays.

requestSource
enum<string>

Optional identifier describing where the API request originated.

Available options:
API,
WEB,
MAKE_DOT_COM,
ZAPIER,
N8N,
PLAYGROUND,
DEFAULT_AUTOMATION,
AGENT_PREVIEW,
AGENT_LIVE,
AUTOPILOT,
STUDIO

Response

Execution results returned.

Flexible JSON structure; fields differ per endpoint.

I