# Download an export

`GET /api/v1/exports/{accountExport}/download` and `QUERY /api/v1/exports/{accountExport}/download`

Retrieve the file of an export that is ready.

The body is the file itself, one JSON document with a file name attached, so what you receive can be written straight to disk. It is not wrapped in data like the other answers here. Its top level holds version (2.0-preview.1), app_version, exported_at and account, and account holds the vaults with everything in them.

Only a key holding the sensitive fields scope can download the file, since it holds every sensitive value: any other key answers 403.

An export that is not ready, or whose expires_at has passed, answers 404. Each download is written to the log of the account.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. [How QUERY works](https://friends.ban.is/docs/api/query-method).

## Path parameters

- `accountExport` (uuid, required): The id of the export. One belonging to another account answers 404.

## Returns

The file, as JSON. An export of another account answers 404.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download');
```

## Request with QUERY

```sh
curl https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://friends.ban.is/api/v1/exports/e7a1d9c4-3b6f-4f2a-8d15-6c0b9e2a4f73/download');
```

## Response

`200`, with no body.
