Поддержка этой версии GitHub Enterprise была прекращена 2023-01-18. Исправления выпускаться не будут даже при критических проблемах безопасности. Для повышения производительности, укрепления безопасности и новых функций установите последнюю версию GitHub Enterprise. Чтобы получить справку по обновлению, обратитесь в службу поддержки GitHub Enterprise.
We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the Actions REST API page.
Глобальные веб-перехватчики
Используйте REST API для управления глобальными веб-перехватчиками для вашего предприятия.
Сведения о глобальных веб-перехватчиках
Эти конечные точки доступны только администраторам сайта, прошедшим проверку подлинности . Обычные пользователи получат 404
ответ. Сведения о настройке глобальных веб-перехватчиков см. в разделе Сведения о глобальных веб-перехватчиках.
Глобальные веб-перехватчики автоматически устанавливаются на предприятии. Глобальные веб-перехватчики можно использовать для автоматического мониторинга, реагирования или применения правил для пользователей, организаций, команд и репозиториев на предприятии.
Глобальные веб-перехватчики могут подписаться на такие типы событий, как организация, пользователь, репозиторий, команда, член, членство, вилка и проверка связи.
List global webhooks
Parameters
Headers |
---|
Имя, Type, Описание |
accept stringSetting to |
Query parameters |
Имя, Type, Описание |
per_page integerThe number of results per page (max 100). Default: |
page integerPage number of the results to fetch. Default: |
HTTP response status codes
Status code | Описание |
---|---|
200 | OK |
Code samples
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks
Response
Status: 200
[
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
]
Create a global webhook
Parameters
Headers | ||||||||
---|---|---|---|---|---|---|---|---|
Имя, Type, Описание | ||||||||
accept stringSetting to | ||||||||
Body parameters | ||||||||
Имя, Type, Описание | ||||||||
name stringRequiredMust be passed as "web". | ||||||||
config objectRequiredKey/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Имя, Type, Описание |
---|
url stringRequiredThe URL to which the payloads will be delivered. |
content_type stringThe media type used to serialize the payloads. Supported values include |
secret stringIf provided, the |
insecure_ssl stringDetermines whether the SSL certificate of the host for |
events
array of stringsThe events that trigger this webhook. A global webhook can be triggered by user
and organization
events. Default: user
and organization
.
active
booleanDetermines if notifications are sent when the webhook is triggered. Set to true
to send notifications.
Default: true
HTTP response status codes
Status code | Описание |
---|---|
201 | Created |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks \
-d '{"name":"web","events":["organization","user"],"config":{"url":"https://example.com/webhook","content_type":"json","secret":"secret"}}'
Response
Status: 201
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
Get a global webhook
Parameters
Headers |
---|
Имя, Type, Описание |
accept stringSetting to |
Path parameters |
Имя, Type, Описание |
hook_id integerRequiredThe unique identifier of the hook. |
HTTP response status codes
Status code | Описание |
---|---|
200 | OK |
Code samples
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID
Response
Status: 200
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
Update a global webhook
Parameters that are not provided will be overwritten with the default value or removed if no default exists.
Parameters
Headers | ||||||||
---|---|---|---|---|---|---|---|---|
Имя, Type, Описание | ||||||||
accept stringSetting to | ||||||||
Path parameters | ||||||||
Имя, Type, Описание | ||||||||
hook_id integerRequiredThe unique identifier of the hook. | ||||||||
Body parameters | ||||||||
Имя, Type, Описание | ||||||||
config objectKey/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Имя, Type, Описание |
---|
url stringRequiredThe URL to which the payloads will be delivered. |
content_type stringThe media type used to serialize the payloads. Supported values include |
secret stringIf provided, the |
insecure_ssl stringDetermines whether the SSL certificate of the host for |
events
array of stringsThe events that trigger this webhook. A global webhook can be triggered by user
and organization
events. Default: user
and organization
.
active
booleanDetermines if notifications are sent when the webhook is triggered. Set to true
to send notifications.
Default: true
HTTP response status codes
Status code | Описание |
---|---|
200 | OK |
Code samples
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID \
-d '{"events":["organization"],"config":{"url":"https://example.com/webhook"}}'
Response
Status: 200
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization"
],
"config": {
"url": "https://example.com",
"content_type": "form",
"insecure_ssl": "0"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
Delete a global webhook
Parameters
Headers |
---|
Имя, Type, Описание |
accept stringSetting to |
Path parameters |
Имя, Type, Описание |
hook_id integerRequiredThe unique identifier of the hook. |
HTTP response status codes
Status code | Описание |
---|---|
204 | No Content |
Code samples
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID
Response
Status: 204
Ping a global webhook
This will trigger a ping event to be sent to the webhook.
Parameters
Headers |
---|
Имя, Type, Описание |
accept stringSetting to |
Path parameters |
Имя, Type, Описание |
hook_id integerRequiredThe unique identifier of the hook. |
HTTP response status codes
Status code | Описание |
---|---|
204 | No Content |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID/pings
Response
Status: 204