projects.md 42.6 KB
Newer Older
1
# Projects API
2

3
## Project visibility level
4

5 6
Project in GitLab can be either private, internal or public.
This is determined by the `visibility` field in the project.
7

8
Values for the project visibility level are:
9

10
* `private`:
11 12
  Project access must be granted explicitly for each user.

13
* `internal`:
14
  The project can be cloned by any logged in user.
15

16
* `public`:
17 18
  The project can be cloned without any authentication.

19
## List all projects
N
Nihad Abbasov 已提交
20

21 22
Get a list of all visible projects across GitLab for the authenticated user.
When accessed without authentication, only public projects are returned.
N
Nihad Abbasov 已提交
23 24 25 26 27

```
GET /projects
```

28 29 30 31 32 33
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `archived` | boolean | no | Limit by archived status |
| `visibility` | string | no | Limit by visibility `public`, `internal`, or `private` |
| `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at` |
| `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc` |
34
| `search` | string | no | Return list of projects matching the search criteria |
35
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
T
Toon Claes 已提交
36
| `owned` | boolean | no | Limit by projects owned by the current user |
37
| `membership` | boolean | no | Limit by projects that the current user is a member of |
T
Toon Claes 已提交
38
| `starred` | boolean | no | Limit by projects starred by the current user |
39
| `statistics` | boolean | no | Include project statistics |
40 41
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
V
vanadium23 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

```json
[
  {
    "id": 4,
    "description": null,
    "default_branch": "master",
    "visibility": "private",
    "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
    "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",
    "web_url": "http://example.com/diaspora/diaspora-client",
    "tag_list": [
      "example",
      "disapora client"
    ],
    "owner": {
      "id": 3,
      "name": "Diaspora",
      "created_at": "2013-09-30T13:46:02Z"
    },
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
    "open_issues_count": 1,
    "merge_requests_enabled": true,
    "jobs_enabled": true,
    "wiki_enabled": true,
    "snippets_enabled": false,
72
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    "container_registry_enabled": false,
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "creator_id": 3,
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
      "kind": "group",
      "full_path": "diaspora"
    },
    "import_status": "none",
    "archived": false,
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
102 103 104 105 106 107 108 109 110 111
    },
    "_links": {
      "self": "http://example.com/api/v4/projects",
      "issues": "http://example.com/api/v4/projects/1/issues",
      "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
      "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
      "labels": "http://example.com/api/v4/projects/1/labels",
      "events": "http://example.com/api/v4/projects/1/events",
      "members": "http://example.com/api/v4/projects/1/members"
    },
V
vanadium23 已提交
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  },
  {
    "id": 6,
    "description": null,
    "default_branch": "master",
    "visibility": "private",
    "ssh_url_to_repo": "git@example.com:brightbox/puppet.git",
    "http_url_to_repo": "http://example.com/brightbox/puppet.git",
    "web_url": "http://example.com/brightbox/puppet",
    "tag_list": [
      "example",
      "puppet"
    ],
    "owner": {
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
    },
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
    "issues_enabled": true,
    "open_issues_count": 1,
    "merge_requests_enabled": true,
    "jobs_enabled": true,
    "wiki_enabled": true,
    "snippets_enabled": false,
140
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    "container_registry_enabled": false,
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "creator_id": 3,
    "namespace": {
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
      "kind": "group",
      "full_path": "brightbox"
    },
    "import_status": "none",
    "import_error": null,
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
    "archived": false,
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
181 182 183 184 185 186 187 188 189
    },
    "_links": {
      "self": "http://example.com/api/v4/projects",
      "issues": "http://example.com/api/v4/projects/1/issues",
      "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
      "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
      "labels": "http://example.com/api/v4/projects/1/labels",
      "events": "http://example.com/api/v4/projects/1/events",
      "members": "http://example.com/api/v4/projects/1/members"
V
vanadium23 已提交
190 191 192 193 194
    }
  }
]
```

195
## List user projects
V
vanadium23 已提交
196

197 198
Get a list of visible projects for the given user. When accessed without
authentication, only public projects are returned.
V
vanadium23 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216

