企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# System hooks API > 原文:[https://docs.gitlab.com/ee/api/system_hooks.html](https://docs.gitlab.com/ee/api/system_hooks.html) * [List system hooks](#list-system-hooks) * [Add new system hook](#add-new-system-hook) * [Test system hook](#test-system-hook) * [Delete system hook](#delete-system-hook) # System hooks API[](#system-hooks-api "Permalink") 所有方法都需要管理员授权. 也可以使用**Admin Area> System Hooks** ( `/admin/hooks` )中的 UI 来配置系统挂钩的 URL 端点. 阅读有关[系统挂钩的](../system_hooks/system_hooks.html)更多信息. ## List system hooks[](#list-system-hooks "Permalink") 获取所有系统挂钩的列表. ``` GET /hooks ``` 请求示例: ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks" ``` 响应示例: ``` [ { "id":1, "url":"https://gitlab.example.com/hook", "created_at":"2016-10-31T12:32:15.192Z", "push_events":true, "tag_push_events":false, "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true } ] ``` ## Add new system hook[](#add-new-system-hook "Permalink") 添加一个新的系统挂钩. ``` POST /hooks ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `url` | string | yes | 挂钩网址 | | `token` | string | no | 用于验证收到的有效载荷的秘密令牌; 这将不会在响应中返回 | | `push_events` | boolean | no | 设置为 true 时,挂钩将在推送事件时触发 | | `tag_push_events` | boolean | no | 设置为 true 时,挂钩将在被推送的新标签上触发 | | `merge_requests_events` | boolean | no | 触发合并请求事件的钩子 | | `repository_update_events` | boolean | no | 触发挂钩存储库更新事件 | | `enable_ssl_verification` | boolean | no | 触发挂钩时执行 SSL 验证 | 请求示例: ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks?url=https://gitlab.example.com/hook" ``` 响应示例: ``` [ { "id":1, "url":"https://gitlab.example.com/hook", "created_at":"2016-10-31T12:32:15.192Z", "push_events":true, "tag_push_events":false, "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true } ] ``` ## Test system hook[](#test-system-hook "Permalink") ``` GET /hooks/:id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer | yes | 钩子的 ID | 请求示例: ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/2" ``` 响应示例: ``` { "project_id" : 1, "owner_email" : "example@gitlabhq.com", "owner_name" : "Someone", "name" : "Ruby", "path" : "ruby", "event_name" : "project_create" } ``` ## Delete system hook[](#delete-system-hook "Permalink") 删除系统挂钩. ``` DELETE /hooks/:id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer | yes | 钩子的 ID | 请求示例: ``` curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/2" ```