2014-05-27 08:12:15 -04:00
|
|
|
# System hooks
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
All methods require administrator authorization.
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
The URL endpoint of the system hooks can also be configured using the UI in
|
2016-01-24 14:19:46 -05:00
|
|
|
the admin area under **Hooks** (`/admin/hooks`).
|
|
|
|
|
|
|
|
Read more about [system hooks](../system_hooks/system_hooks.md).
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
## List system hooks
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Get a list of all system hooks.
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
---
|
|
|
|
|
2014-03-14 14:53:43 -04:00
|
|
|
```
|
|
|
|
GET /hooks
|
|
|
|
```
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Example response:
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2016-01-18 03:45:50 -05:00
|
|
|
{
|
|
|
|
"id" : 1,
|
|
|
|
"url" : "https://gitlab.example.com/hook",
|
|
|
|
"created_at" : "2015-11-04T20:07:35.874Z"
|
|
|
|
}
|
2014-03-14 14:53:43 -04:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
## Add new system hook
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Add a new system hook.
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2014-03-14 14:53:43 -04:00
|
|
|
```
|
|
|
|
POST /hooks
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `url` | string | yes | The hook URL |
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/hooks?url=https://gitlab.example.com/hook"
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id" : 2,
|
|
|
|
"url" : "https://gitlab.example.com/hook",
|
|
|
|
"created_at" : "2015-11-04T20:07:35.874Z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
## Test system hook
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /hooks/:id
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `id` | integer | yes | The ID of the hook |
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2016-01-18 03:45:50 -05:00
|
|
|
"project_id" : 1,
|
|
|
|
"owner_email" : "example@gitlabhq.com",
|
|
|
|
"owner_name" : "Someone",
|
|
|
|
"name" : "Ruby",
|
|
|
|
"path" : "ruby",
|
|
|
|
"event_name" : "project_create"
|
2014-03-14 14:53:43 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete system hook
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Deletes a system hook. This is an idempotent API function and returns `200 OK`
|
2016-01-24 14:19:46 -05:00
|
|
|
even if the hook is not available.
|
|
|
|
|
|
|
|
If the hook is deleted, a JSON object is returned. An error is raised if the
|
|
|
|
hook is not found.
|
|
|
|
|
|
|
|
---
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
DELETE /hooks/:id
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `id` | integer | yes | The ID of the hook |
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"note_events" : false,
|
|
|
|
"project_id" : null,
|
|
|
|
"enable_ssl_verification" : true,
|
|
|
|
"url" : "https://gitlab.example.com/hook",
|
|
|
|
"updated_at" : "2015-11-04T20:12:15.931Z",
|
|
|
|
"issues_events" : false,
|
|
|
|
"merge_requests_events" : false,
|
|
|
|
"created_at" : "2015-11-04T20:12:15.931Z",
|
|
|
|
"service_id" : null,
|
|
|
|
"id" : 2,
|
|
|
|
"push_events" : true,
|
|
|
|
"tag_push_events" : false
|
|
|
|
}
|
|
|
|
```
|