```
GET /users/:user_id/projects
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `user_id` | string | yes | The ID or username of the user |
| `archived` | boolean | no | Limit by archived status |
| `visibility` | string | no | Limit by visibility `public`, `internal`, or `private` |
| `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at` |
| `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc` |
| `search` | string | no | Return list of projects matching the search criteria |
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
| `owned` | boolean | no | Limit by projects owned by the current user |
| `membership` | boolean | no | Limit by projects that the current user is a member of |
| `starred` | boolean | no | Limit by projects starred by the current user |
| `statistics` | boolean | no | Include project statistics |
217 218
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
219

N
Nihad Abbasov 已提交
220 221 222
```json
[
  {
M
Marin Jankovski 已提交
223
    "id": 4,
N
Nihad Abbasov 已提交
224 225
    "description": null,
    "default_branch": "master",
226
    "visibility": "private",
M
Marin Jankovski 已提交
227 228 229
    "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
    "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",
    "web_url": "http://example.com/diaspora/diaspora-client",
230 231 232 233
    "tag_list": [
      "example",
      "disapora client"
    ],
N
Nihad Abbasov 已提交
234
    "owner": {
M
Marin Jankovski 已提交
235 236
      "id": 3,
      "name": "Diaspora",
B
Ben Boeckel 已提交
237
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
238
    },
M
Marin Jankovski 已提交
239 240 241 242 243
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
S
Stan Hu 已提交
244
    "open_issues_count": 1,
M
Marin Jankovski 已提交
245
    "merge_requests_enabled": true,
246
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
247
    "wiki_enabled": true,
M
Marin Jankovski 已提交
248
    "snippets_enabled": false,
249
    "resolve_outdated_diff_discussions": false,
250
    "container_registry_enabled": false,
B
Ben Boeckel 已提交
251 252
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
253
    "creator_id": 3,
M
Marin Jankovski 已提交
254 255 256 257
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
258 259
      "kind": "group",
      "full_path": "diaspora"
260
    },
261
    "import_status": "none",
S
sue445 已提交
262
    "archived": false,
T
Tomasz Maczukin 已提交
263 264 265
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
266 267
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
268
    "public_jobs": true,
269
    "shared_with_groups": [],
J
James Lopez 已提交
270
    "only_allow_merge_if_pipeline_succeeds": false,
271
    "only_allow_merge_if_all_discussions_are_resolved": false,
272 273 274 275 276 277 278
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
279 280 281 282 283 284 285 286 287
    },
    "_links": {
      "self": "http://example.com/api/v4/projects",
      "issues": "http://example.com/api/v4/projects/1/issues",
      "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
      "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
      "labels": "http://example.com/api/v4/projects/1/labels",
      "events": "http://example.com/api/v4/projects/1/events",
      "members": "http://example.com/api/v4/projects/1/members"
288
    }
N
Nihad Abbasov 已提交
289 290
  },
  {
M
Marin Jankovski 已提交
291
    "id": 6,
N
Nihad Abbasov 已提交
292
    "description": null,
M
Marin Jankovski 已提交
293
    "default_branch": "master",
294
    "visibility": "private",
M
Marin Jankovski 已提交
295 296 297
    "ssh_url_to_repo": "git@example.com:brightbox/puppet.git",
    "http_url_to_repo": "http://example.com/brightbox/puppet.git",
    "web_url": "http://example.com/brightbox/puppet",
298 299 300 301
    "tag_list": [
      "example",
      "puppet"
    ],
J
Johannes Schleifenbaum 已提交
302
    "owner": {
M
Marin Jankovski 已提交
303 304 305
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
306
    },
M
Marin Jankovski 已提交
307 308 309 310
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
N
Nihad Abbasov 已提交
311
    "issues_enabled": true,
S
Stan Hu 已提交
312
    "open_issues_count": 1,
N
Nihad Abbasov 已提交
313
    "merge_requests_enabled": true,
314
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
315
    "wiki_enabled": true,
M
Marin Jankovski 已提交
316
    "snippets_enabled": false,
317
    "resolve_outdated_diff_discussions": false,
318
    "container_registry_enabled": false,
M
Marin Jankovski 已提交
319 320
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
321
    "creator_id": 3,
J
Johannes Schleifenbaum 已提交
322
    "namespace": {
M
Marin Jankovski 已提交
323 324 325
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
326 327
      "kind": "group",
      "full_path": "brightbox"
328
    },
329 330
    "import_status": "none",
    "import_error": null,
331 332 333 334 335 336 337 338 339 340
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
S
sue445 已提交
341
    "archived": false,
T
Tomasz Maczukin 已提交
342 343 344 345
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
346
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
347
    "public_jobs": true,
348
    "shared_with_groups": [],
J
James Lopez 已提交
349
    "only_allow_merge_if_pipeline_succeeds": false,
350
    "only_allow_merge_if_all_discussions_are_resolved": false,
351 352 353 354 355 356 357
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
358 359 360 361 362 363 364 365 366
    },
    "_links": {
      "self": "http://example.com/api/v4/projects",
      "issues": "http://example.com/api/v4/projects/1/issues",
      "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
      "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
      "labels": "http://example.com/api/v4/projects/1/labels",
      "events": "http://example.com/api/v4/projects/1/events",
      "members": "http://example.com/api/v4/projects/1/members"
367
    }
