# Start a pre-receive environment download

From **GitHub v3 REST API**.

`POST /admin/pre-receive-environments/{pre_receive_environment_id}/downloads`

Triggers a new download of the environment tarball from the environment's `image_url`. When the download is finished, the newly downloaded tarball will overwrite the existing environment.

If a download cannot be triggered, you will receive a `422 Unprocessable Entity` response.

The possible error messages are:

* _Cannot modify or delete the default environment_
* _Can not start a new download when a download is in progress_

## Parameters

### `pre_receive_environment_id`

- Location: path
- Required: true
- Type: `integer`

## Responses

### `202`

Response

### `application/json`

- Type: `object`

```json
{
  "downloaded_at": null,
  "message": null,
  "state": "not_started",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest"
}
```

```json
{"properties":{"downloaded_at":{"nullable":true,"type":"string"},"message":{"nullable":true,"type":"string"},"state":{"type":"string"},"url":{"type":"string"}},"type":"object"}
```

### `422`

Client Errors

### `application/json`

- Type: `object`

```json
{
  "errors": [
    {
      "code": "custom",
      "message": "Can not start a new download when a download is in progress",
      "resource": "PreReceiveEnvironment"
    }
  ],
  "message": "Validation Failed"
}
```

```json
{"properties":{"errors":{"items":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"resource":{"type":"string"}},"type":"object"},"type":"array"},"message":{"type":"string"}},"type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url {protocol}://{hostname}/api/v3/admin/pre-receive-environments/{pre_receive_environment_id}/downloads
```
