ApplesauceOS
Read Markdown ↗Download .md

POST /automation/run

Execute an async JavaScript function body and retain its result.

This is a device HTTP route. Set DEVICE_URL to your reachable device URL; connection and examples explain how. Do not append this path to the public MCP URL.

Parameters

ParameterTypeMeaning
sourceJSON stringInline async function body; exactly one of source/path; maximum 256 KiB.
pathJSON stringSaved relative .js file, executed as an async function body.
idJSON stringOptional UUID or 32 hex characters chosen before submission; returned as lowercase 32-character runId.
argsJSON objectOptional; values become immutable strings in args.

Response

JSON {runId,nativeRunId,state,sourcePath}; initial state is submitted.

Example

sh
curl --fail-with-body "$DEVICE_URL/automation/run" \
  -H 'Content-Type: application/json' \
  -d '{"source":"console.log(\"Checking\"); return {foreground:frontMostAppId()};"}'

Notes

Supports return and await. Use /scripts/run for ordinary .cso/.aso projects or repeats. Poll /automation/runs with the same ID after submission, including after a lost response. A retained ID cannot be submitted twice.

Check the HTTP status and any JSON error. HTTP workflows and error handling explain shared limits. All endpoints.