368 369 370 371
  }
]
```

372
## Get single project
N
Nihad Abbasov 已提交
373

374 375
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
376 377 378 379 380

```
GET /projects/:id
```

381 382
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
383
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
384
| `statistics` | boolean | no | Include project statistics |
N
Nihad Abbasov 已提交
385

A
Alex Denisov 已提交
386 387
```json
{
M
Marin Jankovski 已提交
388
  "id": 3,
A
Alex Denisov 已提交
389
  "description": null,
M
Marin Jankovski 已提交
390
  "default_branch": "master",
391
  "visibility": "private",
M
Marin Jankovski 已提交
392 393 394
  "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
395 396 397 398
  "tag_list": [
    "example",
    "disapora project"
  ],
A
Alex Denisov 已提交
399
  "owner": {
M
Marin Jankovski 已提交
400 401
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
402
    "created_at": "2013-09-30T13:46:02Z"
A
Alex Denisov 已提交
403
  },
M
Marin Jankovski 已提交
404 405 406 407
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
A
Alex Denisov 已提交
408
  "issues_enabled": true,
S
Stan Hu 已提交
409
  "open_issues_count": 1,
A
Alex Denisov 已提交
410
  "merge_requests_enabled": true,
411
  "jobs_enabled": true,
A
Alex Denisov 已提交
412
  "wiki_enabled": true,
M
Marin Jankovski 已提交
413
  "snippets_enabled": false,
414
  "resolve_outdated_diff_discussions": false,
415
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
416 417
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
418
  "creator_id": 3,
M
Marin Jankovski 已提交
419 420 421 422
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
423 424
    "kind": "group",
    "full_path": "diaspora"
J
Johannes Schleifenbaum 已提交
425
  },
426 427
  "import_status": "none",
  "import_error": null,
D
Dmitriy Zaporozhets 已提交
428 429 430 431 432 433 434 435 436
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
437
  },
S
sue445 已提交
438
  "archived": false,
T
Tomasz Maczukin 已提交
439 440 441 442
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
443
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
444
  "public_jobs": true,
445 446 447 448 449 450 451 452 453 454 455
  "shared_with_groups": [
    {
      "group_id": 4,
      "group_name": "Twitter",
      "group_access_level": 30
    },
    {
      "group_id": 3,
      "group_name": "Gitlab Org",
      "group_access_level": 10
    }
456
  ],
J
James Lopez 已提交
457
  "only_allow_merge_if_pipeline_succeeds": false,
458
  "only_allow_merge_if_all_discussions_are_resolved": false,
459
  "printing_merge_requests_link_enabled": true,
460 461 462 463 464 465 466
  "request_access_enabled": false,
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
    "lfs_objects_size": 0,
    "job_artifacts_size": 0
467 468 469 470 471 472 473 474 475
  },
  "_links": {
    "self": "http://example.com/api/v4/projects",
    "issues": "http://example.com/api/v4/projects/1/issues",
    "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
    "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
    "labels": "http://example.com/api/v4/projects/1/labels",
    "events": "http://example.com/api/v4/projects/1/events",
    "members": "http://example.com/api/v4/projects/1/members"
476
  }
