projects.md 49.7 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 20 21 22 23 24 25 26 27 28 29 30 31 32 33
## Project merge method

There are currently three options for `merge_method` to choose from:

* `merge`:
  A merge commit is created for every merge, and merging is allowed as long as there are no conflicts.

* `rebase_merge`:
  A merge commit is created for every merge, but merging is only allowed if fast-forward merge is possible.
  This way you could make sure that if this merge request would build, after merging to target branch it would also build.

* `ff`:
  No merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded.


34
## List all projects
N
Nihad Abbasov 已提交
35

36 37
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 已提交
38 39 40 41 42

```
GET /projects
```

43 44 45 46 47 48
| 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` |
49
| `search` | string | no | Return list of projects matching the search criteria |
50
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
T
Toon Claes 已提交
51
| `owned` | boolean | no | Limit by projects owned by the current user |
52
| `membership` | boolean | no | Limit by projects that the current user is a member of |
T
Toon Claes 已提交
53
| `starred` | boolean | no | Limit by projects starred by the current user |
54
| `statistics` | boolean | no | Include project statistics |
55
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
56 57
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
V
vanadium23 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

```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,
88
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    "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,
112
    "merge_method": "merge",
V
vanadium23 已提交
113 114 115 116 117 118
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
119 120 121 122 123 124 125 126 127 128
    },
    "_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 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
  },
  {
    "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,
157
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    "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,
192
    "merge_method": "merge",
V
vanadium23 已提交
193 194 195 196 197 198
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
199 200 201 202 203 204 205 206 207
    },
    "_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 已提交
208 209 210 211 212
    }
  }
]
```

213 214 215 216 217 218
You can filter by [custom attributes](custom_attributes.md) with:

```
GET /projects?custom_attributes[key]=value&custom_attributes[other_key]=other_value
```

219
## List user projects
V
vanadium23 已提交
220

221 222
Get a list of visible projects for the given user. When accessed without
authentication, only public projects are returned.
V
vanadium23 已提交
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240

```
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 |
241
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
242 243
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
244

N
Nihad Abbasov 已提交
245 246 247
```json
[
  {
M
Marin Jankovski 已提交
248
    "id": 4,
N
Nihad Abbasov 已提交
249 250
    "description": null,
    "default_branch": "master",
251
    "visibility": "private",
M
Marin Jankovski 已提交
252 253 254
    "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",
255 256 257 258
    "tag_list": [
      "example",
      "disapora client"
    ],
N
Nihad Abbasov 已提交
259
    "owner": {
M
Marin Jankovski 已提交
260 261
      "id": 3,
      "name": "Diaspora",
B
Ben Boeckel 已提交
262
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
263
    },
M
Marin Jankovski 已提交
264 265 266 267 268
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
S
Stan Hu 已提交
269
    "open_issues_count": 1,
M
Marin Jankovski 已提交
270
    "merge_requests_enabled": true,
271
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
272
    "wiki_enabled": true,
M
Marin Jankovski 已提交
273
    "snippets_enabled": false,
274
    "resolve_outdated_diff_discussions": false,
275
    "container_registry_enabled": false,
B
Ben Boeckel 已提交
276 277
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
278
    "creator_id": 3,
M
Marin Jankovski 已提交
279 280 281 282
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
283 284
      "kind": "group",
      "full_path": "diaspora"
285
    },
286
    "import_status": "none",
S
sue445 已提交
287
    "archived": false,
T
Tomasz Maczukin 已提交
288 289 290
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
291 292
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
293
    "public_jobs": true,
294
    "shared_with_groups": [],
J
James Lopez 已提交
295
    "only_allow_merge_if_pipeline_succeeds": false,
296
    "only_allow_merge_if_all_discussions_are_resolved": false,
297
    "request_access_enabled": false,
298
    "merge_method": "merge",
299 300 301 302 303 304
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
305 306 307 308 309 310 311 312 313
    },
    "_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"
314
    }
N
Nihad Abbasov 已提交
315 316
  },
  {
M
Marin Jankovski 已提交
317
    "id": 6,
N
Nihad Abbasov 已提交
318
    "description": null,
M
Marin Jankovski 已提交
319
    "default_branch": "master",
320
    "visibility": "private",
M
Marin Jankovski 已提交
321 322 323
    "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",
324 325 326 327
    "tag_list": [
      "example",
      "puppet"
    ],
J
Johannes Schleifenbaum 已提交
328
    "owner": {
M
Marin Jankovski 已提交
329 330 331
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
332
    },
M
Marin Jankovski 已提交
333 334 335 336
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
N
Nihad Abbasov 已提交
337
    "issues_enabled": true,
S
Stan Hu 已提交
338
    "open_issues_count": 1,
N
Nihad Abbasov 已提交
339
    "merge_requests_enabled": true,
340
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
341
    "wiki_enabled": true,
M
Marin Jankovski 已提交
342
    "snippets_enabled": false,
343
    "resolve_outdated_diff_discussions": false,
344
    "container_registry_enabled": false,
M
Marin Jankovski 已提交
345 346
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
347
    "creator_id": 3,
J
Johannes Schleifenbaum 已提交
348
    "namespace": {
M
Marin Jankovski 已提交
349 350 351
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
352 353
      "kind": "group",
      "full_path": "brightbox"
354
    },
355 356
    "import_status": "none",
    "import_error": null,
357 358 359 360 361 362 363 364 365 366
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
S
sue445 已提交
367
    "archived": false,
T
Tomasz Maczukin 已提交
368 369 370 371
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
372
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
373
    "public_jobs": true,
374
    "shared_with_groups": [],
J
James Lopez 已提交
375
    "only_allow_merge_if_pipeline_succeeds": false,
376
    "only_allow_merge_if_all_discussions_are_resolved": false,
377
    "request_access_enabled": false,
378
    "merge_method": "merge",
379 380 381 382 383 384
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
385 386 387 388 389 390 391 392 393
    },
    "_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"
394
    }
395 396 397 398
  }
]
```

