Skip to main content

Atualmente o GitHub AE está em versão limitada.

Recentemente, movemos algumas das documentações da API REST. Se você não conseguir encontrar o que está procurando, tente a página da API REST Ações.

Webhooks globais

Use a API REST para gerenciar webhooks globais para sua empresa.

Sobre webhooks globais

Esses pontos de extremidade só estão disponíveis para administradores de site autenticados Os usuários normais receberão uma resposta 404. Para saber como configurar webhooks globais, confira Sobre os webhooks globais.

Webhooks globais são instalados automaticamente 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.

Os webhooks globais podem se inscrever nos tipos de eventos organização, usuário, repositório, equipe, membro, associação, fork e ping.

List global webhooks

Parâmetros para "List global webhooks"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros de consulta
Nome, Type, Descrição
per_page integer

The number of results per page (max 100).

Padrão: 30

page integer

Page number of the results to fetch.

Padrão: 1

Códigos de status de resposta HTTP para "List global webhooks"

Código de statusDescrição
200

OK

Exemplos de código para "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

Parâmetros para "Create a global webhook"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros do corpo
Nome, Type, Descrição
name string Obrigatório

Must be passed as "web".

config object Obrigatório

Key/value pairs to provide settings for this webhook.

Nome, Type, Descrição
url string Obrigatório

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.

Padrão: true

Códigos de status de resposta HTTP para "Create a global webhook"

Código de statusDescrição
201

Created

Exemplos de código para "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

Parâmetros para "Get a global webhook"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros de caminho
Nome, Type, Descrição
hook_id integer Obrigatório

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

Códigos de status de resposta HTTP para "Get a global webhook"

Código de statusDescrição
200

OK

Exemplos de código para "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.

Parâmetros para "Update a global webhook"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros de caminho
Nome, Type, Descrição
hook_id integer Obrigatório

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

Parâmetros do corpo
Nome, Type, Descrição
config object

Key/value pairs to provide settings for this webhook.

Nome, Type, Descrição
url string Obrigatório

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.

Padrão: true

Códigos de status de resposta HTTP para "Update a global webhook"

Código de statusDescrição
200

OK

Exemplos de código para "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

Parâmetros para "Delete a global webhook"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros de caminho
Nome, Type, Descrição
hook_id integer Obrigatório

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

Códigos de status de resposta HTTP para "Delete a global webhook"

Código de statusDescrição
204

No Content

Exemplos de código para "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.

Parâmetros para "Ping a global webhook"

Cabeçalhos
Nome, Type, Descrição
accept string

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

Parâmetros de caminho
Nome, Type, Descrição
hook_id integer Obrigatório

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

Códigos de status de resposta HTTP para "Ping a global webhook"

Código de statusDescrição
204

No Content

Exemplos de código para "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