Steps
A routine runs its steps in order. Inputs can come from the trigger, stored scheduled values, or previous step outputs. Choose supported actions from the action catalog; see the step kinds for an overview. A device script (scripts.run) is distinct from an uploaded Serverless Function (functions.run). Loops can repeat steps, but nested loops and task steps inside loops are rejected. Nested steps cannot currently be edited in the routine builder.
Save files (files.upload)
Use the Upload file step (files.upload) to save content produced by earlier steps to
Mobilerun storage: a function’s result, a report, or bytes from a screenshot or app capture.
It does not upload to Google Drive or OneDrive, and it needs no phone of its own.
Pass the actual content, not a local path or a download URL. Empty content is rejected; the
encoded file must be at most 50 MiB. A
.json file must contain one complete JSON value, without
prose or Markdown fences.
This routine document runs an existing function and saves its result as
JSON. Replace the function ID with a ready function you own; adapt input to its schema.
YAML
fileId, filename, mimeType, sizeBytes, and zone: workflow in its output.
To keep a durable routine file, choose Delivery → Mobilerun storage and supply a folder,
as above. Live runs copy their files.upload outputs into that folder; this copy can finish
after the run’s steps. A successful upload step does not by itself confirm that the saved copy is ready.
Files go directly into the configured folder, with the step’s filename; no execution subfolder
is added. Folder templates are resolved once per run. Here, meta.today groups reports by date;
files retain their own IDs and executionId, even when names repeat. Recordings and screenshots
selected in Delivery can be saved there too, without an extra upload step.
Saved files use your storage allowance. They stay until you delete them or
their routine; there is no fixed expiry for ready saved copies. See
Find and download files to retrieve or remove them.
Serverless Functions
Source on GitHub A Serverless Function is saved, versioned Python code with typed inputs and returns, executed in a fresh sandbox. Use it for repeatable code, a task for an agent instruction, or a sandbox for an interactive session. Create it in the dashboard or API, run it directly or in a routine, then read its result and logs.How it works
- Write a Python file and declare any network hosts, credentials, and scopes in its manifest.
- Upload it. Inspection checks the code and discovers its input and output schemas; only a
readyversion can run. - Run directly, attach the function to a routine, or ask the agent to use it. Each run executes a version in an isolated sandbox.
- Read the result and logs. To change the code or manifest, upload a new immutable version.
Write a function
Keep the code in one.py file: adjacent helper modules are not uploaded. Save the greeting example as hello.py; the requests below pass {"name":"Ada"} and receive a greeting in the result.
Use exactly one bare @script entry point, with a Pydantic input model and a supported return annotation: a Pydantic output model, optional output, None, or a dataset. See Writing Serverless Functions for the Python format, device access, and package availability.
The optional upload manifest contains hosts (exact allowed hostnames), credentials (objects with packageName and name), and scopes (permission names). These default to empty lists; the greeting needs none. Supply the manifest as JSON alongside source, rather than as a second code file. Keep secrets out of source, inputs, returns, and logs.
Create it
1
Open Functions
In Routines, choose Manage functions to open the Serverless Functions tab.
2
Upload your code
Choose Upload function and select your
.py file.3
Check the contract
Select the function to inspect Code, Inputs & returns, and Runs. Wait for its version to be ready before running it.
Upload through the API
All requests use your API key. TypeScript and Python examples require SDK 6.3.1 or later. Through the API, upload source as JSON, with a requiredIdempotency-Key. A new function returns 201 with its stable ID in data.id and its first version in data.latestVersion.
pending_inspection, then becomes ready or rejected. Poll GET /v1/compute/functions/{functionId}/versions/{version} and run only a ready version. For rejection details, inspect inspectError; fix the source and upload a new version.
For a source-only check, send source and optional manifest to POST /v1/compute/functions/validations?waitS=25 with an Idempotency-Key header. If the response is still pending, poll GET /v1/compute/functions/validations/{validationId}. Validation reports errors and warnings without saving a function; it does not prove success against a live app.
Run it
Open the function and choose Run to enter its input in Run function. In the API, choose a version or omit it for the latest ready version.waitS controls how long the HTTP request waits, independently of timeoutS.
200 response contains a finished run; 202 means it is still running. Poll GET /v1/compute/runs/{runId}?waitS=30 for its result, or request cancellation with POST /v1/compute/runs/{runId}/cancel. A completed run’s outcome tells you whether it succeeded, partially succeeded, or failed; inspect errorCode on failure.
Read results and logs
List runs withGET /v1/compute/functions/{functionId}/runs, or GET /v1/compute/runs?functionId={functionId}. List items omit input, result, stdout, and stderr; read an individual run for those fields.
url, expiresAt, and sizeBytes, rather than file bytes. Download from url; request a new link when it expires. waitLogs() (Python wait_logs()) waits until the log is ready. For cURL, the log link can return 404 with logs_not_available for a few seconds after the run ends.
Use it in a routine
Add a Serverless Function as one of the ordered steps in a routine. Its trigger decides when the steps run; app, device, and platform event triggers are Soon. Choose the function and its input as a routine step; use the newest ready version or pin a version number. Follow Working with routines for setup, verification, and execution results.Versions
A function has a stable ID; each uploaded version has immutable source and manifest. In the dashboard, choose Edit, then Save as new version. Through the API, sendsource and optional manifest to POST /v1/compute/functions/{functionId}/versions with an Idempotency-Key header. Wait for the new version to become ready.
Read version metadata with GET /v1/compute/functions/{functionId}/versions/{version}. Read code with GET /v1/compute/functions/{functionId}/source?version=1; omit version for the latest ready version.
Limits
Function steps in routines have a separate timeout: see function step limits. External requests must use HTTPS on the default port and match an allowed hostname exactly; redirect targets are not followed automatically. Mobilerun API access uses platform-controlled credentials and permissions.