399
## Get single project
N
Nihad Abbasov 已提交
400

401 402
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
403 404 405 406 407

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

408 409
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
410
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
411
| `statistics` | boolean | no | Include project statistics |
412
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
N
Nihad Abbasov 已提交
413

A
Alex Denisov 已提交
414 415
```json
{
M
Marin Jankovski 已提交
416
  "id": 3,
A
Alex Denisov 已提交
417
  "description": null,
M
Marin Jankovski 已提交
418
  "default_branch": "master",
419
  "visibility": "private",
M
Marin Jankovski 已提交
420 421 422
  "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",
423 424 425 426
  "tag_list": [
    "example",
    "disapora project"
  ],
A
Alex Denisov 已提交
427
  "owner": {
M
Marin Jankovski 已提交
428 429
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
430
    "created_at": "2013-09-30T13:46:02Z"
A
Alex Denisov 已提交
431
  },
M
Marin Jankovski 已提交
432 433 434 435
  "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 已提交
436
  "issues_enabled": true,
S
Stan Hu 已提交
437
  "open_issues_count": 1,
A
Alex Denisov 已提交
438
  "merge_requests_enabled": true,
439
  "jobs_enabled": true,
A
Alex Denisov 已提交
440
  "wiki_enabled": true,
M
Marin Jankovski 已提交
441
  "snippets_enabled": false,
442
  "resolve_outdated_diff_discussions": false,
443
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
444 445
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
446
  "creator_id": 3,
M
Marin Jankovski 已提交
447 448 449 450
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
451 452
    "kind": "group",
    "full_path": "diaspora"
J
Johannes Schleifenbaum 已提交
453
  },
454 455
  "import_status": "none",
  "import_error": null,
D
Dmitriy Zaporozhets 已提交
456 457 458 459 460 461 462 463 464
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
465
  },
S
sue445 已提交
466
  "archived": false,
T
Tomasz Maczukin 已提交
467 468 469 470
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
471
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
472
  "public_jobs": true,
473 474 475 476 477 478 479 480 481 482 483
  "shared_with_groups": [
    {
      "group_id": 4,
      "group_name": "Twitter",
      "group_access_level": 30
    },
    {
      "group_id": 3,
      "group_name": "Gitlab Org",
      "group_access_level": 10
    }
484
  ],
J
James Lopez 已提交
485
  "only_allow_merge_if_pipeline_succeeds": false,
486
  "only_allow_merge_if_all_discussions_are_resolved": false,
487
  "printing_merge_requests_link_enabled": true,
488
  "request_access_enabled": false,
489
  "merge_method": "merge",
490 491 492 493 494 495
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
    "lfs_objects_size": 0,
    "job_artifacts_size": 0
496 497 498 499 500 501 502 503 504
  },
  "_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"
505
  }
A
Alex Denisov 已提交
506 507 508
}
```

509
## Get project users
D
Dmitriy Zaporozhets 已提交
510

511
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
512

513 514 515
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
516

