Recientemente hemos movido parte de la documentación de la API REST. Si no encuentras lo que estás buscando, puedes probar la página de la API REST Acciones.
Webhooks globales
Usa la API de REST para administrar webhooks globales para tu empresa.
Acerca de los webhooks locales
Estos puntos de conexión solo están disponibles para los administradores de sitios autenticados. Los usuarios normales recibirán una respuesta 404
. Para obtener información sobre cómo configurar webhooks globales, vea Acerca de los webhooks globales.
Los webhooks globales se instalan automáticamente en tu empresa. Puedes utilizar los webhooks globales para monitorear, responder a, o requerir las reglas para los usuarios, organizaciones, equipos y repositorios en tu empresa.
Los webhooks globales se pueden suscribir a los tipos de eventos de organización, usuario, repositorio, equipo, miembro, pertenencia, bifurcación y ping.
List global webhooks
Parámetros para "List global webhooks"
Encabezados |
---|
Nombre, Tipo, Descripción |
accept string Setting to |
Parámetros de consulta |
Nombre, Tipo, Descripción |
per_page integer The number of results per page (max 100). Valor predeterminado: |
page integer Page number of the results to fetch. Valor predeterminado: |
Códigos de estado de respuesta HTTP para "List global webhooks"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "List global webhooks"
curl -L \
-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://HOSTNAME/admin/hooks/1",
"ping_url": "https://HOSTNAME/admin/hooks/1/pings"
}
]
Create a global webhook
Parámetros para "Create a global webhook"
Encabezados | ||||||||
---|---|---|---|---|---|---|---|---|
Nombre, Tipo, Descripción | ||||||||
accept string Setting to | ||||||||
Parámetros del cuerpo | ||||||||
Nombre, Tipo, Descripción | ||||||||
name string RequeridoMust be passed as "web". | ||||||||
config object RequeridoKey/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Nombre, Tipo, Descripción |
---|
url string RequeridoThe 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.
Valor predeterminado: true
Códigos de estado de respuesta HTTP para "Create a global webhook"
status code | Descripción |
---|---|
201 | Created |
Ejemplos de código para "Create a global webhook"
curl -L \
-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://HOSTNAME/admin/hooks/1",
"ping_url": "https://HOSTNAME/admin/hooks/1/pings"
}
Get a global webhook
Parámetros para "Get a global webhook"
Encabezados |
---|
Nombre, Tipo, Descripción |
accept string Setting to |
Parámetros de la ruta de acceso |
Nombre, Tipo, Descripción |
hook_id integer RequeridoThe unique identifier of the hook. |
Códigos de estado de respuesta HTTP para "Get a global webhook"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a global webhook"
curl -L \
-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://HOSTNAME/admin/hooks/1",
"ping_url": "https://HOSTNAME/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.
Parámetros para "Update a global webhook"
Encabezados | ||||||||
---|---|---|---|---|---|---|---|---|
Nombre, Tipo, Descripción | ||||||||
accept string Setting to | ||||||||
Parámetros de la ruta de acceso | ||||||||
Nombre, Tipo, Descripción | ||||||||
hook_id integer RequeridoThe unique identifier of the hook. | ||||||||
Parámetros del cuerpo | ||||||||
Nombre, Tipo, Descripción | ||||||||
config object Key/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Nombre, Tipo, Descripción |
---|
url string RequeridoThe 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.
Valor predeterminado: true
Códigos de estado de respuesta HTTP para "Update a global webhook"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Update a global webhook"
curl -L \
-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://HOSTNAME/admin/hooks/1",
"ping_url": "https://HOSTNAME/admin/hooks/1/pings"
}
Delete a global webhook
Parámetros para "Delete a global webhook"
Encabezados |
---|
Nombre, Tipo, Descripción |
accept string Setting to |
Parámetros de la ruta de acceso |
Nombre, Tipo, Descripción |
hook_id integer RequeridoThe unique identifier of the hook. |
Códigos de estado de respuesta HTTP para "Delete a global webhook"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Delete a global webhook"
curl -L \
-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.
Parámetros para "Ping a global webhook"
Encabezados |
---|
Nombre, Tipo, Descripción |
accept string Setting to |
Parámetros de la ruta de acceso |
Nombre, Tipo, Descripción |
hook_id integer RequeridoThe unique identifier of the hook. |
Códigos de estado de respuesta HTTP para "Ping a global webhook"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Ping a global webhook"
curl -L \
-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