Skip to main content

Выпуск GitHub AE сейчас ограничен.

Недавно мы переехали некоторые из документации по REST API. Если вы не можете найти нужные сведения, попробуйте воспользоваться страницей REST API Действия.

Глобальные веб-перехватчики

Используйте REST API для управления глобальными веб-перехватчиками для вашего предприятия.

About global webhooks

These endpoints are only available to authenticated site administrators Normal users will receive a 404 response. To learn how to configure global webhooks, see About global webhooks.

Global webhooks are automatically installed on your enterprise. You can use global webhooks to automatically monitor, respond to, or enforce rules for users, organizations, teams, and repositories on your enterprise.

Global webhooks can subscribe to the organization, user, repository, team, member, membership, fork, and ping event types.

List global webhooks

Параметры для "List global webhooks"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры запроса
Имя, Type, Description
per_page integer

The number of results per page (max 100).

По умолчанию.: 30

page integer

Page number of the results to fetch.

По умолчанию.: 1

Коды состояния http-ответа для "List global webhooks"

Код состоянияОписание
200

OK

Примеры кода для "List global webhooks"

get/admin/hooks
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://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

Параметры для "Create a global webhook"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры запроса
Имя, Type, Description
name string Обязательное поле

Must be passed as "web".

config object Обязательное поле

Key/value pairs to provide settings for this webhook.

Имя, Type, Description
url string Обязательное поле

The URL to which the payloads will be delivered.

content_type string

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

secret string

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl string

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.

events array of strings

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean

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

По умолчанию.: true

Коды состояния http-ответа для "Create a global webhook"

Код состоянияОписание
201

Created

Примеры кода для "Create a global webhook"

post/admin/hooks
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://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

Параметры для "Get a global webhook"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя, Type, Description
hook_id integer Обязательное поле

The unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Коды состояния http-ответа для "Get a global webhook"

Код состоянияОписание
200

OK

Примеры кода для "Get a global webhook"

get/admin/hooks/{hook_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://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.

Параметры для "Update a global webhook"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя, Type, Description
hook_id integer Обязательное поле

The unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Параметры запроса
Имя, Type, Description
config object

Key/value pairs to provide settings for this webhook.

Имя, Type, Description
url string Обязательное поле

The URL to which the payloads will be delivered.

content_type string

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

secret string

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl string

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.

events array of strings

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean

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

По умолчанию.: true

Коды состояния http-ответа для "Update a global webhook"

Код состоянияОписание
200

OK

Примеры кода для "Update a global webhook"

patch/admin/hooks/{hook_id}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://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

Параметры для "Delete a global webhook"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя, Type, Description
hook_id integer Обязательное поле

The unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Коды состояния http-ответа для "Delete a global webhook"

Код состоянияОписание
204

No Content

Примеры кода для "Delete a global webhook"

delete/admin/hooks/{hook_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://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.

Параметры для "Ping a global webhook"

Заголовки
Имя, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя, Type, Description
hook_id integer Обязательное поле

The unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Коды состояния http-ответа для "Ping a global webhook"

Код состоянияОписание
204

No Content

Примеры кода для "Ping a global webhook"

post/admin/hooks/{hook_id}/pings
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/admin/hooks/HOOK_ID/pings

Response

Status: 204