> 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/api/export-project.md).

# Export Project

There are two types of exports:

* **exporting a single file** in a project
* **exporting all files** in a project

## The export API

* Use the API docs reference below and follow this [step-by-step section to make the API request](/api/apis-docs.md).
* Please note that the project ID refers to the resource ID that can be accessed from the URL when opening a project.

### Export a file

This API will only return the latest state of the project.

* Query: [exportTextProjectDocument](https://api-docs.datasaur.ai/#query-exportTextProjectDocument)

### Export all files

Specifically for exporting all files, there is a [Python script example](https://github.com/datasaur-ai/api-client-example/blob/master/export.py) that you can use. This API will return a `.zip` file that consist of the latest state of the project and each labeler's work.

* Query: [exportTextProject](https://api-docs.datasaur.ai/#query-exportTextProject)

## Asynchronous process

All the processes above are done asynchronously. To check the export job, you need to request the [`getExportDeliveryStatus`](https://api-docs.datasaur.ai/#query-getExportDeliveryStatus) query.

Specifically for the `FILE_STORAGE` method, the `fileUrl` response could return 404. If this happens, it means the export result hasn't been uploaded yet. Please wait or polling the query above to know when exactly the `fileUrl` is ready and can be downloaded.

## Required request payloads

### Document ID

See how to get the value [here](/api/get-data.md).

### Method

There are four different methods to obtain the export result: download, email, webhook, and external object storage. These methods are fully explained [here](/data-studio-projects/export-project.md).

For the API payload reference, it can be accessed [here](https://api-docs.datasaur.ai/#definition-GqlExportMethod).

The method will be the same and applicable for both types of export. Below is the additional explanation for each method. **Ensure you fill all the required attributes**, and then follow these hints.

* **Download**
  * For the `method` attribute, fill it with `FILE_STORAGE`.
* **Email**
  * For the `method` attribute, fill it with `EMAIL`.
* **Webhook**
  * For the `method` attribute, fill it with `CUSTOM_WEBHOOK`.
  * You also need to fill `url` and `secret` attribute.
  * The detailed explanation can be seen [here](/api/export-project/custom-webhook.md).
* **External object storage**
  * For the method attribute, fill with `EXTERNAL_OBJECT_STORAGE`.
  * You also need to fill `externalObjectStorageParameter`.

### Format - extension mapping

* `DATASAUR_SCHEMA` can be used for any types of project.
* `XLSX`, `CSV`, `JSON_TABULAR`, and `TSV` for row labeling and document labeling.
  * CSV will also work and is compatible for Hugging Face.
* `TSV_IOB`, `TSV_NON_IOB`, `JSON_ADVANCED` for span labeling.
* `CUSTOM` for export using [File Transformer](/workspace-management/file-transformer.md).
* `JSON` for JSON Simplified format.
* `PLAIN` for exporting only the text (without any labels) of a span labeling project.
* `AMAZON_COMPREHEND_CSV` can be used for both [span labeling](https://docs.aws.amazon.com/comprehend/latest/dg/cer-annotation-csv.html) and [row labeling](https://docs.aws.amazon.com/comprehend/latest/dg/prep-classifier-data-multi-label.html).
  * There is a specific scenario to consider with span labeling. Since Comprehend can only reference a file on S3, it is important to export the text after making any edits by doing another export with the `PLAIN` extension as explained above. This ensures that you can correctly reference the annotation data.
* `AZURE_AUTOML_CSV` can be used for both [span labeling (NER) and row labeling (multi-label)](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-auto-train-nlp-models?view=azureml-api-2\&tabs=cli).
* `GCP_VERTEX_AI_CSV` can be used for both [span labeling](https://cloud.google.com/vertex-ai/docs/text-data/entity-extraction/prepare-data) and [row labeling](https://cloud.google.com/vertex-ai/docs/text-data/classification/prepare-data#multi-label-classification).
