Skip to content

Create a repository webhook

POST
/repos/{owner}/{repo}/hooks

Repositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can share the same config as long as those webhooks do not have any events that overlap.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

Media type application/json
object
name

Use web to create a webhook. Default: web. This parameter only accepts the value web.

string
config

Key/value pairs to provide settings for this webhook.

object
url

The URL to which the payloads will be delivered.

string format: uri
content_type

The media type used to serialize the payloads. Supported values include json and form. The default is form.

string
secret

If provided, the secret will be used as the key to generate the HMAC hex digest value for delivery signature headers.

string
insecure_ssl
One of:

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

string
events

Determines what events the hook is triggered for.

Array<string>
default: push
active

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

boolean
default: true
Examples
Example default
{
"name": "web",
"active": true,
"events": [
"push",
"pull_request"
],
"config": {
"url": "https://example.com/webhook",
"content_type": "json",
"insecure_ssl": "0"
}
}

Response

Media type application/json
Webhook

Webhooks for repositories.

object
type
required
string
id
required

Unique identifier of the webhook.

integer
name
required

The name of a valid service, use ‘web’ for a webhook.

string
active
required

Determines whether the hook is actually triggered on pushes.

boolean
events
required

Determines what events the hook is triggered for. Default: [‘push’].

Array<string>
config
required
Webhook Configuration

Configuration object of the webhook

object
url

The URL to which the payloads will be delivered.

string format: uri
content_type

The media type used to serialize the payloads. Supported values include json and form. The default is form.

string
secret

If provided, the secret will be used as the key to generate the HMAC hex digest value for delivery signature headers.

string
insecure_ssl
One of:

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

string
updated_at
required
string format: date-time
created_at
required
string format: date-time
url
required
string format: uri
test_url
required
string format: uri
ping_url
required
string format: uri
deliveries_url
string format: uri
last_response
required
Hook Response
object
code
required
integer
nullable
status
required
string
nullable
message
required
string
nullable
Examples
Example default
{
"type": "Repository",
"id": 12345678,
"name": "web",
"active": true,
"events": [
"push",
"pull_request"
],
"config": {
"content_type": "json",
"insecure_ssl": "0",
"url": "https://example.com/webhook"
},
"updated_at": "2019-06-03T00:57:16Z",
"created_at": "2019-06-03T00:57:16Z",
"url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678",
"test_url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678/test",
"ping_url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678/pings",
"deliveries_url": "https://api.github.com/repos/octocat/Hello-World/hooks/12345678/deliveries",
"last_response": {
"code": null,
"status": "unused",
"message": null
}
}
Location
string
Example
https://api.github.com/repos/octocat/Hello-World/hooks/12345678

Forbidden

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}