AutomatorsDocs
Scenarios

Workspace files

Read scenario inputs and persist downloadable outputs.

A scenario workspace holds uploaded inputs and generated outputs. The runner synchronizes inputs before execution and persists files written to the output directory.

Upload inputs using the scenario's file controls or the API route POST /scenarios/{scenarioId}/files/upload. List files with GET /scenarios/{scenarioId}/files. Chat attachments and scenario files have different contexts; confirm the intended input is attached to the scenario that will run.

Read an input

import csv
import os
from pathlib import Path

input_path = Path(os.environ["DATAMAKER_WORKSPACE_UPLOADS"]) / "customers.csv"
if not input_path.is_file():
    raise FileNotFoundError("Upload customers.csv to this scenario before running")
with input_path.open(newline="", encoding="utf-8") as handle:
    rows = list(csv.DictReader(handle))
print(f"Read {len(rows)} input rows")

Use the actual filename or relative path shown for the upload. A spreadsheet may need a declared engine such as openpyxl; see Python environment.

Write a deliverable

import json
import os
from pathlib import Path

output_dir = Path(os.environ["DATAMAKER_WORKSPACE_OUTPUTS"])
output_dir.mkdir(parents=True, exist_ok=True)
(output_dir / "summary.json").write_text(
    json.dumps({"rows": len(rows)}), encoding="utf-8"
)

After the run, inspect its file results and verify the downloadable artifact. Files written elsewhere may not be persisted. Do not rely on transient working directories surviving a later run.

Manage inputs carefully

Deleting an input can break scenarios that reference it. Keep required fixtures with the workflow and use explicit filenames. Review whether repeated runs overwrite a deliverable in your deployment; use distinct names when you need to preserve individual reports.

Files are not automatically masked because their originating template had sensitive labels. Apply and verify masking before writing a shareable output. For chat-generated downloads, see My data.

On this page