517 518
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
519 520
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
521
```json
J
Johannes Schleifenbaum 已提交
522 523
[
  {
524 525 526 527 528 529
    "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 已提交
530
  },
J
Johannes Schleifenbaum 已提交
531
  {
532 533 534 535 536 537
    "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 已提交
538 539
  }
]
D
Dmitriy Zaporozhets 已提交
540 541
```

542
## Get project events
D
Dmitriy Zaporozhets 已提交
543

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

546
## Create project
A
Alex Denisov 已提交
547

548
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
549 550 551 552 553

```
POST /projects
```

554 555
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
556 557
| `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). |
558 559 560 561
| `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 |
562
| `jobs_enabled` | boolean | no | Enable jobs for this project |
563 564
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
565
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
566 567
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
568
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
569
| `import_url` | string | no | URL to import repository from |
570 571
| `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 |
572
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
573
| `merge_method` | string | no | Set the merge method used |
574 575
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
576
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
577
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
578
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
579
| `ci_config_path` | string | no | The path to CI config file |
580

581
## Create project for user
582

583
Creates a new project owned by the specified user. Available only for admins.
584 585 586 587 588

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

589 590 591 592 593
| 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 |
594
| `default_branch` | string | no | `master` by default |
595 596 597 598
| `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 |
599
| `jobs_enabled` | boolean | no | Enable jobs for this project |
600 601
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
602
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
603 604
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
605
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
606
| `import_url` | string | no | URL to import repository from |
607 608
| `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 |
609
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
610
| `merge_method` | string | no | Set the merge method used |
611 612
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
613
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
614
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
615
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
616
| `ci_config_path` | string | no | The path to CI config file |
A
Alex Denisov 已提交
617

618
## Edit project
619

620
Updates an existing project.
621 622 623 624 625

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

626 627
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
628
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
629 630
| `name` | string | yes | The name of the project |
| `path` | string | no | Custom repository name for the project. By default generated based on name |
631
| `default_branch` | string | no | `master` by default |
632 633 634
| `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 |
635
| `jobs_enabled` | boolean | no | Enable jobs for this project |
636 637
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
638
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
639 640
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
641
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
642
| `import_url` | string | no | URL to import repository from |
643 644
| `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 |
645
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
646
| `merge_method` | string | no | Set the merge method used |
647 648
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
649
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
650
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
651
| `ci_config_path` | string | no | The path to CI config file |
652

653
## Fork project
654

655
Forks a project into the user namespace of the authenticated user or the one provided.
656

657 658 659
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.
660

661
```
662
POST /projects/:id/fork
663 664
```

665 666
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
667
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
668
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
669

670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
## List Forks of a project

>**Note:** This feature was introduced in GitLab 10.1

List the projects accessible to the calling user that have an established, forked relationship with the specified project

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

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `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 |
693
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |

```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/forks"
```

Example responses:

```json
[
  {
    "id": 3,
    "description": null,
    "default_branch": "master",
    "visibility": "internal",
    "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,
    "jobs_enabled": true,
    "wiki_enabled": true,
    "snippets_enabled": false,
    "resolve_outdated_diff_discussions": false,
    "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": true,
    "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 1,
    "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,
750
    "merge_method": "merge",
751 752 753 754 755 756 757 758 759 760 761 762 763
    "_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"
    }
  }
]
```

764
## Star a project
765

766
Stars a given project. Returns status code `304` if the project is already starred.
767 768 769 770 771 772 773

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

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

```bash
R
Robert Schilling 已提交
777
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
778 779 780 781 782 783 784 785 786
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
787
  "visibility": "internal",
788 789 790 791 792 793 794 795 796 797 798 799 800 801
  "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,
802
  "jobs_enabled": true,
803 804
  "wiki_enabled": true,
  "snippets_enabled": false,
805
  "resolve_outdated_diff_discussions": false,
806
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
807 808
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
809 810 811 812 813
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
814 815
    "kind": "group",
    "full_path": "diaspora"
816
  },
817
  "import_status": "none",
818 819 820 821
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
822
  "star_count": 1,
823
  "public_jobs": true,
824
  "shared_with_groups": [],
J
James Lopez 已提交
825
  "only_allow_merge_if_pipeline_succeeds": false,
826
  "only_allow_merge_if_all_discussions_are_resolved": false,
827
  "request_access_enabled": false,
828
  "merge_method": "merge",
829 830 831 832 833 834 835 836 837
  "_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"
  }
838 839 840
}
```

841
## Unstar a project
842