A
Alex Denisov 已提交
477 478 479
}
```

480
## Get project users
D
Dmitriy Zaporozhets 已提交
481

482
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
483

484 485 486
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
487

488 489
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
490 491
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
492
```json
J
Johannes Schleifenbaum 已提交
493 494
[
  {
495 496 497 498 499 500
    "id": 1,
    "username": "john_smith",
    "name": "John Smith",
    "state": "active",
    "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg",
    "web_url": "http://localhost:3000/john_smith"
D
Dmitriy Zaporozhets 已提交
501
  },
J
Johannes Schleifenbaum 已提交
502
  {
503 504 505 506 507 508
    "id": 2,
    "username": "jack_smith",
    "name": "Jack Smith",
    "state": "blocked",
    "avatar_url": "http://gravatar.com/../e32131cd8.jpeg",
    "web_url": "http://localhost:3000/jack_smith"
J
Johannes Schleifenbaum 已提交
509 510
  }
]
D
Dmitriy Zaporozhets 已提交
511 512
```

513
## Get project events
D
Dmitriy Zaporozhets 已提交
514

515
Please refer to the [Events API documentation](events.md#list-a-projects-visible-events).
D
Dmitriy Zaporozhets 已提交
516

517
## Create project
A
Alex Denisov 已提交
518

519
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
520 521 522 523 524

```
POST /projects
```

525 526
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
527 528
| `name` | string | yes if path is not provided | The name of the new project. Equals path if not provided. |
| `path` | string | yes if name is not provided | Repository name for new project. Generated based on name if not provided (generated lowercased with dashes). |
529 530 531 532
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
533
| `jobs_enabled` | boolean | no | Enable jobs for this project |
534 535
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
536
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
537 538
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
539
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
540
| `import_url` | string | no | URL to import repository from |
541 542
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
543
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
544 545
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
546
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
547
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
548
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
549
| `ci_config_path` | string | no | The path to CI config file |
550

551
## Create project for user
552

553
Creates a new project owned by the specified user. Available only for admins.
554 555 556 557 558

```
POST /projects/user/:user_id
```

559 560 561 562 563
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `user_id` | integer | yes | The user ID of the project owner |
| `name` | string | yes | The name of the new project |
| `path` | string | no | Custom repository name for new project. By default generated based on name |
564
| `default_branch` | string | no | `master` by default |
565 566 567 568
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
569
| `jobs_enabled` | boolean | no | Enable jobs for this project |
570 571
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
572
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
573 574
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
575
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
576
| `import_url` | string | no | URL to import repository from |
577 578
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
579
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
580 581
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
582
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
583
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
584
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
585
| `ci_config_path` | string | no | The path to CI config file |
A
Alex Denisov 已提交
586

587
## Edit project
588

589
Updates an existing project.
590 591 592 593 594

```
PUT /projects/:id
```

595 596
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
597
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
598 599
| `name` | string | yes | The name of the project |
| `path` | string | no | Custom repository name for the project. By default generated based on name |
600
| `default_branch` | string | no | `master` by default |
601 602 603
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
604
| `jobs_enabled` | boolean | no | Enable jobs for this project |
605 606
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
607
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
608 609
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
610
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
611
| `import_url` | string | no | URL to import repository from |
612 613
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
614
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
615 616
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
617
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
618
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
619
| `ci_config_path` | string | no | The path to CI config file |
620

621
## Fork project
622

623
Forks a project into the user namespace of the authenticated user or the one provided.
624

625 626 627
The forking operation for a project is asynchronous and is completed in a
background job. The request will return immediately. To determine whether the
fork of the project has completed, query the `import_status` for the new project.
628

629
```
630
POST /projects/:id/fork
631 632
```

633 634
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
635
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
636
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
637

638
## Star a project
639

640
Stars a given project. Returns status code `304` if the project is already starred.
641 642 643 644 645 646 647

```
POST /projects/:id/star
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
648
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
649 650

