# Download a file or folder from a backup

`GET /api/v1/artifacts/{artifact}/entry`

Streams the entry at `path` (as the file index lists it): a file as it is, a folder as a zip. A file comes as `application/octet-stream`, a folder as `application/zip`. When the entry cannot be served the answer is JSON with a `message`: 404 when the backup holds no such path, 422 for an empty folder or one with too many files, 501 for an encrypted or zstd-compressed backup, 503 while the backup's file list or its storage cannot be reached.

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| artifact | integer | yes | The ID of the backup. Example: `2291`. |

## Query Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| path | string | yes | The path of the file or folder inside the backup, as the entries list gives it. Example: `httpdocs/wp-config.php`. |

## Response

### 200

Binary body (`application/octet-stream`, `application/zip`)

The file, or the folder as a zip.

### 401

The request carries no valid token: the `Authorization: Bearer` header is missing, or its token is unknown, revoked or past its expiry date. Send a current personal access token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | Always `Unauthenticated.`. |

### 403

The token may not read this. The `message` says why: `Your role does not permit this action.` (its owner is not an Admin, Operator or Viewer in the client), `This account is disabled.`, `This token is not bound to a client you belong to.`, or `Client suspended`. While backup downloads are switched off for the client the message is `Backup downloads are disabled.`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 404

The backup, or the file or folder inside it, was not found. A backup that was missing from storage at the last check answers `This backup is missing from storage and cannot be downloaded.`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 410

The storage that held this backup was deleted.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 422

The folder holds no files, or too many to zip.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 501

The backup is encrypted or zstd-compressed, so one file cannot be taken out of it; restore it instead.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 503

The backup's file index cannot be read from storage right now. Try again later. The same status, with the message `The storage that holds this backup can't be reached right now. Try again later.`, when the storage that holds the backup does not answer before the download starts.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

## Request example

```bash
curl 'https://app.clokeep.com/api/v1/artifacts/2291/entry?path=httpdocs%2Fwp-config.php' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Accept: application/octet-stream, application/zip' \
  --fail \
  -o 'wp-config.php'
```

## Response example (401)

```json
{
  "message": "Unauthenticated."
}
```

## Response example (403)

```json
{
  "message": "Backup downloads are disabled."
}
```

## Response example (404)

```json
{
  "message": "This backup holds no file or folder at that path."
}
```

## Response example (410)

```json
{
  "message": "The storage that held this backup was deleted."
}
```

## Response example (422)

```json
{
  "message": "This folder holds no files."
}
```

## Response example (501)

```json
{
  "message": "This backup is encrypted. Per-file download is unavailable; restore it instead."
}
```

## Response example (503)

```json
{
  "message": "The file list of this backup is unavailable: storage unreachable."
}
```
