# kindgi files

> Files kept in the runtime, with every version: list, get, versions, download, upload, restore, pin, unpin, pin-history, delete

## `kindgi files`

**Synopsis**

```sh signature
kindgi files <command>
```

Files kept in the runtime, with every version: list, get, versions, download, upload, restore, pin, unpin, pin-history, delete.

**Commands**

| Command                                                                                                      | Description                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`kindgi files list`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-list)               | List the files you can read, newest change first: by run, project or type.                                                                                 |
| [`kindgi files get`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-get)                 | A file: its name, project and run, Latest, and its pinned versions.                                                                                        |
| [`kindgi files versions`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-versions)       | Every version of a file, newest first, deleted and purged ones too, each with its state.                                                                   |
| [`kindgi files download`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-download)       | Download a version to a file, Latest unless one is named: -o's path, else its own name in this directory (an existing file is kept unless --force).        |
| [`kindgi files upload`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-upload)           | Upload a file: version 1 of a new file, in its run's project, else --project's, else the project your API key is limited to, else the workspace's default. |
| [`kindgi files restore`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-restore)         | Add a version with an earlier version's bytes, which becomes Latest.                                                                                       |
| [`kindgi files pin`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-pin)                 | Pin a version: it can't be deleted, and retention keeps it.                                                                                                |
| [`kindgi files unpin`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-unpin)             | Take a version's pin off.                                                                                                                                  |
| [`kindgi files pin-history`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-pin-history) | Every pin and unpin of a file's versions, newest first.                                                                                                    |
| [`kindgi files delete`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files-delete)           | Delete a file and every version, or with a version, that version.                                                                                          |

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)

### `kindgi files list`

**Synopsis**

```sh signature
kindgi files list [--run=<run-id>] [--project=<project-id>] [--content-type=<mime>] [--limit=<n>] [--cursor=<c>] [--table]
```

List the files you can read, newest change first: by run, project or type.

**Options**

| Option                   | Default              | Description                                                      |
| ------------------------ | -------------------- | ---------------------------------------------------------------- |
| `--content-type <value>` | none                 | Only files whose Latest has this MIME type.                      |
| `--cursor <value>`       | none                 | Resume after this cursor, from the previous page's `nextCursor`. |
| `--limit <value>`        | `25` (at most `100`) | The most to return (default 25, at most 100).                    |
| `--project <value>`      | none                 | Only one project's files.                                        |
| `--run <value>`          | none                 | Only the files whose version 1 this run made.                    |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

List the files one run made, as a table.

```sh
kindgi files list --run=<run-id> --table
```

From [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md):

```sh
pnpm exec kindgi files list --run=<run-id> --table
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files get`

**Synopsis**

```sh signature
kindgi files get <file-id> [<version>]
```

A file: its name, project and run, Latest, and its pinned versions. With a version, that version. Never its bytes.

**Options**

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Show a file and its Latest version; add a version number for that version's details.

```sh
kindgi files get <file-id>
```

From [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md):

```sh
pnpm exec kindgi files get <file-id>
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files versions`

**Synopsis**

```sh signature
kindgi files versions <file-id> [--limit=<n>] [--cursor=<c>] [--table]
```

Every version of a file, newest first, deleted and purged ones too, each with its state.

**Options**

| Option             | Default              | Description                                                      |
| ------------------ | -------------------- | ---------------------------------------------------------------- |
| `--cursor <value>` | none                 | Resume after this cursor, from the previous page's `nextCursor`. |
| `--limit <value>`  | `25` (at most `100`) | The most to return (default 25, at most 100).                    |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

List a file's versions as a table, with which one is Latest, and which are deleted or pinned.

```sh
kindgi files versions <file-id> --table
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files download`

**Synopsis**

```sh signature
kindgi files download <file-id> [<version>] [-o <file>] [--force]
```

Download a version to a file, Latest unless one is named: -o's path, else its own name in this directory (an existing file is kept unless --force). The file is written only once the whole download has arrived.

**Options**

| Option        | Default                                          | Description                      |
| ------------- | ------------------------------------------------ | -------------------------------- |
| `--force`     | off                                              | Overwrite the file if it exists. |
| `--o <value>` | the version's own name, in the current directory | Write it to this file.           |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Save a file's version 2 under a name you pick.

```sh
kindgi files download <file-id> 2 -o report-v2.pdf
```

From [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md):

```sh
pnpm exec kindgi files download <file-id> -o report.pdf
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files upload`

**Synopsis**

```sh signature
kindgi files upload <path> [--to=<file-id> [--expected-version=<n>]] [--name=<name>] [--content-type=<mime>] [--run=<run-id>] [--project=<project-id>] [--tag=<key>=<value>]…
```

