# Save the file

> Saves the file to a folder in Files, ready to download, or to one of your connections.

Source: https://docs.go-lumen.ai/reference/steps/save-file

## At a glance

| Property | Value |
| --- | --- |
| **Step name** | `save-file` |
| **Resource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palette group, category** | save, files |
| **Credits** | **1** credit each time it succeeds |
| **Side effects** | yes: It changes something outside Lumen, so a retry asks first and a test shows what it would do instead of doing it. |
| **Installation must provide** | nothing |

## Inputs

| Property | Value |
| --- | --- |
| **Needs** | `file` |
| **Produces** | nothing |
| **Works on** | item: one document at a time |

Needs and Produces are data types (file, text, fields, email). The editor offers a step only where what it needs is already on the path. See [Documents and data](https://docs.go-lumen.ai/concepts/how-flows-run.md#documents-and-data).

## Outputs

No named outputs. Later nodes still see everything produced earlier on the path, and this step passes the documents on unchanged.

## Settings

Set under `config:` on the flow node. Text settings may contain `{nodeId.field}` placeholders.

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `destination` | string | `"lumen"` | Destination is where the files go: lumen (the default) or connector. (one of lumen, connector) |
| `connectorRef` | string |  | ConnectorRef names the Connector a connector destination writes to. (minLength 1) |
| `folder` | string |  | Use / for subfolders, `{flow}` for the flow's name and `{date:yyyy-MM}` for the month. Empty saves to Saved/`{flow}`. A file whose name is taken is saved as name (2). (maxLength 200) |
| `ifExists` | string | `"copy"` | Keep both saves the new file as name (2). Replace saves it under the same name and keeps the previous file in .versions. (one of copy, replace) |
| `connectionFolder` | string |  | Under the connection's folder; empty saves there. A file with the same name is saved as its new version, and SharePoint keeps the old versions. (maxLength 200) |

The full JSON Schema of these settings: [save-file.schema.json](https://docs.go-lumen.ai/schemas/steps/save-file.schema.json).

## Example

File two invoices in a monthly folder

```yaml title="config"
destination: lumen
folder: Invoices/{date:yyyy-MM}
```

## Use it in a flow

A node that runs `save-file` goes under `spec.nodes` of a [Flow](https://docs.go-lumen.ai/concepts/how-flows-run.md#the-flow-as-yaml). Give it any id, and list the next node ids in next.

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: save-file-example
  namespace: tenant-acme
spec:
  displayName: "Save the file"
  triggers:
    - id: start
      ref: {name: manual-run}
      next: [save-file]
  nodes:
    - id: save-file
      stepRef: {name: save-file}
      config:
        destination: lumen
        folder: Invoices/{date:yyyy-MM}
```