843
Unstars a given project. Returns status code `304` if the project is not starred.
844 845

```
846
POST /projects/:id/unstar
847 848 849 850
```

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

```bash
R
Robert Schilling 已提交
854
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
855 856 857 858 859 860 861 862 863
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
864
  "visibility": "internal",
865 866 867 868 869 870 871 872 873 874 875 876 877 878
  "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,
879
  "jobs_enabled": true,
880 881
  "wiki_enabled": true,
  "snippets_enabled": false,
882
  "resolve_outdated_diff_discussions": false,
883
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
884 885
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
886 887 888 889 890
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
891 892
    "kind": "group",
    "full_path": "diaspora"
893
  },
894
  "import_status": "none",
895 896 897 898
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
899
  "star_count": 0,
900
  "public_jobs": true,
901
  "shared_with_groups": [],
J
James Lopez 已提交
902
  "only_allow_merge_if_pipeline_succeeds": false,
903
  "only_allow_merge_if_all_discussions_are_resolved": false,
904
  "request_access_enabled": false,
905
  "merge_method": "merge",
906 907 908 909 910 911 912 913 914
  "_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"
  }
915 916 917
}
```

918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
## Languages

Get languages used in a project with percentage value.

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

```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/languages"
```

Example response:

```json
{
  "Ruby": 66.69,
  "JavaScript": 22.98,
  "HTML": 7.91,
  "CoffeeScript": 2.42
}
```

941
## Archive a project
942

943
Archives the project if the user is either admin or the project owner of this project. This action is
944 945 946
idempotent, thus archiving an already archived project will not change the project.

```
947
POST /projects/:id/archive
948 949 950 951
```

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

```bash
R
Robert Schilling 已提交
955
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
956 957 958 959 960 961 962 963 964
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
965
  "visibility": "private",
966 967 968 969 970 971 972 973 974 975
  "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 已提交
976
    "created_at": "2013-09-30T13:46:02Z"
977 978 979 980 981 982 983 984
  },
  "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,
985
  "jobs_enabled": true,
986 987
  "wiki_enabled": true,
  "snippets_enabled": false,
988
  "resolve_outdated_diff_discussions": false,
989
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
990 991
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
992 993 994 995 996
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
997 998
    "kind": "group",
    "full_path": "diaspora"
999
  },
1000 1001
  "import_status": "none",
  "import_error": null,
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
  "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,
1017
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1018
  "public_jobs": true,
1019
  "shared_with_groups": [],
J
James Lopez 已提交
1020
  "only_allow_merge_if_pipeline_succeeds": false,
1021
  "only_allow_merge_if_all_discussions_are_resolved": false,
1022
  "request_access_enabled": false,
1023
  "merge_method": "merge",
1024 1025 1026 1027 1028 1029 1030 1031 1032
  "_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"
  }
1033 1034 1035
}
```

1036
## Unarchive a project
1037

1038
Unarchives the project if the user is either admin or the project owner of this project. This action is
V
Ville Skyttä 已提交
1039
idempotent, thus unarchiving a non-archived project will not change the project.
1040 1041

```
S
Sergey Gnuskov 已提交
1042
POST /projects/:id/unarchive
1043 1044 1045 1046
```

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

```bash
R
Robert Schilling 已提交
1050
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
1051 1052 1053 1054 1055 1056 1057 1058 1059
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1060
  "visibility": "private",
1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
  "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 已提交
1071
    "created_at": "2013-09-30T13:46:02Z"
1072 1073 1074 1075 1076 1077 1078 1079
  },
  "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,
1080
  "jobs_enabled": true,
1081 1082
  "wiki_enabled": true,
  "snippets_enabled": false,
1083
  "resolve_outdated_diff_discussions": false,
1084
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1085 1086
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1087 1088 1089 1090 1091
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1092 1093
    "kind": "group",
    "full_path": "diaspora"
1094
  },
1095 1096
  "import_status": "none",
  "import_error": null,
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
  "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,
1112
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1113
  "public_jobs": true,
1114
  "shared_with_groups": [],
J
James Lopez 已提交
1115
  "only_allow_merge_if_pipeline_succeeds": false,
1116
  "only_allow_merge_if_all_discussions_are_resolved": false,
1117
  "request_access_enabled": false,
1118
  "merge_method": "merge",
1119 1120 1121 1122 1123 1124 1125 1126 1127
  "_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"
  }
1128 1129 1130
}
```

1131
## Remove project
D
Dmitriy Zaporozhets 已提交
1132

