# Update a repository webhook

From **GitHub v3 REST API**.

`PATCH /repos/{owner}/{repo}/hooks/{hook_id}`

Updates a webhook configured in a repository. If you previously had a `secret` set, you must provide the same `secret` or set a new `secret` or the secret will be removed. If you are only updating individual webhook `config` properties, use "[Update a webhook configuration for a repository](/rest/reference/repos#update-a-webhook-configuration-for-a-repository)."

## Parameters

### `owner`

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

### `repo`

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

### `hook_id`

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

## Request body

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

- Type: `object`

```json
{
  "active": true,
  "add_events": [
    "pull_request"
  ]
}
```

```json
{"properties":{"active":{"default":true,"description":"Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.","type":"boolean"},"add_events":{"description":"Determines a list of events to be added to the list of events that the Hook triggers for.","items":{"type":"string"},"type":"array"},"config":{"description":"Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/enterprise-server@3.0/rest/reference/repos#create-hook-config-params).","properties":{"address":{"example":"\"bar@example.com\"","type":"string"},"content_type":{"$ref":"#/components/schemas/webhook-config-content-type"},"insecure_ssl":{"$ref":"#/components/schemas/webhook-config-insecure-ssl"},"room":{"example":"\"The Serious Room\"","type":"string"},"secret":{"$ref":"#/components/schemas/webhook-config-secret"},"url":{"$ref":"#/components/schemas/webhook-config-url"}},"required":["url"],"type":"object"},"events":{"default":["push"],"description":"Determines what [events](https://docs.github.com/enterprise-server@3.0/webhooks/event-payloads) the hook is triggered for. This replaces the entire array of events.","items":{"type":"string"},"type":"array"},"remove_events":{"description":"Determines a list of events to be removed from the list of events that the Hook triggers for.","items":{"type":"string"},"type":"array"}},"type":"object"}
```

## Responses

### `200`

Response

### `application/json`

- Type: `object`

Webhooks for repositories.

```json
{
  "active": true,
  "config": {
    "content_type": "json",
    "insecure_ssl": "0",
    "url": "https://example.com/webhook"
  },
  "created_at": "2019-06-03T00:57:16Z",
  "events": [
    "push",
    "pull_request"
  ],
  "id": 12345678,
  "last_response": {
    "code": null,
    "message": null,
    "status": "unused"
  },
  "name": "web",
  "ping_url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678/pings",
  "test_url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678/test",
  "type": "Repository",
  "updated_at": "2019-06-03T00:57:16Z",
  "url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678"
}
```

```json
{"description":"Webhooks for repositories.","properties":{"active":{"description":"Determines whether the hook is actually triggered on pushes.","example":true,"type":"boolean"},"config":{"properties":{"content_type":{"$ref":"#/components/schemas/webhook-config-content-type"},"digest":{"example":"\"sha256\"","type":"string"},"email":{"example":"\"foo@bar.com\"","type":"string"},"insecure_ssl":{"$ref":"#/components/schemas/webhook-config-insecure-ssl"},"password":{"example":"\"foo\"","type":"string"},"room":{"example":"\"roomer\"","type":"string"},"secret":{"$ref":"#/components/schemas/webhook-config-secret"},"subdomain":{"example":"\"foo\"","type":"string"},"token":{"example":"\"abc\"","type":"string"},"url":{"$ref":"#/components/schemas/webhook-config-url"}},"type":"object"},"created_at":{"example":"2011-09-06T17:26:27Z","format":"date-time","type":"string"},"events":{"description":"Determines what events the hook is triggered for. Default: ['push'].","example":["push","pull_request"],"items":{"type":"string"},"type":"array"},"id":{"description":"Unique identifier of the webhook.","example":42,"type":"integer"},"last_response":{"$ref":"#/components/schemas/hook-response"},"name":{"description":"The name of a valid service, use 'web' for a webhook.","example":"web","type":"string"},"ping_url":{"example":"https://api.github.com/repos/octocat/Hello-World/hooks/1/pings","format":"uri","type":"string"},"test_url":{"example":"https://api.github.com/repos/octocat/Hello-World/hooks/1/test","format":"uri","type":"string"},"type":{"type":"string"},"updated_at":{"example":"2011-09-06T20:39:23Z","format":"date-time","type":"string"},"url":{"example":"https://api.github.com/repos/octocat/Hello-World/hooks/1","format":"uri","type":"string"}},"required":["id","url","type","name","active","events","config","ping_url","created_at","updated_at","last_response","test_url"],"title":"Webhook","type":"object"}
```

### `404`

Resource not found

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request PATCH \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/hooks/{hook_id} \
  --header 'content-type: application/json' \
  --data '{
  "active": true,
  "add_events": [
    "pull_request"
  ]
}'
```
