# Download a backup

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

The archive as stored. A backup on an S3 storage that is not encrypted answers 302 to a presigned URL on the storage, valid for 5 minutes by default: follow the redirect, and do not send your Clokeep token to the storage. Any other backup is streamed: send a `Range` header to resume, and the answer is 206 with that part, or 416 with no body when the range lies outside the archive. 403 while backup downloads are switched off for the client. 503 while the storage that holds the backup cannot be reached.

Guides: [API introduction](/docs/api-reference/introduction), [Download and share](/docs/restores/download-share), [S3 storage](/docs/storage/s3)

## Path Parameters

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

## Response

### 200

Binary body (`application/octet-stream`)

The whole archive.

### 206

Binary body (`application/octet-stream`)

The part of the archive the `Range` header asked for.

### 302

An unencrypted backup on an S3 storage: `Location` is a presigned URL on the storage that serves the archive, valid for a few minutes. Follow it without your Clokeep token.

### 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 its file in storage, was not found.

| 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. |

### 416

The `Range` header asks for bytes outside the archive. No body.

### 503

The storage that holds the backup cannot be reached right now. Try again later.

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

## Request example

```bash
curl 'https://app.clokeep.com/api/v1/artifacts/2291/download' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Accept: application/octet-stream' \
  --fail \
  -o 'download.bin'
```

## Response example (401)

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

## Response example (403)

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

## Response example (404)

```json
{
  "message": "Artifact file not found in storage."
}
```

## Response example (410)

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

## Response example (503)

```json
{
  "message": "The storage that holds this backup can't be reached right now. Try again later."
}
```
