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

# Exporting Gift Cards

Exporting gift cards allows downloading a list of gift card codes to a CSV or an XLSX file. You can export all gift cards, filtered gift cards, or gift cards with specific IDs, but only unused cards will be exported. The link to download the file is sent by email to the requestor. An email with information about the problems is sent if any error occurs.

<a id="export-file-structure"></a>

### Export File Structure

The exported file contains one column with a `code` header in the first row and gift card codes in the following rows, as shown below.

| code |
| --- |
| ABCD-EFGH-IJKL |
| IJKL-ABCD-EFGH |
| EFGH-ABCD-IJKL |
| IJKL-EFGH-ABCD |

<a id="exporting-gift-cards"></a>

## Exporting Gift Cards

note

Gift cards can be exported only by logged users with `MANAGE_GIFT_CARD` permission. Only unused gift card codes are exported.

To export gift cards, use `exportGiftCards` mutation.

This mutation takes the following input:

-   `scope`: determine which gift cards should be exported. You can choose between exporting all unused gift cards (`ALL`), filtered gift cards (`FILTER`) or selected IDs (`IDS`). You can find more details in the next sections.
-   `filter`: defines filtering option. This field is optional but must be specified if your choose `FILTER` scope option.
-   `ids`: a list of products IDs to export. This field is optional but must be specified if `IDS` in `scope` is chosen.
-   `fileType`: defines exported file type. You can choose between `CSV` and `XLSX` file.

As a result, this mutation returns `ExportFile` object which is a `Job` instance. For details, look at [export mutations descriptions](/developer/export/export-overview.md#mutations).

<a id="exporting-all-gift-cards"></a>

### Exporting All Gift Cards

The following example shows how to export all gift cards with all available fields to a CSV file.

**Mutation**

```graphql
mutation ExportGiftCards($input: ExportGiftCardsInput!) {
  exportGiftCards(input: $input) {
    exportFile {
      id
      status
      createdAt
      updatedAt
      url
    }
    errors {
      field
      code
      message
    }
  }
}
```

**Variables**

```json
{
  "input": {
    "scope": "ALL",
    "fileType": "CSV"
  }
}
```

**Result**

```json
{
  "data": {
    "exportGiftCards": {
      "exportFile": {
        "id": "RXhwb3J0RmlsZTox",
        "status": "PENDING",
        "createdAt": "2020-06-05T09:15:42.924676+00:00",
        "updatedAt": "2020-06-05T09:16:27.691838+00:00",
        "url": ""
      },
      "errors": []
    }
  }
}
```

Once the task is finished, the `url` field will contain the URL address of the exported file. If the `User` triggers export, the link to the file will be sent by email to the requestor. To check if the URL is ready, you can fetch [ExportFile](/developer/export/export-overview.md#fetching-exportfile-instance).

<a id="applying-filters"></a>

### Applying Filters

To export only filtered gift cards you need to set the `scope` to `FILTER` and include the `filter` parameter.

The following example only includes gift cards that have a `birthday` tag.

**Mutation**

```graphql
mutation ExportGiftCards($input: ExportGiftCardsInput!) {
  exportGiftCards(input: $input) {
    exportFile {
      id
      status
      createdAt
      updatedAt
      url
    }
    errors {
      field
      code
      message
    }
  }
}
```

**Variables**

```json
{
  "input": {
    "scope": "FILTER",
    "fileType": "XLSX",
    "filter": {
      "tags": [
        "birthday"
      ]
    }
  }
}
```

<a id="exporting-gift-cards-with-specified-ids"></a>

### Exporting Gift Cards With Specified IDs

To export only gift cards with provided IDs, you need to set the `scope` to `IDS` and include the `ids` parameter. Lets see an example:

**Mutation**

```graphql
mutation ExportGiftCards($input: ExportGiftCardsInput!) {
  exportGiftCards(input: $input) {
    exportFile {
      id
      status
      createdAt
      updatedAt
      url
    }
    errors {
      field
      code
      message
    }
  }
}
```

**Variables**

```json
{
  "input": {
    "scope": "IDS",
    "fileType": "CSV",
    "ids": [
      "R2lmdENhcmQ6MjU=",
      "R2lmdENhcmQ6MjY=",
      "R2lmdENhcmQ6Mjc="
    ]
  }
}
```
