# Files

> Give a script files to work on, and get back the files it saves.

A script can take files and save files. The monthly report on this page takes an optional CSV file of manual adjustments and saves last month’s revenue as a CSV file for Finance. The script reads and writes ordinary files on disk, so it works the way it does on your laptop.

A run has two folders for files. `/inputs` holds the files given to the run, and `/saved` holds the files it saves for you. Each file’s `origin` says which of the two it came from: `input` or `saved`.

## Mark an input as a file

In `reminix.json`, give the input `"format": "file"`. Add `"contentMediaType"` when only one type makes sense:

```json
{
  "slug": "monthly-report",
  "name": "Monthly report",
  "command": "python report.py [--month {month}] [--adjustments {adjustments}]",
  "inputSchema": {
    "type": "object",
    "properties": {
      "month": { "type": "string", "title": "Month" },
      "adjustments": {
        "type": "string",
        "title": "Manual adjustments",
        "format": "file",
        "contentMediaType": "text/csv"
      }
    }
  }
}
```

For several files in one input, use a list: `{ "type": "array", "items": { "type": "string", "format": "file" } }`.

## Ship a sample file

Put a small sample in your script’s folder and name it in the input’s `examples`, as a path inside the folder:

```json
"adjustments": {
  "type": "string",
  "format": "file",
  "contentMediaType": "text/csv",
  "examples": ["samples/adjustments.csv"]
}
```

The run form then offers **Use the sample file** next to the file picker, so anyone can try the script without a file of their own. When you upload the version, Reminix checks that the sample is in the folder, and refuses the version if it isn’t. Reminix offers only the files you name this way, and the rest of your folder stays private. A sample can be up to 5 MB.

## Read the file in your script

Before the command starts, Reminix copies each file to `/inputs/<input>/<file name>`. It puts the file’s path where the command names the input. With the `reminix.json` above, the month `2026-09` and a file called `adjustments.csv`, Reminix runs:

```sh
python report.py --month 2026-09 --adjustments /inputs/adjustments/adjustments.csv
```

The path is also in the environment variable `$REMINIX_INPUT_ADJUSTMENTS`. The JSON inputs give the file’s details:

```json
{
  "month": "2026-09",
  "adjustments": {
    "path": "/inputs/adjustments/adjustments.csv",
    "name": "adjustments.csv",
    "mediaType": "text/csv",
    "sizeBytes": 2048
  }
}
```

A list of files becomes several arguments in the command, and its environment variable holds a list of paths.

## Save files

When the command ends, Reminix keeps anything your script wrote to `/saved`, whether the run succeeded or failed. These are the run’s **saved files**. The folder’s path is also in `$REMINIX_SAVED`. A folder inside `/saved` becomes part of the file’s name, like `reports/revenue-2026-09.csv`.

```python
import argparse, csv, datetime, json, os

last_month = (datetime.date.today().replace(day=1) - datetime.timedelta(days=1)).strftime("%Y-%m")
parser = argparse.ArgumentParser()
parser.add_argument("--month", default=last_month)
parser.add_argument("--adjustments")  # a path in /inputs, or None
args = parser.parse_args()
month = args.month

rows = revenue_by_day(month, args.adjustments)  # your query, reading api.stripe.com
path = os.path.join(os.environ["REMINIX_SAVED"], f"revenue-{month}.csv")
with open(path, "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["day", "charges", "refunds", "net"])
    writer.writerows(rows)
print(json.dumps({"month": month, "days": len(rows)}))
```

Standard output is still the run’s output. Write large results to a file in `/saved` rather than printing them, because Reminix doesn’t keep standard output over 1 MB.

## Give a run a file in the app

On the script’s page, a file input is a file picker. Pick a file, or select **Use the sample file** when the script ships one. Then select **Run**, and the app uploads the file and starts the run. The run’s page lists the files given to it and the files it saved, each as a download.

## Find a file later

The **Files** page, beside Scripts and Runs in the app, lists the files runs saved, newest first. For each file, it shows:

