我们最近移动了一些 REST API 文档。 如果找不到要查找的内容,可以尝试 操作 REST API 页面。
全局 Webhook
使用 REST API 管理企业的全局 Webhook。
关于全局 web 挂钩
这些终结点仅供经过身份验证的站点管理员使用。普通用户将收到 404
响应。 若要了解如何配置全局 Webhook,请参阅关于全局 Webhook。
全局 webhook 会自动安装在企业中。 您可以使用全局 web 挂钩来自动监视、响应或实施针对企业上的用户、组织、团队和仓库的规则。
List global webhooks
“List global webhooks”的参数
标头 |
---|
名称, 类型, 说明 |
accept string Setting to |
查询参数 |
名称, 类型, 说明 |
per_page integer The number of results per page (max 100). 默认: |
page integer Page number of the results to fetch. 默认: |
“List global webhooks”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
“List global webhooks”的示例代码
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”的参数
标头 | ||||||||
---|---|---|---|---|---|---|---|---|
名称, 类型, 说明 | ||||||||
accept string Setting to | ||||||||
正文参数 | ||||||||
名称, 类型, 说明 | ||||||||
name string 必须Must be passed as "web". | ||||||||
config object 必须Key/value pairs to provide settings for this webhook. | ||||||||
Properties of |
名称, 类型, 说明 |
---|
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 |
secret string If provided, the |
insecure_ssl string Determines whether the SSL certificate of the host for |
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
“Create a global webhook”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
201 | Created |
“Create a global webhook”的示例代码
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”的参数
标头 |
---|
名称, 类型, 说明 |
accept string Setting to |
路径参数 |
名称, 类型, 说明 |
hook_id integer 必须The unique identifier of the hook. |
“Get a global webhook”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
“Get a global webhook”的示例代码
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”的参数
标头 | ||||||||
---|---|---|---|---|---|---|---|---|
名称, 类型, 说明 | ||||||||
accept string Setting to | ||||||||
路径参数 | ||||||||
名称, 类型, 说明 | ||||||||
hook_id integer 必须The unique identifier of the hook. | ||||||||
正文参数 | ||||||||
名称, 类型, 说明 | ||||||||
config object Key/value pairs to provide settings for this webhook. | ||||||||
Properties of |
名称, 类型, 说明 |
---|
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 |
secret string If provided, the |
insecure_ssl string Determines whether the SSL certificate of the host for |
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
“Update a global webhook”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
“Update a global webhook”的示例代码
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”的参数
标头 |
---|
名称, 类型, 说明 |
accept string Setting to |
路径参数 |
名称, 类型, 说明 |
hook_id integer 必须The unique identifier of the hook. |
“Delete a global webhook”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
204 | No Content |
“Delete a global webhook”的示例代码
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”的参数
标头 |
---|
名称, 类型, 说明 |
accept string Setting to |
路径参数 |
名称, 类型, 说明 |
hook_id integer 必须The unique identifier of the hook. |
“Ping a global webhook”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
204 | No Content |
“Ping a global webhook”的示例代码
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