# Download a data export's file

```http
GET https://secure.yoprint.com/v1/api/store/{team_slug}/data_export/{id}/download
```

- API version: v1
- Operation ID: `v1_public_data_export_download`
- Section: Imports and exports › [Data exports](https://developer.yoprint.com/reference/data-exports.md)
- Web page: https://developer.yoprint.com/reference/data-exports/v1-data-export-download/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

Sends the export's CSV file itself, not JSON and not a link. The file is named `yoprint_<type>_export-<YYYY-MM-DD>.csv`, with the date (UTC) the export was created (in `Content-Disposition`).

It works only while the export is `ready` and not expired, which is 3 days after it became ready. You can download it as many times as you like in that time.

Save the answer to a file. The `Accept: application/json` header every request sends is fine here: the file still comes back as CSV.

```bash
curl -o export.csv -H "Authorization: Bearer YOUR_API_KEY" -H "Accept: application/json" \
  https://secure.yoprint.com/v1/api/store/your-team/data_export/G59hl28azOL22k/download
```

## Permission

Any member of the team, for any of the team's exports.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.
- `id` (string, required): The export's `id`, from the create answer. A hash id; unique keys and document numbers are refused with 404. Example `G59hl28azOL22k`.

## Request body

This operation takes no request body.

### Example request

```bash
curl 'https://secure.yoprint.com/v1/api/store/your-team/data_export/G59hl28azOL22k/download' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -o download
```

## Response

`200` Binary download response.

The answer is a file (`application/octet-stream`), not JSON. The example saves it with `curl -o`.

## Errors

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You are not allowed to do this. `api_access_not_in_plan`: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only `{"message": "Insufficient Permission"}`. Other refusals use the error envelope, with `unauthorized` or `user_is_not_authorized`.
- `404` Not found. `page_not_found`: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. `code: null`, with a message that starts "No query results for": there is no record with that id.
  - When: The export is not ready yet, failed, expired, or its file was removed. All of these answer the same 404 (`page_not_found`). Fix: Read the export first: download only when `status` is `ready` and `expires_at` is in the future. If it expired, create a new export.
  - When: The id is not one of this team's exports. Fix: Use the `id` the create operation returned.

## Notes

- The response has `Cache-Control: private, no-store`. Save the file; do not rely on caches.
- The file is UTF-8 with a byte order mark, so spreadsheet apps read accents correctly. Strip the first three bytes if your CSV reader does not expect it.

## Related

- [Get a data export](https://developer.yoprint.com/reference/data-exports/v1-data-export-show.md): `GET /v1/api/store/{team_slug}/data_export/{id}`
