2020-10-28 15:08:49 +00:00
---
2021-08-02 15:08:56 +00:00
stage: Ecosystem
group: Integrations
2020-11-26 06:09:20 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-28 15:08:49 +00:00
---
2021-09-09 12:09:09 +00:00
# System hooks API **(FREE SELF)**
2014-05-27 12:12:15 +00:00
2016-01-24 19:19:46 +00:00
All methods require administrator authorization.
2014-03-14 18:53:43 +00:00
2021-06-14 00:09:37 +00:00
You can configure the URL endpoint of the system hooks from the GitLab user interface:
2021-08-26 00:09:31 +00:00
1. On the top bar, select **Menu > Admin** .
2021-06-14 00:09:37 +00:00
1. Select **System Hooks** (`/admin/hooks`).
2016-01-24 19:19:46 +00:00
2022-03-18 09:07:21 +00:00
Read more about [system hooks ](../administration/system_hooks.md ).
2014-03-14 18:53:43 +00:00
## List system hooks
2016-01-18 08:45:50 +00:00
Get a list of all system hooks.
2014-03-14 18:53:43 +00:00
2020-02-29 03:07:51 +00:00
```plaintext
2014-03-14 18:53:43 +00:00
GET /hooks
```
2016-01-24 19:19:46 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/hooks"
2016-01-18 08:45:50 +00:00
```
2014-03-14 18:53:43 +00:00
2016-01-18 08:45:50 +00:00
Example response:
2014-03-14 18:53:43 +00:00
```json
[
2016-10-19 14:08:30 +00:00
{
"id":1,
"url":"https://gitlab.example.com/hook",
"created_at":"2016-10-31T12:32:15.192Z",
"push_events":true,
"tag_push_events":false,
2017-11-23 15:45:00 +00:00
"merge_requests_events": true,
2018-08-14 18:55:55 +00:00
"repository_update_events": true,
2016-10-19 14:08:30 +00:00
"enable_ssl_verification":true
}
2014-03-14 18:53:43 +00:00
]
```
2022-02-28 18:14:03 +00:00
## Get system hook
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81595) in GitLab 14.9.
Get a system hook by its ID.
```plaintext
GET /hooks/:id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of the hook |
Example request:
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/hooks/1"
```
Example response:
```json
[
{
"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
}
]
```
2016-01-18 08:45:50 +00:00
## Add new system hook
2014-03-14 18:53:43 +00:00
2016-01-24 19:19:46 +00:00
Add a new system hook.
2020-02-29 03:07:51 +00:00
```plaintext
2014-03-14 18:53:43 +00:00
POST /hooks
```
2016-01-18 08:45:50 +00:00
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `url` | string | yes | The hook URL |
2020-11-19 21:09:07 +00:00
| `token` | string | no | Secret token to validate received payloads; this isn't returned in the response |
| `push_events` | boolean | no | When true, the hook fires on push events |
| `tag_push_events` | boolean | no | When true, the hook fires on new tags being pushed |
2017-11-23 20:36:58 +00:00
| `merge_requests_events` | boolean | no | Trigger hook on merge requests events |
2018-08-14 18:55:55 +00:00
| `repository_update_events` | boolean | no | Trigger hook on repository update events |
2016-11-02 12:24:24 +00:00
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
2016-01-18 08:45:50 +00:00
2016-01-24 19:19:46 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2018-12-27 09:03:08 +00:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/hooks?url=https://gitlab.example.com/hook"
2016-01-18 08:45:50 +00:00
```
2014-03-14 18:53:43 +00:00
2016-01-18 08:45:50 +00:00
Example response:
```json
[
2016-10-19 14:08:30 +00:00
{
"id":1,
"url":"https://gitlab.example.com/hook",
"created_at":"2016-10-31T12:32:15.192Z",
"push_events":true,
"tag_push_events":false,
2017-11-23 20:36:58 +00:00
"merge_requests_events": true,
2018-08-14 18:55:55 +00:00
"repository_update_events": true,
2016-10-19 14:08:30 +00:00
"enable_ssl_verification":true
}
2016-01-18 08:45:50 +00:00
]
```
2014-03-14 18:53:43 +00:00
## Test system hook
2020-02-29 03:07:51 +00:00
```plaintext
2021-03-31 18:09:19 +00:00
POST /hooks/:id
2014-03-14 18:53:43 +00:00
```
2016-01-18 08:45:50 +00:00
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of the hook |
2014-03-14 18:53:43 +00:00
2016-01-24 19:19:46 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2021-03-31 18:09:19 +00:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/hooks/1"
2016-01-18 08:45:50 +00:00
```
Example response:
2014-03-14 18:53:43 +00:00
```json
{
2016-01-18 08:45:50 +00:00
"project_id" : 1,
"owner_email" : "example@gitlabhq.com",
"owner_name" : "Someone",
"name" : "Ruby",
"path" : "ruby",
"event_name" : "project_create"
2014-03-14 18:53:43 +00:00
}
```
## Delete system hook
2016-11-24 17:28:52 +00:00
Deletes a system hook.
2016-01-24 19:19:46 +00:00
2020-02-29 03:07:51 +00:00
```plaintext
2014-03-14 18:53:43 +00:00
DELETE /hooks/:id
```
2016-01-18 08:45:50 +00:00
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of the hook |
2016-01-24 19:19:46 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/hooks/2"
2019-07-15 01:04:35 +00:00
```