> Documentation index: [Saleor](/llms.txt) · [This section](/developer/llms.txt)
> Source: https://docs.saleor.io/developer/export/export-overview

# Exporting Data

This guide gives information common to all exports. At this time, only the export of products and gift cards is available.

<a id="workflow"></a>

### Workflow

<a id="schedule-export"></a>

#### Schedule export

The chart below describes what the workflow looks like for each export. The changes for each export involve the mutation and the background worker adapted to the data type.

```mermaid
sequenceDiagram
  Client ->>+ Saleor: mutation
  Saleor ->> Saleor: Validate input data
  Saleor ->>+ Background Worker: Schedule export
  Background Worker -->>- Saleor: Scheduled
  Saleor -->>- Client: return ExportFile instance
```

<a id="handling-background-worker-result"></a>

#### Handling background worker result

Background worker result is also handled in the same way for all workers. The chart below shows what happens in case of the successful and failed worker results.

```mermaid
graph TD
  D[Export data <br> Background Worker] -->|Success| E[Send email to user <br> with a link to <br> download file]
  D -->|Success| X[Set SUCCESS <br>ExportFile status]
  E -->Y[Create export file <br>sent event]
  X -->F[Create data export <br>success event]
  D -->|Failed| G[Set FAILED <br>ExportFile status]
  G --> U[Create data export <br>failed event]
  U --> J[Send email to the user<br>with information <br>about failing export]
  J --> K[Create export failed <br>info sent event]
```

<a id="mutations"></a>

### Mutations

The input data for the mutations may differ insignificantly, but all of them return the same data type: the `ExportFile` object, being a `Job` instance. It corresponds to running the export background worker, keeping task status, and creating a file. `ExportFile` object contains the following fields:

-   `id`: a unique export file ID. Could be use to check export status.
-   `status`: status of running the job.
-   `user`: instance of `User` who requested exporting products. Set to `null` if export requested by `App`.
-   `app`: instance of `App` which requested exporting products. Set to `null` if export requested by `User`.
-   `createdAt`: the date and time when the export was started.
-   `updatedAt`: the date and time when the job was last time updated.
-   `url`: URL to the exported file. Set to `null` when the file doesn't exist yet.
-   `events`: a list of events associated with the export.

In addition, the following field is available on every mutation result:

-   `errors`: a list of errors that occurred during mutation execution.

<a id="fetching-exportfile-instance"></a>

### Fetching `ExportFile` instance

Export is done in the asynchronous worker, so as a result, you might get an export file instance with a `PENDING` status. To check if the task status has changed, you can fetch `ExportFile` by `ID` with the use of `exportFile` query:

**Query**

```graphql
query ExportFile($id: ID!){
  exportFile(id: $id) {
    id
    status
    createdAt
    updatedAt
    url
  }
}
```

**Variables**

```json
{
  "id": "RXhwb3J0RmlsZToxMA=="
}
```

**Result**

```json
{
  "data": {
    "exportFile": {
      "id": "RXhwb3J0RmlsZToxMA==",
      "status": "SUCCESS",
      "createdAt": "2020-06-05T09:15:42.924676+00:00",
      "updatedAt": "2020-06-05T09:16:27.691838+00:00",
      "url": "http://localhost:8000/media/export_files/product_data_05_06_2020.csv"
    }
  }
}
```