Upload a file: version 1 of a new file, in its run's project, else --project's, else the project your API key is limited to, else the workspace's default. With --to, a new version of that file. The runtime caps an upload (100 MiB unless set otherwise).

**Options**

| Option                       | Default                                                                                                            | Description                                                                          |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `--content-type <value>`     | from the file's extension, else `application/octet-stream`                                                         | Its MIME type (default: from the file's extension, else `application/octet-stream`). |
| `--expected-version <value>` | none: the last write wins                                                                                          | With --to: the version you built on. If Latest isn't it, nothing is written.         |
| `--name <value>`             | the file's name; with `--to`, Latest's                                                                             | Its name (default: the file's name; with --to, Latest's).                            |
| `--project <value>`          | with `--run`, the run's project; else the project your API key is limited to; else the workspace's default project | With no --run: the project it belongs to.                                            |
| `--run <value>`              | none                                                                                                               | The run that made it: it joins that run's project.                                   |
| `--tag <value>`              | none                                                                                                               | A label, `key=value` (repeatable). Repeatable.                                       |
| `--to <value>`               | none: version 1 of a file                                                                                          | Add a version to this file, which becomes its Latest.                                |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Keep a file in a project: it becomes version 1 of a file.

```sh
kindgi files upload ./report.pdf --project=<project-id>
```

Add a version to that file, unless someone added one after version 1.

```sh
kindgi files upload ./report.pdf --to=<file-id> --expected-version=1
```

From [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md):

```sh
pnpm exec kindgi files upload report.pdf --run=<run-id> --tag=kind=summary
pnpm exec kindgi files upload report.pdf --to=<file-id> --expected-version=1
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files restore`

**Synopsis**

```sh signature
kindgi files restore <file-id> <version> [--expected-version=<n>]
```

Add a version with an earlier version's bytes, which becomes Latest. Nothing is removed.

**Options**

| Option                       | Default                   | Description                                                    |
| ---------------------------- | ------------------------- | -------------------------------------------------------------- |
| `--expected-version <value>` | none: the last write wins | The Latest you expect. If Latest isn't it, nothing is written. |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Make version 2's bytes Latest again, as a version of its own, unless someone added a version after 5.

```sh
kindgi files restore <file-id> 2 --expected-version=5
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files pin`

**Synopsis**

```sh signature
kindgi files pin <file-id> <version> [--reason=<text>]
```

Pin a version: it can't be deleted, and retention keeps it. Latest doesn't move.

**Options**

| Option             | Default | Description                                         |
| ------------------ | ------- | --------------------------------------------------- |
| `--reason <value>` | none    | Why, kept with the change (at most 500 characters). |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Keep version 3: it can't be deleted, and retention keeps it.

```sh
kindgi files pin <file-id> 3 --reason="signed by the client"
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files unpin`

**Synopsis**

```sh signature
kindgi files unpin <file-id> <version> [--reason=<text>]
```

Take a version's pin off. Latest doesn't move.

**Options**

| Option             | Default | Description                                         |
| ------------------ | ------- | --------------------------------------------------- |
| `--reason <value>` | none    | Why, kept with the change (at most 500 characters). |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Take version 3's pin off, saying why.

```sh
kindgi files unpin <file-id> 3 --reason="superseded by version 5"
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files pin-history`

**Synopsis**

```sh signature
kindgi files pin-history <file-id> [--limit=<n>] [--cursor=<c>] [--table]
```

Every pin and unpin of a file's versions, newest first.

**Options**

| Option             | Default              | Description                                                      |
| ------------------ | -------------------- | ---------------------------------------------------------------- |
| `--cursor <value>` | none                 | Resume after this cursor, from the previous page's `nextCursor`. |
| `--limit <value>`  | `25` (at most `100`) | The most to return (default 25, at most 100).                    |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

See every pin and unpin of a file's versions, newest first.

```sh
kindgi files pin-history <file-id> --table
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)

### `kindgi files delete`

**Synopsis**

```sh signature
kindgi files delete <file-id> [<version>] [--yes]
```

Delete a file and every version, or with a version, that version. It asks first. Deleted versions stay until the retention policy for `file_version` purges them.

**Options**

| Option  | Default | Description                    |
| ------- | ------- | ------------------------------ |
| `--yes` | off     | Don't ask first (for scripts). |

Every command also takes the [global flags](https://docs.kindgi.com/v0.8.1/reference/cli.md#global-flags).

**Examples**

Delete a file's version 1, without being asked first.

```sh
kindgi files delete <file-id> 1 --yes
```

From [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md):

```sh
pnpm exec kindgi files delete <file-id> --yes
```

**See also**

- [Keep files with a run](https://docs.kindgi.com/v0.8.1/guides/runs/keep-files-with-a-run.md)
- [`kindgi files`](https://docs.kindgi.com/v0.8.1/reference/cli/files.md#kindgi-files)