```bash
R
Robert Schilling 已提交
651
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
652 653 654 655 656 657 658 659 660
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
661
  "visibility": "internal",
662 663 664 665 666 667 668 669 670 671 672 673 674 675
  "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
  "issues_enabled": true,
  "open_issues_count": 1,
  "merge_requests_enabled": true,
676
  "jobs_enabled": true,
677 678
  "wiki_enabled": true,
  "snippets_enabled": false,
679
  "resolve_outdated_diff_discussions": false,
680
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
681 682
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
683 684 685 686 687
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
688 689
    "kind": "group",
    "full_path": "diaspora"
690
  },
691
  "import_status": "none",
692 693 694 695
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
696
  "star_count": 1,
697
  "public_jobs": true,
698
  "shared_with_groups": [],
J
James Lopez 已提交
699
  "only_allow_merge_if_pipeline_succeeds": false,
700
  "only_allow_merge_if_all_discussions_are_resolved": false,
701 702 703 704 705 706 707 708 709 710
  "request_access_enabled": false,
  "_links": {
    "self": "http://example.com/api/v4/projects",
    "issues": "http://example.com/api/v4/projects/1/issues",
    "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
    "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
    "labels": "http://example.com/api/v4/projects/1/labels",
    "events": "http://example.com/api/v4/projects/1/events",
    "members": "http://example.com/api/v4/projects/1/members"
  }
711 712 713
}
```

714
## Unstar a project
715

716
Unstars a given project. Returns status code `304` if the project is not starred.
717 718

```
719
POST /projects/:id/unstar
720 721 722 723
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
724
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
725 726

```bash
R
Robert Schilling 已提交
727
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
728 729 730 731 732 733 734 735 736
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
737
  "visibility": "internal",
738 739 740 741 742 743 744 745 746 747 748 749 750 751
  "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
  "issues_enabled": true,
  "open_issues_count": 1,
  "merge_requests_enabled": true,
752
  "jobs_enabled": true,
753 754
  "wiki_enabled": true,
  "snippets_enabled": false,
755
  "resolve_outdated_diff_discussions": false,
756
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
757 758
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
759 760 761 762 763
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
764 765
    "kind": "group",
    "full_path": "diaspora"
766
  },
767
  "import_status": "none",
768 769 770 771
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
772
  "star_count": 0,
773
  "public_jobs": true,
774
  "shared_with_groups": [],
J
James Lopez 已提交
775
  "only_allow_merge_if_pipeline_succeeds": false,
776
  "only_allow_merge_if_all_discussions_are_resolved": false,
777 778 779 780 781 782 783 784 785 786
  "request_access_enabled": false,
  "_links": {
    "self": "http://example.com/api/v4/projects",
    "issues": "http://example.com/api/v4/projects/1/issues",
    "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
    "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
    "labels": "http://example.com/api/v4/projects/1/labels",
    "events": "http://example.com/api/v4/projects/1/events",
    "members": "http://example.com/api/v4/projects/1/members"
  }
787 788 789
}
```

790
## Archive a project
791

792
Archives the project if the user is either admin or the project owner of this project. This action is
793 794 795
idempotent, thus archiving an already archived project will not change the project.

```
796
POST /projects/:id/archive
797 798 799 800
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
801
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
802 803

```bash
R
Robert Schilling 已提交
804
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
805 806 807 808 809 810 811 812 813
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
814
  "visibility": "private",
815 816 817 818 819 820 821 822 823 824
  "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
825
    "created_at": "2013-09-30T13:46:02Z"
826 827 828 829 830 831 832 833
  },
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
  "issues_enabled": true,
  "open_issues_count": 1,
  "merge_requests_enabled": true,
834
  "jobs_enabled": true,
835 836
  "wiki_enabled": true,
  "snippets_enabled": false,
837
  "resolve_outdated_diff_discussions": false,
838
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
839 840
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
841 842 843 844 845
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
846 847
    "kind": "group",
    "full_path": "diaspora"
848
  },
849 850
  "import_status": "none",
  "import_error": null,
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
  },
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
866
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
867
  "public_jobs": true,
868
  "shared_with_groups": [],
J
James Lopez 已提交
869
  "only_allow_merge_if_pipeline_succeeds": false,
870
  "only_allow_merge_if_all_discussions_are_resolved": false,
871 872 873 874 875 876 877 878 879 880
  "request_access_enabled": false,
  "_links": {
    "self": "http://example.com/api/v4/projects",
    "issues": "http://example.com/api/v4/projects/1/issues",
    "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
    "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
    "labels": "http://example.com/api/v4/projects/1/labels",
    "events": "http://example.com/api/v4/projects/1/events",
    "members": "http://example.com/api/v4/projects/1/members"
  }
881 882 883
}
```