1133
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1134 1135 1136 1137 1138

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

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

1143
## Upload a file
D
Douwe Maan 已提交
1144 1145 1146 1147 1148 1149 1150

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

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

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

1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
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 已提交
1167 1168 1169 1170 1171 1172 1173 1174
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1179
## Share project with group
1180 1181 1182 1183 1184 1185 1186

Allow to share project with group.

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

1187 1188
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1189
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1190 1191 1192
| `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 |
1193

1194
## Delete a shared project link within a group
1195 1196 1197 1198 1199 1200 1201 1202 1203

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

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

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

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

1211 1212
## Hooks

1213 1214 1215
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1216 1217
### List project hooks

1218
Get a list of project hooks.
M
miks 已提交
1219 1220 1221 1222 1223

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

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

1228
### Get project hook
1229

1230
Get a specific hook for a project.
1231 1232 1233 1234 1235

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

1236 1237
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1238
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1239
| `hook_id` | integer | yes | The ID of a project hook |
1240

1241 1242 1243 1244
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1245
  "project_id": 3,
B
Ben Boeckel 已提交
1246 1247
  "push_events": true,
  "issues_events": true,
1248
  "confidential_issues_events": true,
B
Ben Boeckel 已提交
1249
  "merge_requests_events": true,
1250
  "tag_push_events": true,
B
Ben Boeckel 已提交
1251
  "note_events": true,
1252
  "job_events": true,
1253
  "pipeline_events": true,
1254
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1255
  "enable_ssl_verification": true,
1256 1257 1258 1259 1260 1261
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1262
Adds a hook to a specified project.
M
miks 已提交
1263 1264 1265 1266 1267

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

1268 1269
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1270
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1271 1272 1273
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
1274
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1275 1276 1277
| `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 |
1278
| `job_events` | boolean | no | Trigger hook on job events |
1279
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
1280
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
1281
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1282
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1283

1284 1285
### Edit project hook

1286
Edits a hook for a specified project.
1287 1288 1289 1290 1291

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

1292 1293
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1294
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1295 1296 1297 1298
| `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 |
1299
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1300 1301 1302
| `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 |
1303
| `job_events` | boolean | no | Trigger hook on job events |
1304 1305 1306
| `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 |
1307
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1308

1309
### Delete project hook
M
miks 已提交
1310

1311
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1312
Either the hook is available or not.
M
miks 已提交
1313 1314

```
1315
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1316 1317
```

1318 1319
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1320
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1321
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1322

1323 1324
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.
1325

1326 1327
## Admin fork relation

1328
Allows modification of the forked relationship between existing projects. Available only for admins.
1329

1330
### Create a forked from/to relation between existing projects
1331 1332 1333 1334 1335

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

1336 1337
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1338
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1339
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1340 1341 1342 1343 1344 1345 1346

### Delete an existing forked from relationship

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

1347 1348
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1349
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1350 1351 1352

## Search for projects by name

1353 1354 1355
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 已提交
1356 1357

```
1358
GET /projects
I
Izaak Alpert 已提交
1359 1360
```

1361 1362
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1363
| `search` | string | yes | A string contained in the project name |
1364
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1365
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1366

1367 1368 1369 1370
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1371 1372
## Start the Housekeeping task for a Project

1373
> Introduced in GitLab 9.0.
1374 1375 1376 1377 1378 1379 1380

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

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1381 1382 1383 1384 1385 1386
| `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.

J
James Lopez 已提交
1387 1388
## Project Import/Export

J
James Lopez 已提交
1389
Read more in the [Project import/export](project_import_export.md) documentation.
J
James Lopez 已提交
1390

1391 1392 1393
## Project members

Read more in the [Project members](members.md) documentation.
1394 1395 1396 1397

## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
1398 1399 1400

## Issue and merge request description templates

1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
The non-default [issue and merge request description templates](../user/project/description_templates.md) are managed inside the project's repository. So you can manage them via the API through the [Repositories API](repositories.md) and the [Repository Files API](repository_files.md).

## Download snapshot of a git repository

> Introduced in GitLab 10.7

This endpoint may only be accessed by an administrative user.

Download a snapshot of the project (or wiki, if requested) git repository. This
snapshot is always in uncompressed [tar](https://en.wikipedia.org/wiki/Tar_(computing))
format.

If a repository is corrupted to the point where `git clone` does not work, the
snapshot may allow some of the data to be retrieved.

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

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id`      | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `wiki`    | boolean | no | Whether to download the wiki, rather than project, repository |