|
1 | 1 | # System hooks
|
2 | 2 |
|
3 |
| -All methods require admin authorization. |
| 3 | +All methods require administrator authorization. |
4 | 4 |
|
5 |
| -The URL endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks). |
| 5 | +The URL endpoint of the system hooks can also be configured using the UI in |
| 6 | +the admin area under **Hooks** (`/admin/hooks`). |
| 7 | + |
| 8 | +Read more about [system hooks](../system_hooks/system_hooks.md). |
6 | 9 |
|
7 | 10 | ## List system hooks
|
8 | 11 |
|
9 |
| -Get list of system hooks |
| 12 | +Get a list of all system hooks. |
| 13 | + |
| 14 | +--- |
10 | 15 |
|
11 | 16 | ```
|
12 | 17 | GET /hooks
|
13 | 18 | ```
|
14 | 19 |
|
15 |
| -Parameters: |
| 20 | +Example request: |
| 21 | + |
| 22 | +```bash |
| 23 | +curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks |
| 24 | +``` |
16 | 25 |
|
17 |
| -- **none** |
| 26 | +Example response: |
18 | 27 |
|
19 | 28 | ```json
|
20 | 29 | [
|
21 |
| - { |
22 |
| - "id": 3, |
23 |
| - "url": "http://example.com/hook", |
24 |
| - "created_at": "2013-10-02T10:15:31Z" |
25 |
| - } |
| 30 | + { |
| 31 | + "id" : 1, |
| 32 | + "url" : "https://gitlab.example.com/hook", |
| 33 | + "created_at" : "2015-11-04T20:07:35.874Z" |
| 34 | + } |
26 | 35 | ]
|
27 | 36 | ```
|
28 | 37 |
|
29 |
| -## Add new system hook hook |
| 38 | +## Add new system hook |
| 39 | + |
| 40 | +Add a new system hook. |
| 41 | + |
| 42 | +--- |
30 | 43 |
|
31 | 44 | ```
|
32 | 45 | POST /hooks
|
33 | 46 | ```
|
34 | 47 |
|
35 |
| -Parameters: |
| 48 | +| Attribute | Type | Required | Description | |
| 49 | +| --------- | ---- | -------- | ----------- | |
| 50 | +| `url` | string | yes | The hook URL | |
| 51 | + |
| 52 | +Example request: |
| 53 | + |
| 54 | +```bash |
| 55 | +curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/hooks?url=https://gitlab.example.com/hook" |
| 56 | +``` |
| 57 | + |
| 58 | +Example response: |
36 | 59 |
|
37 |
| -- `url` (required) - The hook URL |
| 60 | +```json |
| 61 | +[ |
| 62 | + { |
| 63 | + "id" : 2, |
| 64 | + "url" : "https://gitlab.example.com/hook", |
| 65 | + "created_at" : "2015-11-04T20:07:35.874Z" |
| 66 | + } |
| 67 | +] |
| 68 | +``` |
38 | 69 |
|
39 | 70 | ## Test system hook
|
40 | 71 |
|
41 | 72 | ```
|
42 | 73 | GET /hooks/:id
|
43 | 74 | ```
|
44 | 75 |
|
45 |
| -Parameters: |
| 76 | +| Attribute | Type | Required | Description | |
| 77 | +| --------- | ---- | -------- | ----------- | |
| 78 | +| `id` | integer | yes | The ID of the hook | |
46 | 79 |
|
47 |
| -- `id` (required) - The ID of hook |
| 80 | +Example request: |
| 81 | + |
| 82 | +```bash |
| 83 | +curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2 |
| 84 | +``` |
| 85 | + |
| 86 | +Example response: |
48 | 87 |
|
49 | 88 | ```json
|
50 | 89 | {
|
51 |
| - "event_name": "project_create", |
52 |
| - "name": "Ruby", |
53 |
| - "path": "ruby", |
54 |
| - "project_id": 1, |
55 |
| - "owner_name": "Someone", |
56 |
| - "owner_email": "[email protected]" |
| 90 | + "project_id" : 1, |
| 91 | + "owner_email" : "[email protected]", |
| 92 | + "owner_name" : "Someone", |
| 93 | + "name" : "Ruby", |
| 94 | + "path" : "ruby", |
| 95 | + "event_name" : "project_create" |
57 | 96 | }
|
58 | 97 | ```
|
59 | 98 |
|
60 | 99 | ## Delete system hook
|
61 | 100 |
|
62 |
| -Deletes a system hook. This is an idempotent API function and returns `200 OK` even if the hook is not available. If the hook is deleted it is also returned as JSON. |
| 101 | +Deletes a system hook. This is an idempotent API function and returns `200 OK` |
| 102 | +even if the hook is not available. |
| 103 | + |
| 104 | +If the hook is deleted, a JSON object is returned. An error is raised if the |
| 105 | +hook is not found. |
| 106 | + |
| 107 | +--- |
63 | 108 |
|
64 | 109 | ```
|
65 | 110 | DELETE /hooks/:id
|
66 | 111 | ```
|
67 | 112 |
|
68 |
| -Parameters: |
| 113 | +| Attribute | Type | Required | Description | |
| 114 | +| --------- | ---- | -------- | ----------- | |
| 115 | +| `id` | integer | yes | The ID of the hook | |
| 116 | + |
| 117 | +Example request: |
69 | 118 |
|
70 |
| -- `id` (required) - The ID of hook |
| 119 | +```bash |
| 120 | +curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/hooks/2 |
| 121 | +``` |
| 122 | + |
| 123 | +Example response: |
| 124 | + |
| 125 | +```json |
| 126 | +{ |
| 127 | + "note_events" : false, |
| 128 | + "project_id" : null, |
| 129 | + "enable_ssl_verification" : true, |
| 130 | + "url" : "https://gitlab.example.com/hook", |
| 131 | + "updated_at" : "2015-11-04T20:12:15.931Z", |
| 132 | + "issues_events" : false, |
| 133 | + "merge_requests_events" : false, |
| 134 | + "created_at" : "2015-11-04T20:12:15.931Z", |
| 135 | + "service_id" : null, |
| 136 | + "id" : 2, |
| 137 | + "push_events" : true, |
| 138 | + "tag_push_events" : false |
| 139 | +} |
| 140 | +``` |
0 commit comments