# Files API

> The files endpoints, each in TypeScript, Python, the CLI and curl.

The files endpoints, each in TypeScript, Python, the CLI and curl.

## Set up

* TypeScript

  ```bash
  npm install @reminix/sdk
  export REMINIX_API_KEY="<your API key>"
  ```

* Python

  ```bash
  pip install reminix
  export REMINIX_API_KEY="<your API key>"
  ```

* CLI

  ```bash
  npm install -g @reminix/cli
  reminix login
  ```

* curl

  ```bash
  export REMINIX_API_KEY="<your API key>"
  ```

To pass the key yourself, use `createClient({ apiKey: key })` in TypeScript or `Reminix(api_key=key)` in Python.

## Upload a file

`POST /v1/files`[ Try it in the API playground (opens in a new tab)](https://api.reminix.com/v1/docs#tag/files/POST/files)

Scope: `runs:write`.

Uploads a file that a run can take as a file input.

* TypeScript

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

  // Uses the REMINIX_API_KEY environment variable.
  const reminix = createClient();
  const file = await reminix.files.upload(await readFile("adjustments.csv"), {
    name: "adjustments.csv",
  });
  console.log(file);
  ```

* Python

  ```python
  from pathlib import Path
  from reminix import Reminix

  # Uses the REMINIX_API_KEY environment variable.
  reminix = Reminix()
  file = reminix.files.upload(
      Path("adjustments.csv").read_bytes(),
      name="adjustments.csv",
  )
  print(file)
  ```

* CLI

  ```bash
  reminix files upload ./adjustments.csv
  ```

* curl

  ```bash
  curl -X POST "https://api.reminix.com/v1/files?name=adjustments.csv" \
    -H "Authorization: Bearer $REMINIX_API_KEY" \
    -H "Content-Type: application/octet-stream" \
    --data-binary @adjustments.csv
  ```

**Returns:**

```json
{
  "id": "file_36d59242-1144-4fcb-851f-20f4c444d538",
  "name": "adjustments.csv",
  "mediaType": "text/csv",
  "sizeBytes": 18432,
  "origin": "input",
  "runId": null,
  "input": null,
  "sha256": null,
  "createdAt": "2026-10-01T09:14:12.000Z",
  "expiresAt": "2026-10-02T09:14:12.000Z",
  "downloadUrl": "https://3c5a….r2.cloudflarestorage.com/files/…?X-Amz-Expires=3600&X-Amz-Signature=…"
}
```

| Field                          | Description      |
| ------------------------------ | ---------------- |
| `name` string, query, required | The file's name. |

More about this endpoint

Send the file’s bytes as the request body, with `Content-Type` and `Content-Length` headers, and its name as `?name=`. Then pass the returned id as the file input’s value (`{ "adjustments": "file_36d59242-1144-4fcb-851f-20f4c444d538" }`). You can give each upload to only one run. If no run uses an upload within a day, Reminix deletes it. Your plan sets the largest file you can upload. Reminix refuses a file over 1,000 MB on every plan.

## List files

`GET /v1/files`[ Try it in the API playground (opens in a new tab)](https://api.reminix.com/v1/docs#tag/files/GET/files)

Scope: `runs:read`.

Lists the files that runs saved, newest first, across the scripts you can see.

* TypeScript

  ```ts
  import { createClient } from "@reminix/sdk";

  // Uses the REMINIX_API_KEY environment variable.
  const reminix = createClient();
  const files = await reminix.files.list();
  console.log(files);
  ```

* Python

  ```python
  from reminix import Reminix

  # Uses the REMINIX_API_KEY environment variable.
  reminix = Reminix()
  files = reminix.files.list()
  print(files)
  ```

* CLI

  ```bash
  reminix files list
  ```

* curl

  ```bash
  curl -X GET "https://api.reminix.com/v1/files" \
    -H "Authorization: Bearer $REMINIX_API_KEY"
  ```

**Returns:**

```json
{
  "items": [
    {
      "id": "file_ab689098-cd54-4061-8322-c3eec1f29745",
      "name": "revenue-2026-09.csv",
      "mediaType": "text/csv",
      "sizeBytes": 52480,
      "origin": "saved",
      "runId": "run_d3c0553c-fa27-400f-8525-7b2985b36444",
      "input": null,
      "sha256": "9f2c4e1a7b3d5f60c8e2a4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f3a5c7e9b1d3f5",
      "createdAt": "2026-10-01T09:14:20.000Z",
      "expiresAt": "2026-10-08T09:14:20.000Z",
      "downloadUrl": "https://3c5a….r2.cloudflarestorage.com/files/…?X-Amz-Expires=3600&X-Amz-Signature=…",
      "script": {
        "slug": "monthly-report",
        "name": "Monthly report"
      },
      "run": {
        "id": "run_d3c0553c-fa27-400f-8525-7b2985b36444",
        "startedAt": "2026-10-01T09:14:15.000Z"
      },
      "startedBy": {
        "userId": "usr_276b6c46-92e7-4d47-89c1-2ada515bc3e4",
        "name": "Ana Lopez",
        "credential": {
          "type": "pat",
          "name": "ci"
        }
      }
    }
  ],
  "nextCursor": null
}
```

| Field                  | Description                                                                                                                |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `limit` number, query  | Items per page, 1–100 (default 25).                                                                                        |
| `cursor` string, query | Opaque token from a previous page's nextCursor.                                                                            |
| `before` string, query | Start from this moment: items older than it, newest first. Ignored with `cursor`, which already says where to go on.       |
| `script` string, query | Only files from this script's runs, by its slug.                                                                           |
| `origin` string, query | Which files to list: `saved` for files runs saved (the default), `input` for files runs took as inputs, or `all` for both. |
| `name` string, query   | Only files whose name contains this text.                                                                                  |

More about this endpoint

A file stays in the list until it expires. Pass `?script=<slug>` for one script’s files. Pass `?origin=input` for the files runs took as inputs, or `?origin=all` for both. Pass `?name=` to match file names. Each file comes with a download link that works for an hour. Pass `?before=` to start from a moment. Paginate with the opaque `nextCursor` token.

## Get a file

`GET /v1/files/{fileId}`[ Try it in the API playground (opens in a new tab)](https://api.reminix.com/v1/docs#tag/files/GET/files/{fileId})

Scope: `runs:read`.

Returns a file’s name, media type and size, the run that took or saved it, and a download link that works for an hour.

* TypeScript

  ```ts
  import { createClient } from "@reminix/sdk";

  // Uses the REMINIX_API_KEY environment variable.
  const reminix = createClient();
  const file = await reminix.files.get("file_36d59242-1144-4fcb-851f-20f4c444d538");
  console.log(file);
  ```

* Python

  ```python
  from reminix import Reminix

  # Uses the REMINIX_API_KEY environment variable.
  reminix = Reminix()
  file = reminix.files.get("file_36d59242-1144-4fcb-851f-20f4c444d538")
  print(file)
  ```

* CLI

  ```bash
  reminix files get file_36d59242-1144-4fcb-851f-20f4c444d538
  ```

* curl

  ```bash
  curl -X GET "https://api.reminix.com/v1/files/file_36d59242-1144-4fcb-851f-20f4c444d538" \
    -H "Authorization: Bearer $REMINIX_API_KEY"
  ```

**Returns:**

```json
{
  "id": "file_36d59242-1144-4fcb-851f-20f4c444d538",
  "name": "adjustments.csv",
  "mediaType": "text/csv",
  "sizeBytes": 18432,
  "origin": "input",
  "runId": null,
  "input": null,
  "sha256": null,
  "createdAt": "2026-10-01T09:14:12.000Z",
  "expiresAt": "2026-10-02T09:14:12.000Z",
  "downloadUrl": "https://3c5a….r2.cloudflarestorage.com/files/…?X-Amz-Expires=3600&X-Amz-Signature=…"
}
```

| Field                           | Description    |
| ------------------------------- | -------------- |
| `fileId` string, path, required | The file's ID. |

More about this endpoint

Anyone who can see a run can read its files. Until a run uses an upload, only the person who uploaded it, a workspace owner or admin, or a workspace API key can read it.

## Get a file’s content

`GET /v1/files/{fileId}/content`[ Try it in the API playground (opens in a new tab)](https://api.reminix.com/v1/docs#tag/files/GET/files/{fileId}/content)

Scope: `runs:read`.

Returns the file’s bytes as a download.

* TypeScript

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

  // Uses the REMINIX_API_KEY environment variable.
  const reminix = createClient();
  const file = await reminix.files.content("file_36d59242-1144-4fcb-851f-20f4c444d538");
  await writeFile("report.csv", Buffer.from(await file.arrayBuffer()));
  ```

* Python

  ```python
  from pathlib import Path
  from reminix import Reminix

  # Uses the REMINIX_API_KEY environment variable.
  reminix = Reminix()
  Path("report.csv").write_bytes(reminix.files.content("file_36d59242-1144-4fcb-851f-20f4c444d538"))
  ```

* CLI

  ```bash
  reminix files download \
    file_36d59242-1144-4fcb-851f-20f4c444d538 \
    --out report.csv
  ```

* curl

  ```bash
  curl -X GET "https://api.reminix.com/v1/files/file_36d59242-1144-4fcb-851f-20f4c444d538/content" \
    -H "Authorization: Bearer $REMINIX_API_KEY" \
    -o report.csv
  ```

**Returns** the file itself (`application/octet-stream`), which the example saves to disk.

| Field                           | Description    |
| ------------------------------- | -------------- |
| `fileId` string, path, required | The file's ID. |

More about this endpoint

The response always has `Content-Disposition: attachment`, so a browser saves the file instead of showing it as a page.
