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.
Webhooks globais
Os webhooks globais são instalados na sua empresa. Você pode usar webhooks globais para monitorar, responder ou aplicar regras automaticamente para usuários, organizações, equipes e repositórios na sua empresa.
Webhooks globais podem se inscrever para os tipos de eventos organização, usuário, repositório, equipe, integrante, filiação, bifurcaçãoe ping.
Esta API está disponível somente para administradores do site autenticados. Usuários normais receberão uma mensagem 404 se tentarem acessá-la. Para aprender como configurar webhooks globais, consulte Sobre webhooks globais.
List global webhooks
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Parâmetros de consulta |
| Nome, Tipo, Descrição |
per_pageintegerThe number of results per page (max 100). Padrão: |
pageintegerPage number of the results to fetch. Padrão: |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://HOSTNAME/api/v3/admin/hooksResponse
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
Parâmetros
| Headers | ||||||||
|---|---|---|---|---|---|---|---|---|
| Nome, Tipo, Descrição | ||||||||
acceptstringSetting to | ||||||||
| Body parameters | ||||||||
| Nome, Tipo, Descrição | ||||||||
namestringObrigatórioMust be passed as "web". | ||||||||
configobjectObrigatórioKey/value pairs to provide settings for this webhook. | ||||||||
Properties of the | ||||||||
| Nome, Tipo, Descrição |
|---|
urlstringObrigatórioThe URL to which the payloads will be delivered. |
content_typestringThe media type used to serialize the payloads. Supported values include |
secretstringIf provided, the |
insecure_sslstringDetermines whether the SSL certificate of the host for |
eventsarray of stringsThe events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.
activebooleanDetermines if notifications are sent when the webhook is triggered. Set to true to send notifications.
Padrão: true
HTTP response status codes
| Status code | Descrição |
|---|---|
201 | Created |
Amostras de código
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <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
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
hook_idintegerObrigatórioThe unique identifier of the hook. |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://HOSTNAME/api/v3/admin/hooks/HOOK_IDResponse
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.
Parâmetros
| Headers | ||||||||
|---|---|---|---|---|---|---|---|---|
| Nome, Tipo, Descrição | ||||||||
acceptstringSetting to | ||||||||
| Path parameters | ||||||||
| Nome, Tipo, Descrição | ||||||||
hook_idintegerObrigatórioThe unique identifier of the hook. | ||||||||
| Body parameters | ||||||||
| Nome, Tipo, Descrição | ||||||||
configobjectKey/value pairs to provide settings for this webhook. | ||||||||
Properties of the | ||||||||
| Nome, Tipo, Descrição |
|---|
urlstringObrigatórioThe URL to which the payloads will be delivered. |
content_typestringThe media type used to serialize the payloads. Supported values include |
secretstringIf provided, the |
insecure_sslstringDetermines whether the SSL certificate of the host for |
eventsarray of stringsThe events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.
activebooleanDetermines if notifications are sent when the webhook is triggered. Set to true to send notifications.
Padrão: true
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <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
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
hook_idintegerObrigatórioThe unique identifier of the hook. |
HTTP response status codes
| Status code | Descrição |
|---|---|
204 | No Content |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://HOSTNAME/api/v3/admin/hooks/HOOK_IDResponse
Status: 204Ping a global webhook
This will trigger a ping event to be sent to the webhook.
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
hook_idintegerObrigatórioThe unique identifier of the hook. |
HTTP response status codes
| Status code | Descrição |
|---|---|
204 | No Content |
Amostras de código
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://HOSTNAME/api/v3/admin/hooks/HOOK_ID/pingsResponse
Status: 204