此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 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.
全局 web 挂钩
全局 web 挂钩安装在企业上。 您可以使用全局 web 挂钩来自动监视、响应或实施针对企业上的用户、组织、团队和仓库的规则。
全局 web 挂钩可以订阅组织、用户、仓库、团队、成员、成员身份、复刻和 ping 事件类型。
此 API 只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404
响应。 要了解如何配置全局 web 挂钩,请参阅关于全局 web 挂钩。
List global webhooks
参数
� �头 |
---|
名称, 类型, 描述 |
accept stringSetting to |
查询参数 |
名称, 类型, 描述 |
per_page integerThe number of results per page (max 100). 默认值: |
page integerPage number of the results to fetch. 默认值: |
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
200 | OK |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <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"
}
]
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
Create a global webhook
参数
� �头 | ||||||||
---|---|---|---|---|---|---|---|---|
名称, 类型, 描述 | ||||||||
accept stringSetting to | ||||||||
正文参数 | ||||||||
名称, 类型, 描述 | ||||||||
name string必选Must be passed as "web". | ||||||||
config object必选Key/value pairs to provide settings for this webhook. | ||||||||
Properties of the |
名称, 类型, 描述 |
---|
url string必选The 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.
默认值: true
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
201 | Created |
代� �示例
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <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"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
Get a global webhook
参数
� �头 |
---|
名称, 类型, 描述 |
accept stringSetting to |
路径参数 |
名称, 类型, 描述 |
hook_id integer必选The unique identifier of the hook. |
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
200 | OK |
代� �示例
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <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"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
Update a global webhook
Parameters that are not provided will be overwritten with the default value or removed if no default exists.
参数
� �头 | ||||||||
---|---|---|---|---|---|---|---|---|
名称, 类型, 描述 | ||||||||
accept stringSetting to | ||||||||
路径参数 | ||||||||
名称, 类型, 描述 | ||||||||
hook_id integer必选The unique identifier of the hook. | ||||||||
正文参数 | ||||||||
名称, 类型, 描述 | ||||||||
config objectKey/value pairs to provide settings for this webhook. | ||||||||
Properties of the |
名称, 类型, 描述 |
---|
url string必选The 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.
默认值: true
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
200 | OK |
代� �示例
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <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"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
Delete a global webhook
参数
� �头 |
---|
名称, 类型, 描述 |
accept stringSetting to |
路径参数 |
名称, 类型, 描述 |
hook_id integer必选The unique identifier of the hook. |
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
204 | No Content |
代� �示例
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID
Response
Status: 204
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
Ping a global webhook
This will trigger a ping event to be sent to the webhook.
参数
� �头 |
---|
名称, 类型, 描述 |
accept stringSetting to |
路径参数 |
名称, 类型, 描述 |
hook_id integer必选The unique identifier of the hook. |
HTTP 响应状态代� �
状态代� � | 描述 |
---|---|
204 | No Content |
代� �示例
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/hooks/HOOK_ID/pings
Response
Status: 204
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json