Nous avons récemment déplacé une partie de la documentation de l’API REST. Si vous ne trouvez pas ce que vous recherchez, vous pouvez essayer la page d’API REST Actions.
Webhooks globaux
Utilisez l’API REST pour gérer les webhooks globaux pour votre entreprise.
À propos des webhooks globaux
Ces points de terminaison sont disponibles uniquement pour les administrateurs de sites authentifiés. Les utilisateurs normaux recevront une réponse 404
. Pour savoir comment configurer des webhooks globaux, consultez À propos des webhooks globaux.
Les webhooks globaux sont installés automatiquement sur votre entreprise. Vous pouvez utiliser des webhooks globaux pour surveiller, répondre ou appliquer automatiquement des règles pour les utilisateurs, les organisations, les équipes et les référentiels de votre entreprise.
Les webhooks globaux peuvent s’abonner aux types d’événements organisation, utilisateur, référentiel, équipe, membre, appartenance, duplication et ping.
List global webhooks
Paramètres pour « List global webhooks »
En-têtes |
---|
Nom, Type, Description |
accept stringSetting to |
Paramètres de requête |
Nom, Type, Description |
per_page integerThe number of results per page (max 100). Default: |
page integerPage number of the results to fetch. Default: |
Codes d’état de la réponse HTTP pour « List global webhooks »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « 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
Paramètres pour « Create a global webhook »
En-têtes | ||||||||
---|---|---|---|---|---|---|---|---|
Nom, Type, Description | ||||||||
accept stringSetting to | ||||||||
Paramètres du corps | ||||||||
Nom, Type, Description | ||||||||
name stringObligatoireMust be passed as "web". | ||||||||
config objectObligatoireKey/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Nom, Type, Description |
---|
url stringObligatoireThe 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.
Default: true
Codes d’état de la réponse HTTP pour « Create a global webhook »
Code d’état | Description |
---|---|
201 | Created |
Exemples de code pour « 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
Paramètres pour « Get a global webhook »
En-têtes |
---|
Nom, Type, Description |
accept stringSetting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
hook_id integerObligatoireThe unique identifier of the hook. |
Codes d’état de la réponse HTTP pour « Get a global webhook »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « 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.
Paramètres pour « Update a global webhook »
En-têtes | ||||||||
---|---|---|---|---|---|---|---|---|
Nom, Type, Description | ||||||||
accept stringSetting to | ||||||||
Paramètres de chemin d’accès | ||||||||
Nom, Type, Description | ||||||||
hook_id integerObligatoireThe unique identifier of the hook. | ||||||||
Paramètres du corps | ||||||||
Nom, Type, Description | ||||||||
config objectKey/value pairs to provide settings for this webhook. | ||||||||
Properties of |
Nom, Type, Description |
---|
url stringObligatoireThe 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.
Default: true
Codes d’état de la réponse HTTP pour « Update a global webhook »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « 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
Paramètres pour « Delete a global webhook »
En-têtes |
---|
Nom, Type, Description |
accept stringSetting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
hook_id integerObligatoireThe unique identifier of the hook. |
Codes d’état de la réponse HTTP pour « Delete a global webhook »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « 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.
Paramètres pour « Ping a global webhook »
En-têtes |
---|
Nom, Type, Description |
accept stringSetting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
hook_id integerObligatoireThe unique identifier of the hook. |
Codes d’état de la réponse HTTP pour « Ping a global webhook »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « 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