* its name and its script
* when its run saved it, and who started that run
* its size
* when Reminix will delete it

Search by name, switch to **Given to runs** for the files given to runs, or narrow the list to one script. A script’s page shows its latest files too, with a **See all files** link. Every file links to the run that made it.

In the CLI, use `reminix files list`. In your code, use `reminix.files.list()`. Each file comes with a download link that works for an hour. See [List files](/docs/reference/files/#list-files).

## Give a run a file

Pass the file as the input. The SDKs and the CLI upload it first and give the run its id. To get back what the run saves, read the files on the finished run, or use `--out` in the CLI:

* TypeScript

  ```ts
  import { readFile } from "node:fs/promises";
  import { createClient } from "@reminix/sdk";

  const reminix = createClient();

  const run = await reminix.run("monthly-report", {
    month: "2026-09",
    adjustments: {
      name: "adjustments.csv",
      mediaType: "text/csv",
      data: await readFile("adjustments.csv"),
    },
  });
  console.log(run.files);
  ```

* Python

  ```python
  from pathlib import Path

  from reminix import Reminix

  reminix = Reminix()

  run = reminix.run(
      "monthly-report",
      {"month": "2026-09", "adjustments": Path("adjustments.csv")},
  )
  print(run.files)
  ```

* CLI

  ```bash
  reminix run monthly-report \
    -f month=2026-09 \
    --file adjustments=./adjustments.csv \
    --out ./reports
  ```

  Repeat `--file` for an input that takes several files. Without `--out`, the command prints each saved file’s name and download link.

* curl

  Upload the file first, then pass its id as the input. If you send no `Content-Type`, or `application/octet-stream`, Reminix takes the media type from the file’s name:

  ```bash
  curl -X POST "https://api.reminix.com/v1/files?name=adjustments.csv" \
    -H "Authorization: Bearer $REMINIX_API_KEY" \
    -H "Content-Type: text/csv" \
    --data-binary @adjustments.csv
  # → { "id": "file_36d59242-1144-4fcb-851f-20f4c444d538", "name": "adjustments.csv", … }

  curl -X POST https://api.reminix.com/v1/scripts/monthly-report/runs \
    -H "Authorization: Bearer $REMINIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "inputs": { "month": "2026-09", "adjustments": "file_36d59242-1144-4fcb-851f-20f4c444d538" } }'
  ```

Only one run can use each upload. To give a second run the same file, upload it again. You can also pass the id of a file an earlier run saved, so one script’s saved file can be the next script’s input.

## Get the files a run saved

A finished run lists its files: the ones given to it (`"origin": "input"`) and the ones it saved (`"origin": "saved"`). Each has a `downloadUrl` that works for an hour without a key. On the run’s page in the app, each file is a download. In the CLI, `reminix files download <file-id>` saves one. In your code, `reminix.files.content(fileId)` returns its bytes. See [Get a file’s content](/docs/reference/files/#get-a-files-content). Reminix always sends a file as a download, never as a page to view.

## Agents pass a link

An agent can’t carry a file inside a tool call, so a file input also takes an `https` link. Reminix downloads the file when the run starts and gives it to the script like an upload. Reminix refuses links to private networks. The run’s result lists the files it saved, and the agent can share each file’s download link.

## Schedules and triggers

A schedule runs with no one there to give it a file, so a script that needs a file for every run can’t run on a schedule. On a scheduled run, an optional file input stays empty. For example, the monthly report’s schedule runs on the 1st without adjustments and still saves its CSV file.

## How long Reminix keeps files

If no run uses an upload within a day, Reminix deletes it. Your plan sets the other limits:

* how many days Reminix keeps a run’s files, given and saved
* how large each file can be
* how many files one run can save
* how much space the workspace’s files can take up in all

If a run saves more files than its plan allows, or a file that’s too large, Reminix leaves those files out and writes a line to the run’s log. The numbers are on [Plan limits](/docs/plans/).
