Webhook API Documentation

1. List WebHooks of a Repository

Request

GET https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenquerystring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
pageCurrent Page Numberqueryint
per_pageItems Per Page, Maximum 100,default:20queryint

Response

[
  {
    "id": 9523,
    "url": "http://duxwsqdkyx.cu/pxssss",
    "password": "123445",
    "result": "not found",
    "project_id": 282463,
    "result_code": 503,
    "push_events": false,
    "tag_push_events": false,
    "issues_events": true,
    "note_events": false,
    "merge_requests_events": true,
    "created_at": "2024-09-18T17:51:44+08:00"
  }
]

Demo

curl --location --request GET 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks?access_token={your-token}'

2. Create a WebHook for a Repository

Request

POST https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenformDatastring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
url*urlformDatastring
encryption_typeEncryption Type: 0(Password), 1(Signature Key)formDataint
passwordThe password is included in the request URL to prevent malicious requests.formDatastring
push_eventsPush Code to Repository EventformDataboolean
tag_push_eventsTag Push to Repository EventformDataboolean
issues_eventsIssue Creation/Closure EventformDataboolean
note_eventsComment on Issue/PR/commit EventformDataboolean
merge_requests_eventsMerge Request Creation and Merging EventformDataboolean

Response

{
  "id": 9529,
  "url": "http://duxwsqdkyx.cu/pxddddd",
  "password": "123445",
  "result": null,
  "project_id": 282463,
  "result_code": 0,
  "push_events": false,
  "tag_push_events": false,
  "issues_events": true,
  "note_events": false,
  "merge_requests_events": true,
  "created_at": "2024-09-26T16:13:27+08:00"
}

Demo

curl --location --request POST 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks?access_token={your-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "http://duxwsqdkyx.cu/px",
    "encryption_type": 0,
    "password": "123445",
    "push_events": false,
    "tag_push_events": false,
    "issues_events": true,
    "note_events": false,
    "merge_requests_events": true
}'

3. Get a Specific WebHook of a Repository

Request

GET https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks/{id}

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenquerystring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
id*ID of Webhookpathstring

Response

{
  "id": 9529,
  "url": "http://duxwsqdkyx.cu/pxddddd",
  "password": "123445",
  "result": null,
  "project_id": 282463,
  "result_code": 0,
  "push_events": false,
  "tag_push_events": false,
  "issues_events": true,
  "note_events": false,
  "merge_requests_events": true,
  "created_at": "2024-09-26T16:13:27+08:00"
}

Demo

curl --location --request GET 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks/9524?access_token={your-token}'

4. Update a WebHook of a Repository

Request

PATCH https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks/{id}

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenquerystring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
id*ID of Webhookpathstring
url*urlformDatastring
encryption_typeEncryption Type: 0(Password), 1(Signature Key)formDataint
passwordThe password is included in the request URL to prevent malicious requests.formDatastring
push_eventsPush Code to Repository EventformDataboolean
tag_push_eventsTag Push to Repository EventformDataboolean
issues_eventsIssue Creation/Closure EventformDataboolean
note_eventsComment on Issue/PR/commit EventformDataboolean
merge_requests_eventsMerge Request Creation and Merging EventformDataboolean

Response

{
  "url": "http://duxwsqdkyx.cu/pxddddd",
  "password": "123445",
  "result": null,
  "project_id": 282463,
  "result_code": 0,
  "push_events": false,
  "tag_push_events": false,
  "issues_events": true,
  "note_events": false,
  "merge_requests_events": true,
  "created_at": "2024-09-26T16:13:27+08:00"
}

Demo

curl --location --request PATCH 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks/9516?access_token={your-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "http://duxwsqdkyx.cu/dengmm",
    "encryption_type": 0,
    "password": "334455",
    "push_events": true,
    "tag_push_events": true,
    "issues_events": false,
    "note_events": true,
    "merge_requests_events": true
}'

5. Delete a WebHook of a Repository

Request

DELETE https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks/{id}

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenquerystring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
id*ID of Webhookpathstring

Response

Http Code: 204, No Content

Demo

curl --location --request DELETE 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks/9516?access_token={your-token}'

6. Test if a WebHook is Successfully Sent

Request

POST https://api.gitcode.com/api/v5/repos/{owner}/{repo}/hooks/{id}/tests

Parameters

ParameterDescriptionTypeData Type
access_tokenpersonal access tokenquerystring
owner*Repository Ownership Path (Company, Organization, or Personal Path)pathstring
repo*Repository Path(path)pathstring
id*ID of Webhookpathstring

Response

Http Code: 204, No Content

Demo

curl --location --request POST 'https://api.gitcode.com/api/v5/repos/mactribe/test02/hooks/9516/tests?access_token={your-token}'