884
## Unarchive a project
885

886
Unarchives the project if the user is either admin or the project owner of this project. This action is
887 888 889
idempotent, thus unarchiving an non-archived project will not change the project.

```
S
Sergey Gnuskov 已提交
890
POST /projects/:id/unarchive
891 892 893 894
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
895
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
896 897

```bash
R
Robert Schilling 已提交
898
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
899 900 901 902 903 904 905 906 907
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
908
  "visibility": "private",
909 910 911 912 913 914 915 916 917 918
  "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
919
    "created_at": "2013-09-30T13:46:02Z"
920 921 922 923 924 925 926 927
  },
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
  "issues_enabled": true,
  "open_issues_count": 1,
  "merge_requests_enabled": true,
928
  "jobs_enabled": true,
929 930
  "wiki_enabled": true,
  "snippets_enabled": false,
931
  "resolve_outdated_diff_discussions": false,
932
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
933 934
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
935 936 937 938 939
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
940 941
    "kind": "group",
    "full_path": "diaspora"
942
  },
943 944
  "import_status": "none",
  "import_error": null,
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
  },
  "archived": false,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
960
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
961
  "public_jobs": true,
962
  "shared_with_groups": [],
J
James Lopez 已提交
963
  "only_allow_merge_if_pipeline_succeeds": false,
964
  "only_allow_merge_if_all_discussions_are_resolved": false,
965 966 967 968 969 970 971 972 973 974
  "request_access_enabled": false,
  "_links": {
    "self": "http://example.com/api/v4/projects",
    "issues": "http://example.com/api/v4/projects/1/issues",
    "merge_requests": "http://example.com/api/v4/projects/1/merge_requests",
    "repo_branches": "http://example.com/api/v4/projects/1/repository_branches",
    "labels": "http://example.com/api/v4/projects/1/labels",
    "events": "http://example.com/api/v4/projects/1/events",
    "members": "http://example.com/api/v4/projects/1/members"
  }
975 976 977
}
```

978
## Remove project
D
Dmitriy Zaporozhets 已提交
979

980
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
981 982 983 984 985

```
DELETE /projects/:id
```

986 987
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
988
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
989

990
## Upload a file
D
Douwe Maan 已提交
991 992 993 994 995 996 997

Uploads a file to the specified project to be used in an issue or merge request description, or a comment.

```
POST /projects/:id/uploads
```

998 999
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1000
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1001
| `file` | string | yes | The file to be uploaded |
D
Douwe Maan 已提交
1002

1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
To upload a file from your filesystem, use the `--form` argument. This causes
cURL to post data using the header `Content-Type: multipart/form-data`.
The `file=` parameter must point to a file on your filesystem and be preceded
by `@`. For example:

```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "file=@dk.png" https://gitlab.example.com/api/v3/projects/5/uploads
```

Returned object:

D
Douwe Maan 已提交
1014 1015 1016 1017 1018 1019 1020 1021
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

1022
>**Note**: The returned `url` is relative to the project path.
1023 1024
In Markdown contexts, the link is automatically expanded when the format in
`markdown` is used.
D
Douwe Maan 已提交
1025

1026
## Share project with group
1027 1028 1029 1030 1031 1032 1033

Allow to share project with group.

```
POST /projects/:id/share
```

1034 1035
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1036
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1037 1038 1039
| `group_id` | integer | yes | The ID of the group to share with |
| `group_access` | integer | yes | The permissions level to grant the group |
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1040

1041
## Delete a shared project link within a group
1042 1043 1044 1045 1046 1047 1048 1049 1050

Unshare the project from the group. Returns `204` and no content on success.

```
DELETE /projects/:id/share/:group_id
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1051
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1052 1053 1054
| `group_id` | integer | yes | The ID of the group |

