CreateWebHook - Create Webhook
Create a webhook for a code repository to receive event notifications.
|
Applicable editions |
Central edition, Region edition |
Service Endpoints and Authorization Information
- Get service endpoint: Replace {domain} in the request URL with your service endpoint.
- Get personal access token.
- Obtain the organization ID: Required only for Central edition. Go to the Basic Information page in the Organization Management console.
|
Product |
Resource |
Required Permissions |
|
Code Management |
Webhook |
Read/Write |
Request Syntax
Central edition
POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/webhooks
Region edition
POST https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/webhooks
Request Headers
|
Parameter |
Type |
Required |
Description |
Example Value |
|
x-yunxiao-token |
string |
Yes |
Personal access token. |
pt-0fh3****0fbG_35af****0484 |
Request Parameters
|
Parameter |
Type |
Location |
Required |
Description |
Example Value |
|
organizationId |
string |
path |
|
Organization ID. |
60d54f3daccf2bbd6659f3ad |
|
repositoryId |
string |
path |
Yes |
Repository ID or URL-encoded full path. |
2813489 or 60de7a6852743a5162b5f957%2FDemoRepo |
| - |
object |
body |
No |
|
|
| description |
string |
body |
No |
Webhook description. |
Description content |
| enableSslVerification |
boolean |
body |
No |
Whether to enable SSL verification. |
false |
| mergeRequestsEvents |
boolean |
body |
No |
Whether to trigger on merge request events. |
true |
| noteEvents |
boolean |
body |
No |
Whether to trigger on note events. |
true |
| pushEvents |
boolean |
body |
No |
Whether to trigger on push events. |
true |
| tagPushEvents |
boolean |
body |
No |
Whether to trigger on tag push events. |
true |
| token |
string |
body |
No |
User-defined token for identity verification. |
xxx |
| url |
string |
body |
Yes |
Webhook callback URL, generally no more than 1024 characters. |
http://example/example |
Request Examples
Central edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/webhooks' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"description": "Description content",
"enableSslVerification": false,
"mergeRequestsEvents": true,
"noteEvents": true,
"pushEvents": true,
"tagPushEvents": true,
"token": "xxx",
"url": "http://example/example"
}'
Region edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/webhooks' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"description": "Description content",
"enableSslVerification": false,
"mergeRequestsEvents": true,
"noteEvents": true,
"pushEvents": true,
"tagPushEvents": true,
"token": "xxx",
"url": "http://example/example"
}'
Response Parameters
|
Parameter |
Type |
Description |
Example Value |
| - |
object |
|
|
| createdAt |
string |
Creation time. |
2024-10-05T15:30:45Z |
| description |
string |
Webhook description. |
Description content |
| enableSSLVerification |
boolean |
Whether SSL verification is enabled. |
false |
| id |
integer |
Webhook ID. |
1 |
| mergeRequestEvents |
boolean |
Whether merge request events are enabled. |
true |
| noteEvents |
boolean |
Whether note events are enabled. |
true |
| pushEvents |
boolean |
Whether push events are enabled. |
true |
| repositoryId |
integer |
Repository ID. |
1 |
| tagPushEvents |
boolean |
Whether tag push events are enabled. |
true |
| token |
string |
User-defined token for identity verification. |
xxx |
| updatedAt |
string |
Update time. |
2024-10-05T15:30:45Z |
| url |
string |
Webhook URL. |
http://example/example |
Response Example
{
"createdAt": "2024-10-05T15:30:45Z",
"description": "Description content",
"enableSSLVerification": false,
"id": 1,
"mergeRequestEvents": true,
"noteEvents": true,
"pushEvents": true,
"repositoryId": 1,
"tagPushEvents": true,
"token": "xxx",
"updatedAt": "2024-10-05T15:30:45Z",
"url": "http://example/example"
}
Error Codes
For API error codes, see the Error Code Center.