# Update a pre-receive hook

From **GitHub v3 REST API**.

`PATCH /admin/pre-receive-hooks/{pre_receive_hook_id}`

Update a pre-receive hook

## Parameters

### `pre_receive_hook_id`

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

pre_receive_hook_id parameter

## Request body

- Required: false
### `application/json`

- Type: `object`

```json
{
  "allow_downstream_configuration": true,
  "environment": {
    "id": 1
  },
  "name": "Check Commits"
}
```

```json
{"properties":{"allow_downstream_configuration":{"description":"Whether enforcement can be overridden at the org or repo level.","type":"boolean"},"enforcement":{"description":"The state of enforcement for this hook.","type":"string"},"environment":{"additionalProperties":true,"description":"The pre-receive environment where the script is executed.","type":"object"},"name":{"description":"The name of the hook.","type":"string"},"script":{"description":"The script that the hook runs.","type":"string"},"script_repository":{"additionalProperties":true,"description":"The GitHub repository where the script is kept.","type":"object"}},"type":"object"}
```

## Responses

### `200`

Response

### `application/json`

- Type: `object`

```json
{
  "allow_downstream_configuration": true,
  "enforcement": "disabled",
  "environment": {
    "created_at": "2016-05-20T11:35:45-05:00",
    "default_environment": true,
    "download": {
      "downloaded_at": "2016-05-26T07:42:53-05:00",
      "message": null,
      "state": "success",
      "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1/downloads/latest"
    },
    "hooks_count": 1,
    "html_url": "https://github.example.com/admin/pre-receive-environments/1",
    "id": 1,
    "image_url": "githubenterprise://internal",
    "name": "Default",
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1"
  },
  "id": 1,
  "name": "Check Commits",
  "script": "scripts/commmit_check.sh",
  "script_repository": {
    "full_name": "DevIT/hooks",
    "html_url": "https://github.example.com/DevIT/hooks",
    "id": 595,
    "url": "https://github.example.com/api/v3/repos/DevIT/hooks"
  }
}
```

```json
{"properties":{"allow_downstream_configuration":{"type":"boolean"},"enforcement":{"type":"string"},"environment":{"properties":{"created_at":{"type":"string"},"default_environment":{"type":"boolean"},"download":{"properties":{"downloaded_at":{"nullable":true,"type":"string"},"message":{"nullable":true,"type":"string"},"state":{"type":"string"},"url":{"type":"string"}},"type":"object"},"hooks_count":{"type":"integer"},"html_url":{"type":"string"},"id":{"type":"integer"},"image_url":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"}},"type":"object"},"id":{"type":"integer"},"name":{"type":"string"},"script":{"type":"string"},"script_repository":{"properties":{"full_name":{"type":"string"},"html_url":{"type":"string"},"id":{"type":"integer"},"url":{"type":"string"}},"type":"object"}},"type":"object"}
```

## Request examples

### cURL

```shell
curl --request PATCH \
  --url {protocol}://{hostname}/api/v3/admin/pre-receive-hooks/{pre_receive_hook_id} \
  --header 'content-type: application/json' \
  --data '{
  "allow_downstream_configuration": true,
  "environment": {
    "id": 1
  },
  "name": "Check Commits"
}'
```