```bash
R
Robert Schilling 已提交
1055
curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/share/17
1056 1057
```

1058 1059
## Hooks

1060 1061 1062
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1063 1064
### List project hooks

1065
Get a list of project hooks.
M
miks 已提交
1066 1067 1068 1069 1070

```
GET /projects/:id/hooks
```

1071 1072
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1073
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
M
miks 已提交
1074

1075
### Get project hook
1076

1077
Get a specific hook for a project.
1078 1079 1080 1081 1082

```
GET /projects/:id/hooks/:hook_id
```

1083 1084
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1085
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1086
| `hook_id` | integer | yes | The ID of a project hook |
1087

1088 1089 1090 1091
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1092
  "project_id": 3,
B
Ben Boeckel 已提交
1093 1094 1095
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
1096
  "tag_push_events": true,
B
Ben Boeckel 已提交
1097
  "note_events": true,
1098
  "job_events": true,
1099
  "pipeline_events": true,
1100
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1101
  "enable_ssl_verification": true,
1102 1103 1104 1105 1106 1107
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1108
Adds a hook to a specified project.
M
miks 已提交
1109 1110 1111 1112 1113

```
POST /projects/:id/hooks
```

1114 1115
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1116
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1117 1118 1119 1120 1121 1122
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
| `merge_requests_events` | boolean | no | Trigger hook on merge requests events |
| `tag_push_events` | boolean | no | Trigger hook on tag push events |
| `note_events` | boolean | no | Trigger hook on note events |
1123
| `job_events` | boolean | no | Trigger hook on job events |
1124 1125 1126
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
| `wiki_events` | boolean | no | Trigger hook on wiki events |
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1127
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1128

1129 1130
### Edit project hook

1131
Edits a hook for a specified project.
1132 1133 1134 1135 1136

```
PUT /projects/:id/hooks/:hook_id
```

1137 1138
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1139
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1140 1141 1142 1143 1144 1145 1146
| `hook_id` | integer | yes | The ID of the project hook |
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
| `merge_requests_events` | boolean | no | Trigger hook on merge requests events |
| `tag_push_events` | boolean | no | Trigger hook on tag push events |
| `note_events` | boolean | no | Trigger hook on note events |
1147
| `job_events` | boolean | no | Trigger hook on job events |
1148 1149 1150
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
| `wiki_events` | boolean | no | Trigger hook on wiki events |
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1151
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1152

1153
### Delete project hook
M
miks 已提交
1154

1155
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1156
Either the hook is available or not.
M
miks 已提交
1157 1158

```
1159
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1160 1161
```

1162 1163
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1164
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1165
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1166

1167 1168
Note the JSON response differs if the hook is available or not. If the project hook
is available before it is returned in the JSON response or an empty response is returned.
1169

1170 1171
## Admin fork relation

1172
Allows modification of the forked relationship between existing projects. Available only for admins.
1173

1174
### Create a forked from/to relation between existing projects
1175 1176 1177 1178 1179

```
POST /projects/:id/fork/:forked_from_id
```

1180 1181
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1182
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1183
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1184 1185 1186 1187 1188 1189 1190

### Delete an existing forked from relationship

```
DELETE /projects/:id/fork
```

1191 1192
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1193
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1194 1195 1196

## Search for projects by name

1197 1198 1199
Search for projects by name which are accessible to the authenticated user. This
endpoint can be accessed without authentication if the project is publicly
accessible.
I
Izaak Alpert 已提交
1200 1201

```
1202
GET /projects
I
Izaak Alpert 已提交
1203 1204
```

1205 1206
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1207
| `search` | string | yes | A string contained in the project name |
1208
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1209
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1210

1211 1212 1213 1214
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1215 1216
## Start the Housekeeping task for a Project

1217
> Introduced in GitLab 9.0.
1218 1219 1220 1221 1222 1223 1224

```
POST /projects/:id/housekeeping
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1225 1226 1227 1228 1229 1230 1231 1232 1233
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |

## Branches

Read more in the [Branches](branches.md) documentation.

## Project members

Read more in the [Project members](members.md) documentation.