> For the complete documentation index, see [llms.txt](https://docs.datasaur.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasaur.ai/integrations/robosaur/commands/export-projects.md).

# Export Projects

## How it works

{% code overflow="wrap" %}

```bash
$ npm run start -- export-projects -h
Usage: robosaur export-projects [options] <configFile>

Export all projects based on the given config file

Options:
  -u --unzip  Unzips the exported projects, only storing the final version accepted by reviewers
  -h, --help  display help for command
```

{% endcode %}

* Robosaur exports projects that were previously created using the `create-projects` command.
* Each project is exported as a separate ZIP file under the directory specified in `export.prefix`.
* By default, Robosaur performs a full project export, including each labeler’s version of the project documents.
* For simpler workflows where only the final document version is needed, use the `--unzip` option. When enabled, Robosaur saves only the final version of the documents to the export destination.
* Robosaur exports:
  * Projects that match the configured filters.
  * Projects that have not yet been recorded in the state file.
* Each project is exported only once.

## Configuration

```json
{
  ...
  "export": {
    "source": "local",
    "prefix": "path/to/export/root",
    "teamId": "<TEAM_ID>",
    "statusFilter": [],
    "format": "JSON_ADVANCED",
    "fileTransformerId": null
  },
  ...
}
```

### Storage options

Refer to the [Storage options](/integrations/robosaur/storage-options.md) guide for detailed configuration instructions.

### Format

Refer to the [Supported formats](/compatibility-and-updates/supported-formats.md) to know all the supported formats.

### File transformer ID

You can apply a custom transformation to exported files using a custom script. To create it:

1. Go to Datasaur and open the **File transformers** page.
2. Create a file transformer in the app.
3. Open the file transformer and copy the ID from the URL.
4. Set the ID in `fileTransformerId`.

### Filter <a href="#execution-modes" id="execution-modes"></a>

Robosaur supports filtering exported projects by project status. If `statusFilter` is empty, no status filtering is applied. Supported statuses:

* `CREATED`: Projects that haven't been opened by any labelers.
* `IN_PROGRESS`: Project that have been opened by at least one labeler.
* `REVIEW_READY`: Projects that have been finished by all labelers.
* `IN_REVIEW`: `REVIEW_READY` projects that have been opened by at least one reviewer.
* `COMPLETE`: Projects marked as complete by a reviewer.

## Execution modes <a href="#execution-modes" id="execution-modes"></a>

Robosaur supports two export modes:

* Stateful export (default).
* Stateless export.

### Stateful project export (default) <a href="#stateful-project-creation--export" id="stateful-project-creation--export"></a>

In stateful mode, the state file configured through `projectState` is treated as the source of truth.

Only projects recorded in the state file, typically projects created by Robosaur, are checked against `statusFilter` and exported.

Robosaur also tracks the last exported project status. Subsequent runs only export projects if the project status has progressed forward since the previous export.

### Stateless project export <a href="#stateless-project-export" id="stateless-project-export"></a>

Stateless mode supports exporting projects that were not created by Robosaur. To enable this mode, configure the following fields.

1. `"executionMode"` : Defines whether the exported projects were created with Robosaur. Fill with `"stateless"` for projects created outside Robosaur and `"stateful"` for projects created with Robosaur. The default value is `"stateful"`.
2. `"projectFilter"` : Defines which projects should be exported. Contains the following attributes:
   * `"kind"` (required): Fill with `TOKEN_BASED`, `ROW_BASED`, or `DOCUMENT_BASED` .
   * `"date"`
     * `"newestDate"` (required): Ignores all projects created after this date.
     * `"oldestDate"` : Ignores all projects created before this date.

Example:

```json
...
"export": {
  "source": "local",
  "prefix": "quickstart/token-based/export",
  "teamId": "1",
  "statusFilter": [],
  "executionMode": "stateless",
  "projectFilter": {
    "kind": "TOKEN_BASED",
    "date": {
      "newestDate": "2022-03-11",
      "oldestDate": "2022-03-07"
    }
  },
  "format": "JSON_ADVANCED",
  "fileTransformerId": null
},
...
```
