projects.md 89.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
  The project can be accessed without any authentication.
18

19 20 21 22
## Project merge method

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

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

26
- `rebase_merge`:
27 28 29
  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.

30
- `ff`:
31 32
  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.

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

35
Get a list of all visible projects across GitLab for the authenticated user.
36
When accessed without authentication, only public projects with "simple" fields are returned.
N
Nihad Abbasov 已提交
37

38
```plaintext
N
Nihad Abbasov 已提交
39 40 41
GET /projects
```

42 43
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
44 45 46 47 48 49 50 51 52 53 54 55
| `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 limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
| `owned`                       | boolean | no | Limit by projects explicitly 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 |
| `with_custom_attributes`      | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
| `with_issues_enabled`         | boolean | no | Limit by enabled issues feature |
56
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
57
| `with_programming_language`   | string  | no | Limit by projects which use the given programming language |
58 59
| `wiki_checksum_failed`        | boolean | no | **(PREMIUM)** Limit projects where the wiki checksum calculation has failed ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6137) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.2) |
| `repository_checksum_failed`  | boolean | no | **(PREMIUM)** Limit projects where the repository checksum calculation has failed ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6137) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.2) |
60
| `min_access_level`            | integer | no | Limit by current user minimal [access level](members.md) |
61 62
| `id_after`                    | integer | no | Limit results to projects with IDs greater than the specified ID |
| `id_before`                   | integer | no | Limit results to projects with IDs less than the specified ID |
V
vanadium23 已提交
63

64 65 66
NOTE: **Note:**
This endpoint supports [keyset pagination](README.md#keyset-based-pagination) for selected `order_by` options.

67 68 69 70 71 72 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
When `simple=true` or the user is unauthenticated this returns something like:

```json
[
  {
    "id": 4,
    "description": null,
    "default_branch": "master",
    "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",
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
    "tag_list": [
      "example",
      "disapora client"
    ],
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "forks_count": 0,
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "star_count": 0,
  },
  {
    "id": 6,
    "description": null,
    "default_branch": "master",
...
```

When the user is authenticated and `simple` is not set this returns something like:

V
vanadium23 已提交
102 103 104 105 106 107 108 109 110 111
```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",
I
Imre Farkas 已提交
112
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
V
vanadium23 已提交
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
    "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,
132
    "can_create_merge_request_in": true,
133
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    "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",
152
    "ci_default_git_depth": 50,
V
vanadium23 已提交
153 154 155 156
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
157
    "remove_source_branch_after_merge": false,
V
vanadium23 已提交
158
    "request_access_enabled": false,
159
    "merge_method": "merge",
160
    "autoclose_referenced_issues": true,
161
    "suggestion_commit_message": null,
V
vanadium23 已提交
162 163 164 165
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
166
      "wiki_size" : 0,
V
vanadium23 已提交
167
      "lfs_objects_size": 0,
168 169
      "job_artifacts_size": 0,
      "packages_size": 0
170 171 172 173 174 175 176 177 178 179
    },
    "_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 已提交
180 181 182 183 184 185 186 187 188
  },
  {
    "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",
I
Imre Farkas 已提交
189
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
V
vanadium23 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
    "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,
209
    "can_create_merge_request_in": true,
210
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
    "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",
240
    "ci_default_git_depth": 0,
V
vanadium23 已提交
241 242 243 244
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
245
    "remove_source_branch_after_merge": false,
V
vanadium23 已提交
246
    "request_access_enabled": false,
247
    "merge_method": "merge",
248 249 250 251 252 253 254 255 256 257 258 259 260
    "auto_devops_enabled": true,
    "auto_devops_deploy_strategy": "continuous",
    "repository_storage": "default",
    "approvals_before_merge": 0,
    "mirror": false,
    "mirror_user_id": 45,
    "mirror_trigger_builds": false,
    "only_mirror_protected_branches": false,
    "mirror_overwrites_diverged_branches": false,
    "external_authorization_classification_label": null,
    "packages_enabled": true,
    "service_desk_enabled": false,
    "service_desk_address": null,
261
    "autoclose_referenced_issues": true,
262
    "suggestion_commit_message": null,
V
vanadium23 已提交
263 264 265 266
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
267
      "wiki_size" : 0,
V
vanadium23 已提交
268
      "lfs_objects_size": 0,
269 270
      "job_artifacts_size": 0,
      "packages_size": 0
271 272 273 274 275 276 277 278 279
    },
    "_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 已提交
280 281 282 283 284
    }
  }
]
```

285 286 287 288 289 290 291 292 293 294 295 296 297 298
Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see
the `approvals_before_merge` parameter:

```json
[
  {
    "id": 4,
    "description": null,
    "approvals_before_merge": 0,
    ...
  }
]
```

299 300
You can filter by [custom attributes](custom_attributes.md) with:

301
```plaintext
302 303 304
GET /projects?custom_attributes[key]=value&custom_attributes[other_key]=other_value
```

305 306 307 308 309 310 311 312 313
### Pagination limits

From GitLab 12.10, [offset-based pagination](README.md#offset-based-pagination) will be
[limited to 10,000 records](https://gitlab.com/gitlab-org/gitlab/issues/34565).
[Keyset pagination](README.md#keyset-based-pagination) will be required to retrieve projects
beyond this limit.

Note that keyset pagination only supports `order_by=id`. Other sorting options are not available.

314
## List user projects
V
vanadium23 已提交
315

D
Davin Walker 已提交
316
Get a list of visible projects owned by the given user. When accessed without authentication, only public projects are returned.
V
vanadium23 已提交
317

318
```plaintext
V
vanadium23 已提交
319 320 321 322 323 324 325 326 327 328 329
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 |
330
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
331
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
V
vanadium23 已提交
332 333 334
| `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 |
335
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
336 337
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
338
| `with_programming_language` | string | no | Limit by projects which use the given programming language |
339
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
340 341
| `id_after`                    | integer | no | Limit results to projects with IDs greater than the specified ID |
| `id_before`                   | integer | no | Limit results to projects with IDs less than the specified ID |
342

343 344 345
NOTE: **Note:**
This endpoint supports [keyset pagination](README.md#keyset-based-pagination) for selected `order_by` options.

N
Nihad Abbasov 已提交
346 347 348
```json
[
  {
M
Marin Jankovski 已提交
349
    "id": 4,
N
Nihad Abbasov 已提交
350 351
    "description": null,
    "default_branch": "master",
352
    "visibility": "private",
M
Marin Jankovski 已提交
353 354 355
    "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",
I
Imre Farkas 已提交
356
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
357 358 359 360
    "tag_list": [
      "example",
      "disapora client"
    ],
N
Nihad Abbasov 已提交
361
    "owner": {
M
Marin Jankovski 已提交
362 363
      "id": 3,
      "name": "Diaspora",
B
Ben Boeckel 已提交
364
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
365
    },
M
Marin Jankovski 已提交
366 367 368 369 370
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
S
Stan Hu 已提交
371
    "open_issues_count": 1,
M
Marin Jankovski 已提交
372
    "merge_requests_enabled": true,
373
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
374
    "wiki_enabled": true,
M
Marin Jankovski 已提交
375
    "snippets_enabled": false,
376
    "can_create_merge_request_in": true,
377
    "resolve_outdated_diff_discussions": false,
378
    "container_registry_enabled": false,
B
Ben Boeckel 已提交
379 380
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
381
    "creator_id": 3,
M
Marin Jankovski 已提交
382 383 384 385
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
386 387
      "kind": "group",
      "full_path": "diaspora"
388
    },
389
    "import_status": "none",
S
sue445 已提交
390
    "archived": false,
T
Tomasz Maczukin 已提交
391 392 393
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
394 395
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
396
    "ci_default_git_depth": 50,
397
    "public_jobs": true,
398
    "shared_with_groups": [],
J
James Lopez 已提交
399
    "only_allow_merge_if_pipeline_succeeds": false,
400
    "only_allow_merge_if_all_discussions_are_resolved": false,
401
    "remove_source_branch_after_merge": false,
402
    "request_access_enabled": false,
403
    "merge_method": "merge",
404
    "autoclose_referenced_issues": true,
405
    "suggestion_commit_message": null,
406 407 408 409
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
410
      "wiki_size" : 0,
411
      "lfs_objects_size": 0,
412 413
      "job_artifacts_size": 0,
      "packages_size": 0
414 415 416 417 418 419 420 421 422
    },
    "_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"
423
    }
N
Nihad Abbasov 已提交
424 425
  },
  {
M
Marin Jankovski 已提交
426
    "id": 6,
N
Nihad Abbasov 已提交
427
    "description": null,
M
Marin Jankovski 已提交
428
    "default_branch": "master",
429
    "visibility": "private",
M
Marin Jankovski 已提交
430 431 432
    "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",
I
Imre Farkas 已提交
433
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
434 435 436 437
    "tag_list": [
      "example",
      "puppet"
    ],
J
Johannes Schleifenbaum 已提交
438
    "owner": {
M
Marin Jankovski 已提交
439 440 441
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
442
    },
M
Marin Jankovski 已提交
443 444 445 446
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
N
Nihad Abbasov 已提交
447
    "issues_enabled": true,
S
Stan Hu 已提交
448
    "open_issues_count": 1,
N
Nihad Abbasov 已提交
449
    "merge_requests_enabled": true,
450
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
451
    "wiki_enabled": true,
M
Marin Jankovski 已提交
452
    "snippets_enabled": false,
453
    "can_create_merge_request_in": true,
454
    "resolve_outdated_diff_discussions": false,
455
    "container_registry_enabled": false,
M
Marin Jankovski 已提交
456 457
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
458
    "creator_id": 3,
J
Johannes Schleifenbaum 已提交
459
    "namespace": {
M
Marin Jankovski 已提交
460 461 462
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
463 464
      "kind": "group",
      "full_path": "brightbox"
465
    },
466 467
    "import_status": "none",
    "import_error": null,
468 469 470 471 472 473 474 475 476 477
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
S
sue445 已提交
478
    "archived": false,
T
Tomasz Maczukin 已提交
479 480 481 482
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
483
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
484
    "ci_default_git_depth": 0,
485
    "public_jobs": true,
486
    "shared_with_groups": [],
J
James Lopez 已提交
487
    "only_allow_merge_if_pipeline_succeeds": false,
488
    "only_allow_merge_if_all_discussions_are_resolved": false,
489
    "remove_source_branch_after_merge": false,
490
    "request_access_enabled": false,
491
    "merge_method": "merge",
492 493 494 495 496 497 498 499 500 501 502 503 504
    "auto_devops_enabled": true,
    "auto_devops_deploy_strategy": "continuous",
    "repository_storage": "default",
    "approvals_before_merge": 0,
    "mirror": false,
    "mirror_user_id": 45,
    "mirror_trigger_builds": false,
    "only_mirror_protected_branches": false,
    "mirror_overwrites_diverged_branches": false,
    "external_authorization_classification_label": null,
    "packages_enabled": true,
    "service_desk_enabled": false,
    "service_desk_address": null,
505
    "autoclose_referenced_issues": true,
506
    "suggestion_commit_message": null,
507 508 509 510
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
511
      "wiki_size" : 0,
512
      "lfs_objects_size": 0,
513 514
      "job_artifacts_size": 0,
      "packages_size": 0
515 516 517 518 519 520 521 522 523
    },
    "_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"
524
    }
525 526 527 528
  }
]
```

529 530 531 532
## List projects starred by a user

Get a list of visible projects owned by the given user. When accessed without authentication, only public projects are returned.

533
```plaintext
534 535 536 537 538
GET /users/:user_id/starred_projects
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
C
Camil Staps 已提交
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
| `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 limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned.. |
| `owned` | boolean | no | Limit by projects explicitly 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. |
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only). |
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature. |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature. |
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md). |

555
```shell
C
Camil Staps 已提交
556 557 558 559
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/5/starred_projects"
```

Example response:
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590

```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",
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
    "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,
591
    "can_create_merge_request_in": true,
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
    "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": 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,
615
    "remove_source_branch_after_merge": false,
616 617
    "request_access_enabled": false,
    "merge_method": "merge",
618
    "autoclose_referenced_issues": true,
619
    "suggestion_commit_message": null,
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
    },
    "_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"
    }
  },
  {
    "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",
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
    "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,
665
    "can_create_merge_request_in": true,
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
    "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": 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,
700
    "remove_source_branch_after_merge": false,
701 702
    "request_access_enabled": false,
    "merge_method": "merge",
703 704 705 706 707 708 709 710 711 712 713 714 715
    "auto_devops_enabled": true,
    "auto_devops_deploy_strategy": "continuous",
    "repository_storage": "default",
    "approvals_before_merge": 0,
    "mirror": false,
    "mirror_user_id": 45,
    "mirror_trigger_builds": false,
    "only_mirror_protected_branches": false,
    "mirror_overwrites_diverged_branches": false,
    "external_authorization_classification_label": null,
    "packages_enabled": true,
    "service_desk_enabled": false,
    "service_desk_address": null,
716
    "autoclose_referenced_issues": true,
717
    "suggestion_commit_message": null,
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
    },
    "_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"
    }
  }
]
```

738
## Get single project
N
Nihad Abbasov 已提交
739

740 741
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
742

743
```plaintext
N
Nihad Abbasov 已提交
744 745 746
GET /projects/:id
```

747 748
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
749
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
750
| `statistics` | boolean | no | Include project statistics |
J
J.D. Bean 已提交
751
| `license` | boolean | no | Include project license data |
752
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
N
Nihad Abbasov 已提交
753

A
Alex Denisov 已提交
754 755
```json
{
756 757
  "id": 3,
  "description": null,
M
Marin Jankovski 已提交
758
  "default_branch": "master",
759 760 761 762 763
  "visibility": "private",
  "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",
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
764
  "tag_list": [
765 766
    "example",
    "disapora project"
767
  ],
768 769 770 771
  "owner": {
    "id": 3,
    "name": "Diaspora",
    "created_at": "2013-09-30T13:46:02Z"
772
  },
773 774 775 776
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
777
  "issues_enabled": true,
778
  "open_issues_count": 1,
779 780
  "merge_requests_enabled": true,
  "jobs_enabled": true,
781 782
  "wiki_enabled": true,
  "snippets_enabled": false,
783
  "can_create_merge_request_in": true,
784 785
  "resolve_outdated_diff_discussions": false,
  "container_registry_enabled": false,
786 787 788 789 790 791 792 793
  "container_expiration_policy": {
    "cadence": "7d",
    "enabled": false,
    "keep_n": null,
    "older_than": null,
    "name_regex": null,
    "next_run_at": "2020-01-07T21:42:58.658Z"
  },
794 795 796 797 798 799 800 801 802 803 804 805
  "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",
    "avatar_url": "http://localhost:3000/uploads/group/avatar/3/foo.jpg",
    "web_url": "http://localhost:3000/groups/diaspora"
  },
806 807
  "import_status": "none",
  "import_error": null,
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
  "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",
  "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
  "license": {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0",
    "nickname": "GNU LGPLv3",
    "html_url": "http://choosealicense.com/licenses/lgpl-3.0/",
    "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
  },
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
832
  "ci_default_git_depth": 50,
833
  "public_jobs": true,
834
  "shared_with_groups": [
835 836 837 838 839 840
    {
      "group_id": 4,
      "group_name": "Twitter",
      "group_full_path": "twitter",
      "group_access_level": 30
    },
841 842
    {
      "group_id": 3,
843 844 845
      "group_name": "Gitlab Org",
      "group_full_path": "gitlab-org",
      "group_access_level": 10
846
    }
847
  ],
848
  "repository_storage": "default",
J
James Lopez 已提交
849
  "only_allow_merge_if_pipeline_succeeds": false,
850
  "only_allow_merge_if_all_discussions_are_resolved": false,
851
  "remove_source_branch_after_merge": false,
852 853
  "printing_merge_requests_link_enabled": true,
  "request_access_enabled": false,
854
  "merge_method": "merge",
855 856 857 858 859 860 861 862 863 864 865 866 867
  "auto_devops_enabled": true,
  "auto_devops_deploy_strategy": "continuous",
  "repository_storage": "default",
  "approvals_before_merge": 0,
  "mirror": false,
  "mirror_user_id": 45,
  "mirror_trigger_builds": false,
  "only_mirror_protected_branches": false,
  "mirror_overwrites_diverged_branches": false,
  "external_authorization_classification_label": null,
  "packages_enabled": true,
  "service_desk_enabled": false,
  "service_desk_address": null,
868
  "autoclose_referenced_issues": true,
869
  "suggestion_commit_message": null,
870 871 872 873
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
874
    "wiki_size" : 0,
875
    "lfs_objects_size": 0,
876 877
    "job_artifacts_size": 0,
    "packages_size": 0
878 879 880 881 882 883 884 885 886
  },
  "_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"
887
  }
A
Alex Denisov 已提交
888 889 890
}
```

891 892 893 894 895 896 897 898 899 900 901 902
Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see
the `approvals_before_merge` parameter:

```json
{
  "id": 3,
  "description": null,
  "approvals_before_merge": 0,
  ...
}
```

903 904
**Note**: The `web_url` and `avatar_url` attributes on `namespace` were [introduced][ce-27427] in GitLab 11.11.

905 906 907 908 909 910 911 912 913 914 915 916 917 918
If the project is a fork, and you provide a valid token to authenticate, the
`forked_from_project` field will appear in the response.

```json
{
   "id":3,

   ...

   "forked_from_project":{
      "id":13083,
      "description":"GitLab Community Edition",
      "name":"GitLab Community Edition",
      "name_with_namespace":"GitLab.org / GitLab Community Edition",
919 920
      "path":"gitlab-foss",
      "path_with_namespace":"gitlab-org/gitlab-foss",
921 922 923
      "created_at":"2013-09-26T06:02:36.000Z",
      "default_branch":"master",
      "tag_list":[],
924
      "ssh_url_to_repo":"git@gitlab.com:gitlab-org/gitlab-foss.git",
925 926
      "http_url_to_repo":"https://gitlab.com/gitlab-org/gitlab-foss.git",
      "web_url":"https://gitlab.com/gitlab-org/gitlab-foss",
927
      "avatar_url":"https://assets.gitlab-static.net/uploads/-/system/project/avatar/13083/logo-extra-whitespace.png",
928
      "license_url": "https://gitlab.com/gitlab-org/gitlab/blob/master/LICENSE",
J
J.D. Bean 已提交
929 930 931 932 933 934 935
      "license": {
        "key": "mit",
        "name": "MIT License",
        "nickname": null,
        "html_url": "http://choosealicense.com/licenses/mit/",
        "source_url": "https://opensource.org/licenses/MIT",
      },
936 937
      "star_count":3812,
      "forks_count":3561,
938 939 940 941 942 943 944 945 946
      "last_activity_at":"2018-01-02T11:40:26.570Z",
      "namespace": {
            "id": 72,
            "name": "GitLab.org",
            "path": "gitlab-org",
            "kind": "group",
            "full_path": "gitlab-org",
            "parent_id": null
      }
947 948 949 950 951 952 953
   }

   ...

}
```

954
## Get project users
D
Dmitriy Zaporozhets 已提交
955

956
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
957

958
```plaintext
959 960
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
961

962 963 964 965
| Attribute    | Type          | Required | Description |
| ------------ | ------------- | -------- | ----------- |
| `search`     | string        | no       | Search for specific users |
| `skip_users` | integer array | no       | Filter out users with the specified IDs |
966

D
Dmitriy Zaporozhets 已提交
967
```json
J
Johannes Schleifenbaum 已提交
968 969
[
  {
970 971 972 973 974 975
    "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 已提交
976
  },
J
Johannes Schleifenbaum 已提交
977
  {
978 979 980 981 982 983
    "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 已提交
984 985
  }
]
D
Dmitriy Zaporozhets 已提交
986 987
```

988
## Get project events
D
Dmitriy Zaporozhets 已提交
989

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

992
## Create project
A
Alex Denisov 已提交
993

994
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
995

996
```plaintext
A
Alex Denisov 已提交
997 998 999
POST /projects
```

1000 1001
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1002 1003
| `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). |
1004
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
1005
| `default_branch` | string | no | `master` by default |
1006
| `description` | string | no | Short project description |
1007 1008 1009 1010 1011 1012 1013 1014
| `issues_enabled` | boolean | no | (deprecated) Enable issues for this project. Use `issues_access_level` instead |
| `merge_requests_enabled` | boolean | no | (deprecated) Enable merge requests for this project. Use `merge_requests_access_level` instead |
| `jobs_enabled` | boolean | no | (deprecated) Enable jobs for this project. Use `builds_access_level` instead |
| `wiki_enabled` | boolean | no | (deprecated) Enable wiki for this project. Use `wiki_access_level` instead |
| `snippets_enabled` | boolean | no | (deprecated) Enable snippets for this project. Use `snippets_access_level` instead |
| `issues_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `repository_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `merge_requests_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1015
| `forking_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1016 1017 1018
| `builds_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `wiki_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `snippets_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1019
| `pages_access_level` | string | no | One of `disabled`, `private`, `enabled` or `public` |
1020
| `emails_disabled` | boolean | no | Disable email notifications |
1021
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
1022
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
1023
| `container_expiration_policy_attributes` | hash | no | Update the container expiration policy for this project. Accepts: `cadence` (string), `keep_n` (string), `older_than` (string), `name_regex` (string), `enabled` (boolean) |
1024
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
1025
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
1026
| `import_url` | string | no | URL to import repository from |
1027
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
1028
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
1029
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
1030
| `merge_method` | string | no | Set the [merge method](#project-merge-method) used |
1031
| `autoclose_referenced_issues` | boolean | no | Set whether auto-closing referenced issues on default branch |
1032
| `remove_source_branch_after_merge` | boolean | no | Enable `Delete source branch` option by default for all new merge requests |
1033 1034
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
1035
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
1036
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
1037
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
1038
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
1039
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
1040
| `auto_cancel_pending_pipelines` | string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
1041
| `build_coverage_regex` | string | no | Test coverage parsing |
1042
| `ci_config_path` | string | no | The path to CI config file |
1043 1044
| `auto_devops_enabled` | boolean | no | Enable Auto DevOps for this project |
| `auto_devops_deploy_strategy` | string | no | Auto Deploy strategy (`continuous`, `manual` or `timed_incremental`) |
1045
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
1046
| `approvals_before_merge` | integer | no | **(STARTER)** How many approvers should approve merge requests by default |
1047
| `external_authorization_classification_label` | string | no | **(PREMIUM)** The classification label for the project |
1048 1049
| `mirror` | boolean | no | **(STARTER)** Enables pull mirroring in a project |
| `mirror_trigger_builds` | boolean | no | **(STARTER)** Pull mirroring triggers builds |
S
Steve 已提交
1050
| `initialize_with_readme` | boolean | no | `false` by default |
1051
| `template_name` | string | no | When used without `use_custom_template`, name of a [built-in project template](../gitlab-basics/create-project.md#built-in-templates). When used with `use_custom_template`, name of a custom project template |
1052
| `template_project_id` | integer | no | **(PREMIUM)** When used with `use_custom_template`, project ID of a custom project template. This is preferable to using `template_name` since `template_name` may be ambiguous. |
1053 1054
| `use_custom_template` | boolean | no | **(PREMIUM)** Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template |
| `group_with_project_templates_id` | integer | no | **(PREMIUM)** For group-level custom templates, specifies ID of group from which all the custom project templates are sourced. Leave empty for instance-level templates. Requires `use_custom_template` to be true |
1055
| `packages_enabled` | boolean | no | **(PREMIUM ONLY)** Enable or disable packages repository feature |
1056

1057
NOTE: **Note:** If your HTTP repository is not publicly accessible,
1058 1059 1060
add authentication information to the URL: `https://username:password@gitlab.company.com/group/project.git`
where `password` is a public access key with the `api` scope enabled.

1061
## Create project for user
1062

1063
Creates a new project owned by the specified user. Available only for admins.
1064

1065
```plaintext
1066 1067 1068
POST /projects/user/:user_id
```

1069 1070 1071 1072 1073 1074 1075
| 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 |
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
| `description` | string | no | Short project description |
1076 1077 1078 1079 1080 1081 1082 1083
| `issues_enabled` | boolean | no | (deprecated) Enable issues for this project. Use `issues_access_level` instead |
| `merge_requests_enabled` | boolean | no | (deprecated) Enable merge requests for this project. Use `merge_requests_access_level` instead |
| `jobs_enabled` | boolean | no | (deprecated) Enable jobs for this project. Use `builds_access_level` instead |
| `wiki_enabled` | boolean | no | (deprecated) Enable wiki for this project. Use `wiki_access_level` instead |
| `snippets_enabled` | boolean | no | (deprecated) Enable snippets for this project. Use `snippets_access_level` instead |
| `issues_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `repository_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `merge_requests_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1084
| `forking_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1085 1086 1087
| `builds_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `wiki_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `snippets_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1088
| `pages_access_level` | string | no | One of `disabled`, `private`, `enabled` or `public` |
1089
| `emails_disabled` | boolean | no | Disable email notifications |
1090
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
1091 1092
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
1093
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
1094
| `import_url` | string | no | URL to import repository from |
1095
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
1096
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
1097
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
1098
| `merge_method` | string | no | Set the [merge method](#project-merge-method) used |
1099
| `autoclose_referenced_issues` | boolean | no | Set whether auto-closing referenced issues on default branch |
1100
| `suggestion_commit_message` | string | no | The commit message used to apply merge request suggestions |
1101
| `remove_source_branch_after_merge` | boolean | no | Enable `Delete source branch` option by default for all new merge requests |
1102 1103
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
1104
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
1105
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
1106
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
1107
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
1108
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
1109
| `auto_cancel_pending_pipelines` | string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
1110
| `build_coverage_regex` | string | no | Test coverage parsing |
1111
| `ci_config_path` | string | no | The path to CI config file |
1112 1113
| `auto_devops_enabled` | boolean | no | Enable Auto DevOps for this project |
| `auto_devops_deploy_strategy` | string | no | Auto Deploy strategy (`continuous`, `manual` or `timed_incremental`) |
1114
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
1115
| `approvals_before_merge` | integer | no | **(STARTER)** How many approvers should approve merge requests by default |
1116
| `external_authorization_classification_label` | string | no | **(PREMIUM)** The classification label for the project |
1117 1118
| `mirror` | boolean | no | **(STARTER)** Enables pull mirroring in a project |
| `mirror_trigger_builds` | boolean | no | **(STARTER)** Pull mirroring triggers builds |
1119
| `initialize_with_readme` | boolean | no | `false` by default |
1120 1121 1122
| `template_name` | string | no | When used without `use_custom_template`, name of a [built-in project template](../gitlab-basics/create-project.md#built-in-templates). When used with `use_custom_template`, name of a custom project template |
| `use_custom_template` | boolean | no | **(PREMIUM)** Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template |
| `group_with_project_templates_id` | integer | no | **(PREMIUM)** For group-level custom templates, specifies ID of group from which all the custom project templates are sourced. Leave empty for instance-level templates. Requires `use_custom_template` to be true |
1123
| `packages_enabled` | boolean | no | **(PREMIUM ONLY)** Enable or disable packages repository feature |
1124

1125
NOTE: **Note:** If your HTTP repository is not publicly accessible,
1126 1127
add authentication information to the URL: `https://username:password@gitlab.company.com/group/project.git`
where `password` is a public access key with the `api` scope enabled.
A
Alex Denisov 已提交
1128

1129
## Edit project
1130

1131
Updates an existing project.
1132

1133
```plaintext
1134 1135 1136
PUT /projects/: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
| `name` | string | no | The name of the project |
1141
| `path` | string | no | Custom repository name for the project. By default generated based on name |
1142
| `default_branch` | string | no | `master` by default |
1143
| `description` | string | no | Short project description |
1144 1145 1146 1147 1148 1149 1150 1151
| `issues_enabled` | boolean | no | (deprecated) Enable issues for this project. Use `issues_access_level` instead |
| `merge_requests_enabled` | boolean | no | (deprecated) Enable merge requests for this project. Use `merge_requests_access_level` instead |
| `jobs_enabled` | boolean | no | (deprecated) Enable jobs for this project. Use `builds_access_level` instead |
| `wiki_enabled` | boolean | no | (deprecated) Enable wiki for this project. Use `wiki_access_level` instead |
| `snippets_enabled` | boolean | no | (deprecated) Enable snippets for this project. Use `snippets_access_level` instead |
| `issues_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `repository_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `merge_requests_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1152
| `forking_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1153 1154 1155
| `builds_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `wiki_access_level` | string | no | One of `disabled`, `private` or `enabled` |
| `snippets_access_level` | string | no | One of `disabled`, `private` or `enabled` |
1156
| `pages_access_level` | string | no | One of `disabled`, `private`, `enabled` or `public` |
1157
| `emails_disabled` | boolean | no | Disable email notifications |
1158
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
1159
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
1160
| `container_expiration_policy_attributes` | hash | no | Update the container expiration policy for this project. Accepts: `cadence` (string), `keep_n` (string), `older_than` (string), `name_regex` (string), `enabled` (boolean) |
1161
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
1162
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
1163
| `import_url` | string | no | URL to import repository from |
1164
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
1165
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
1166
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
1167
| `merge_method` | string | no | Set the [merge method](#project-merge-method) used |
1168
| `autoclose_referenced_issues` | boolean | no | Set whether auto-closing referenced issues on default branch |
1169
| `suggestion_commit_message` | string | no | The commit message used to apply merge request suggestions |
1170
| `remove_source_branch_after_merge` | boolean | no | Enable `Delete source branch` option by default for all new merge requests |
1171 1172
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
1173
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
1174
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
1175
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
1176
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
1177
| `auto_cancel_pending_pipelines` | string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
1178
| `build_coverage_regex` | string | no | Test coverage parsing |
1179
| `ci_config_path` | string | no | The path to CI config file |
1180
| `ci_default_git_depth` | integer | no | Default number of revisions for [shallow cloning](../ci/pipelines/settings.md#git-shallow-clone) |
1181 1182
| `auto_devops_enabled` | boolean | no | Enable Auto DevOps for this project |
| `auto_devops_deploy_strategy` | string | no | Auto Deploy strategy (`continuous`, `manual` or `timed_incremental`) |
1183
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
1184
| `approvals_before_merge` | integer | no | **(STARTER)** How many approvers should approve merge request by default |
1185
| `external_authorization_classification_label` | string | no | **(PREMIUM)** The classification label for the project |
1186 1187 1188 1189 1190 1191
| `mirror` | boolean | no | **(STARTER)** Enables pull mirroring in a project |
| `mirror_user_id` | integer | no | **(STARTER)** User responsible for all the activity surrounding a pull mirror event |
| `mirror_trigger_builds` | boolean | no | **(STARTER)** Pull mirroring triggers builds |
| `only_mirror_protected_branches` | boolean | no | **(STARTER)** Only mirror protected branches |
| `mirror_overwrites_diverged_branches` | boolean | no | **(STARTER)** Pull mirror overwrites diverged branches |
| `packages_enabled` | boolean | no | **(PREMIUM ONLY)** Enable or disable packages repository feature |
1192
| `service_desk_enabled` | boolean | no | **(PREMIUM ONLY)** Enable or disable service desk feature |
1193

1194
NOTE: **Note:** If your HTTP repository is not publicly accessible,
1195 1196
add authentication information to the URL: `https://username:password@gitlab.company.com/group/project.git`
where `password` is a public access key with the `api` scope enabled.
1197

1198
## Fork project
1199

1200
Forks a project into the user namespace of the authenticated user or the one provided.
1201

1202 1203 1204
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.
1205

1206
```plaintext
1207
POST /projects/:id/fork
1208 1209
```

1210 1211
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1212
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1213 1214 1215
| `namespace` | integer/string | no | (deprecated) The ID or path of the namespace that the project will be forked to |
| `namespace_id` | integer | no | The ID of the namespace that the project will be forked to |
| `namespace_path` | string | no | The path of the namespace that the project will be forked to |
1216 1217
| `path` | string | no | The path that will be assigned to the resultant project after forking |
| `name` | string | no | The name that will be assigned to the resultant project after forking |
1218

1219 1220 1221 1222 1223 1224
## 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

1225
```plaintext
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236
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 |
1237
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
1238
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
1239 1240 1241
| `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 |
1242
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
1243 1244
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
1245
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
1246

1247
```shell
1248
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/forks"
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
```

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",
I
Imre Farkas 已提交
1263
    "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
    "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,
1278
    "can_create_merge_request_in": true,
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
    "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,
1301
    "remove_source_branch_after_merge": false,
1302
    "request_access_enabled": false,
1303
    "merge_method": "merge",
1304
    "autoclose_referenced_issues": true,
1305
    "suggestion_commit_message": null,
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
    "_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"
    }
  }
]
```

1319
## Star a project
1320

1321
Stars a given project. Returns status code `304` if the project is already starred.
1322

1323
```plaintext
1324 1325 1326 1327 1328
POST /projects/:id/star
```

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

1331
```shell
1332
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/star"
1333 1334 1335 1336 1337 1338 1339 1340 1341
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1342
  "visibility": "internal",
1343 1344 1345
  "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",
I
Imre Farkas 已提交
1346
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357
  "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,
1358
  "jobs_enabled": true,
1359 1360
  "wiki_enabled": true,
  "snippets_enabled": false,
1361
  "can_create_merge_request_in": true,
1362
  "resolve_outdated_diff_discussions": false,
1363
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1364 1365
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1366 1367 1368 1369 1370
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1371 1372
    "kind": "group",
    "full_path": "diaspora"
1373
  },
1374
  "import_status": "none",
1375 1376
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
1377 1378 1379 1380 1381 1382 1383 1384
  "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
  "license": {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0",
    "nickname": "GNU LGPLv3",
    "html_url": "http://choosealicense.com/licenses/lgpl-3.0/",
    "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
  },
1385 1386
  "shared_runners_enabled": true,
  "forks_count": 0,
1387
  "star_count": 1,
1388
  "public_jobs": true,
1389
  "shared_with_groups": [],
J
James Lopez 已提交
1390
  "only_allow_merge_if_pipeline_succeeds": false,
1391
  "only_allow_merge_if_all_discussions_are_resolved": false,
1392
  "remove_source_branch_after_merge": false,
1393
  "request_access_enabled": false,
1394
  "merge_method": "merge",
1395
  "autoclose_referenced_issues": true,
1396
  "suggestion_commit_message": null,
1397 1398 1399 1400 1401 1402 1403 1404 1405
  "_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"
  }
1406 1407 1408
}
```

1409
## Unstar a project
1410

1411
Unstars a given project. Returns status code `304` if the project is not starred.
1412

1413
```plaintext
1414
POST /projects/:id/unstar
1415 1416 1417 1418
```

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

1421
```shell
1422
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unstar"
1423 1424 1425 1426 1427 1428 1429 1430 1431
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1432
  "visibility": "internal",
1433 1434 1435
  "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",
I
Imre Farkas 已提交
1436
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447
  "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,
1448
  "jobs_enabled": true,
1449 1450
  "wiki_enabled": true,
  "snippets_enabled": false,
1451
  "can_create_merge_request_in": true,
1452
  "resolve_outdated_diff_discussions": false,
1453
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1454 1455
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1456 1457 1458 1459 1460
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1461 1462
    "kind": "group",
    "full_path": "diaspora"
1463
  },
1464
  "import_status": "none",
1465 1466
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
1467 1468 1469 1470 1471 1472 1473 1474
  "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
  "license": {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0",
    "nickname": "GNU LGPLv3",
    "html_url": "http://choosealicense.com/licenses/lgpl-3.0/",
    "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
  },
1475 1476
  "shared_runners_enabled": true,
  "forks_count": 0,
1477
  "star_count": 0,
1478
  "public_jobs": true,
1479
  "shared_with_groups": [],
J
James Lopez 已提交
1480
  "only_allow_merge_if_pipeline_succeeds": false,
1481
  "only_allow_merge_if_all_discussions_are_resolved": false,
1482
  "remove_source_branch_after_merge": false,
1483
  "request_access_enabled": false,
1484
  "merge_method": "merge",
1485
  "autoclose_referenced_issues": true,
1486
  "suggestion_commit_message": null,
1487 1488 1489 1490 1491 1492 1493 1494 1495
  "_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"
  }
1496 1497 1498
}
```

1499 1500
## List Starrers of a project

C
Camil Staps 已提交
1501
List the users who starred the specified project.
1502

1503
```plaintext
1504 1505 1506 1507 1508
GET /projects/:id/starrers
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
C
Camil Staps 已提交
1509
| `search` | string | no | Search for specific users. |
1510

1511
```shell
1512 1513 1514 1515 1516 1517 1518 1519
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/starrers"
```

Example responses:

```json
[
  {
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
    "starred_since": "2019-01-28T14:47:30.642Z",
    "user":
      {
        "id": 1,
        "username": "jane_smith",
        "name": "Jane Smith",
        "state": "active",
        "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg",
        "web_url": "http://localhost:3000/jane_smith"
      }
1530
  },
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
    "starred_since": "2018-01-02T11:40:26.570Z",
    "user":
      {
        "id": 2,
        "username": "janine_smith",
        "name": "Janine Smith",
        "state": "blocked",
        "avatar_url": "http://gravatar.com/../e32131cd8.jpeg",
        "web_url": "http://localhost:3000/janine_smith"
      }
1541 1542 1543
]
```

1544 1545 1546 1547
## Languages

Get languages used in a project with percentage value.

1548
```plaintext
1549 1550 1551
GET /projects/:id/languages
```

1552
```shell
1553
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/languages"
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
```

Example response:

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

1567
## Archive a project
1568

1569
Archives the project if the user is either admin or the project owner of this project. This action is
1570 1571
idempotent, thus archiving an already archived project will not change the project.

1572
```plaintext
1573
POST /projects/:id/archive
1574 1575 1576 1577
```

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

1580
```shell
1581
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/archive"
1582 1583 1584 1585 1586 1587 1588 1589 1590
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1591
  "visibility": "private",
1592 1593 1594
  "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",
I
Imre Farkas 已提交
1595
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1596 1597 1598 1599 1600 1601 1602
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1603
    "created_at": "2013-09-30T13:46:02Z"
1604 1605 1606 1607 1608 1609 1610 1611
  },
  "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,
1612
  "jobs_enabled": true,
1613 1614
  "wiki_enabled": true,
  "snippets_enabled": false,
1615
  "can_create_merge_request_in": true,
1616
  "resolve_outdated_diff_discussions": false,
1617
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1618 1619
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1620 1621 1622 1623 1624
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1625 1626
    "kind": "group",
    "full_path": "diaspora"
1627
  },
1628 1629
  "import_status": "none",
  "import_error": null,
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
  "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",
J
J.D. Bean 已提交
1642 1643 1644 1645 1646 1647 1648 1649
  "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
  "license": {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0",
    "nickname": "GNU LGPLv3",
    "html_url": "http://choosealicense.com/licenses/lgpl-3.0/",
    "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
  },
1650 1651 1652
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1653
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1654
  "ci_default_git_depth": 50,
1655
  "public_jobs": true,
1656
  "shared_with_groups": [],
J
James Lopez 已提交
1657
  "only_allow_merge_if_pipeline_succeeds": false,
1658
  "only_allow_merge_if_all_discussions_are_resolved": false,
1659
  "remove_source_branch_after_merge": false,
1660
  "request_access_enabled": false,
1661
  "merge_method": "merge",
1662
  "autoclose_referenced_issues": true,
1663
  "suggestion_commit_message": null,
1664 1665 1666 1667 1668 1669 1670 1671 1672
  "_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"
  }
1673 1674 1675
}
```

1676
## Unarchive a project
1677

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

1681
```plaintext
S
Sergey Gnuskov 已提交
1682
POST /projects/:id/unarchive
1683 1684 1685 1686
```

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

1689
```shell
1690
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unarchive"
1691 1692 1693 1694 1695 1696 1697 1698 1699
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1700
  "visibility": "private",
1701 1702 1703
  "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",
I
Imre Farkas 已提交
1704
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1705 1706 1707 1708 1709 1710 1711
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1712
    "created_at": "2013-09-30T13:46:02Z"
1713 1714 1715 1716 1717 1718 1719 1720
  },
  "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,
1721
  "jobs_enabled": true,
1722 1723
  "wiki_enabled": true,
  "snippets_enabled": false,
1724
  "can_create_merge_request_in": true,
1725
  "resolve_outdated_diff_discussions": false,
1726
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1727 1728
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1729 1730 1731 1732 1733
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1734 1735
    "kind": "group",
    "full_path": "diaspora"
1736
  },
1737 1738
  "import_status": "none",
  "import_error": null,
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750
  "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",
J
J.D. Bean 已提交
1751 1752 1753 1754 1755 1756 1757 1758
  "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
  "license": {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0",
    "nickname": "GNU LGPLv3",
    "html_url": "http://choosealicense.com/licenses/lgpl-3.0/",
    "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
  },
1759 1760 1761
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1762
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1763
  "ci_default_git_depth": 50,
1764
  "public_jobs": true,
1765
  "shared_with_groups": [],
J
James Lopez 已提交
1766
  "only_allow_merge_if_pipeline_succeeds": false,
1767
  "only_allow_merge_if_all_discussions_are_resolved": false,
1768
  "remove_source_branch_after_merge": false,
1769
  "request_access_enabled": false,
1770
  "merge_method": "merge",
1771
  "autoclose_referenced_issues": true,
1772
  "suggestion_commit_message": null,
1773 1774 1775 1776 1777 1778 1779 1780 1781
  "_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"
  }
1782 1783 1784
}
```

1785
## Remove project
D
Dmitriy Zaporozhets 已提交
1786

1787 1788 1789
This endpoint either:

- Removes a project including all associated resources (issues, merge requests etc).
1790
- From [GitLab 12.6](https://gitlab.com/gitlab-org/gitlab/issues/32935) on [Premium or Silver](https://about.gitlab.com/pricing/) or higher tiers, marks a project for deletion. Actual
1791
  deletion happens after number of days specified in
1792
  [instance settings](../user/admin_area/settings/visibility_and_access_controls.md#default-deletion-adjourned-period-premium-only).
D
Dmitriy Zaporozhets 已提交
1793

1794
```plaintext
D
Dmitriy Zaporozhets 已提交
1795 1796 1797
DELETE /projects/:id
```

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

1802 1803
## Restore project marked for deletion **(PREMIUM)**

1804 1805
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/32935) in GitLab 12.6.

1806 1807
Restores project marked for deletion.

1808
```plaintext
1809 1810 1811 1812 1813 1814 1815
POST /projects/:id/restore
```

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

1816
## Upload a file
D
Douwe Maan 已提交
1817 1818 1819

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

1820
```plaintext
D
Douwe Maan 已提交
1821 1822 1823
POST /projects/:id/uploads
```

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

1829 1830 1831 1832 1833
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:

1834
```shell
1835
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "file=@dk.png" https://gitlab.example.com/api/v4/projects/5/uploads
1836 1837 1838 1839
```

Returned object:

D
Douwe Maan 已提交
1840 1841 1842 1843
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
1844
  "full_path": "/namespace1/project1/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
D
Douwe Maan 已提交
1845 1846 1847 1848
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

1849
>**Note**: The returned `url` is relative to the project path. The returned `full_path` is the absolute path to the file.
1850 1851
In Markdown contexts, the link is automatically expanded when the format in
`markdown` is used.
D
Douwe Maan 已提交
1852

1853
## Share project with group
1854 1855 1856

Allow to share project with group.

1857
```plaintext
1858 1859 1860
POST /projects/:id/share
```

1861 1862
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1863
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1864
| `group_id` | integer | yes | The ID of the group to share with |
1865
| `group_access` | integer | yes | The [permissions level](members.md) to grant the group |
1866
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1867

1868
## Delete a shared project link within a group
1869 1870 1871

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

1872
```plaintext
1873 1874 1875 1876 1877
DELETE /projects/:id/share/:group_id
```

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

1881
```shell
1882
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/5/share/17
1883 1884
```

1885 1886
## Hooks

1887 1888 1889
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1890 1891
### List project hooks

1892
Get a list of project hooks.
M
miks 已提交
1893

1894
```plaintext
M
miks 已提交
1895 1896 1897
GET /projects/:id/hooks
```

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

1902
### Get project hook
1903

1904
Get a specific hook for a project.
1905

1906
```plaintext
1907 1908 1909
GET /projects/:id/hooks/:hook_id
```

1910 1911
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1912
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1913
| `hook_id` | integer | yes | The ID of a project hook |
1914

1915 1916 1917 1918
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1919
  "project_id": 3,
B
Ben Boeckel 已提交
1920
  "push_events": true,
D
Duana Saskia 已提交
1921
  "push_events_branch_filter": "",
B
Ben Boeckel 已提交
1922
  "issues_events": true,
1923
  "confidential_issues_events": true,
B
Ben Boeckel 已提交
1924
  "merge_requests_events": true,
1925
  "tag_push_events": true,
B
Ben Boeckel 已提交
1926
  "note_events": true,
1927
  "job_events": true,
1928
  "pipeline_events": true,
1929
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1930
  "enable_ssl_verification": true,
1931 1932 1933 1934 1935 1936
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1937
Adds a hook to a specified project.
M
miks 已提交
1938

1939
```plaintext
M
miks 已提交
1940 1941 1942
POST /projects/:id/hooks
```

1943 1944
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1945
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1946 1947
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
D
Duana Saskia 已提交
1948
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1949
| `issues_events` | boolean | no | Trigger hook on issues events |
1950
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1951 1952 1953
| `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 |
1954
| `job_events` | boolean | no | Trigger hook on job events |
1955
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
1956
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
1957
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1958
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1959

1960 1961
### Edit project hook

1962
Edits a hook for a specified project.
1963

1964
```plaintext
1965 1966 1967
PUT /projects/:id/hooks/:hook_id
```

1968 1969
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1970
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1971 1972 1973
| `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 |
D
Duana Saskia 已提交
1974
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1975
| `issues_events` | boolean | no | Trigger hook on issues events |
1976
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1977 1978 1979
| `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 |
1980
| `job_events` | boolean | no | Trigger hook on job events |
1981 1982 1983
| `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 |
1984
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1985

1986
### Delete project hook
M
miks 已提交
1987

1988
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1989
Either the hook is available or not.
M
miks 已提交
1990

1991
```plaintext
1992
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1993 1994
```

1995 1996
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1997
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1998
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1999

2000 2001
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.
2002

2003
## Fork relationship
2004

2005
Allows modification of the forked relationship between existing projects. Available only for project owners and admins.
2006

2007
### Create a forked from/to relation between existing projects
2008

2009
```plaintext
2010 2011 2012
POST /projects/:id/fork/:forked_from_id
```

2013 2014
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2015
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
2016
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
2017 2018 2019

### Delete an existing forked from relationship

2020
```plaintext
2021 2022 2023
DELETE /projects/:id/fork
```

2024 2025
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2026
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
2027 2028 2029

## Search for projects by name

2030 2031 2032
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 已提交
2033

2034
```plaintext
2035
GET /projects
I
Izaak Alpert 已提交
2036 2037
```

2038 2039
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2040
| `search` | string | yes | A string contained in the project name |
2041
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
2042
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
2043

2044
```shell
2045
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects?search=test
2046 2047
```

2048 2049
## Start the Housekeeping task for a Project

2050
> Introduced in GitLab 9.0.
2051

2052
```plaintext
2053 2054 2055
POST /projects/:id/housekeeping
```

2056 2057 2058 2059
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |

2060
## Push Rules **(STARTER)**
2061 2062 2063 2064 2065

### Get project push rules

Get the push rules of a project.

2066
```plaintext
2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078
GET /projects/:id/push_rule
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |

```json
{
  "id": 1,
  "project_id": 3,
  "commit_message_regex": "Fixes \d+\..*",
2079
  "commit_message_negative_regex": "ssh\:\/\/",
2080 2081 2082 2083 2084 2085 2086 2087
  "branch_name_regex": "",
  "deny_delete_tag": false,
  "created_at": "2012-10-12T17:04:47Z",
  "member_check": false,
  "prevent_secrets": false,
  "author_email_regex": "",
  "file_name_regex": "",
  "max_file_size": 5,
2088 2089
  "commit_committer_check": false,
  "reject_unsigned_commits": false
2090 2091 2092
}
```

2093
Users on GitLab [Premium, Silver, or higher](https://about.gitlab.com/pricing/) will also see
2094
the `commit_committer_check` and `reject_unsigned_commits` parameters:
2095

2096 2097 2098 2099
```json
{
  "id": 1,
  "project_id": 3,
2100 2101
  "commit_committer_check": false,
  "reject_unsigned_commits": false
2102 2103 2104
  ...
}
```
2105 2106 2107 2108 2109

### Add project push rule

Adds a push rule to a specified project.

2110
```plaintext
2111 2112 2113
POST /projects/:id/push_rule
```

2114 2115 2116 2117 2118 2119 2120 2121 2122 2123
| Attribute                                     | Type           | Required | Description |
| --------------------------------------------- | -------------- | -------- | ----------- |
| `id`                                          | integer/string | yes      | The ID of the project or NAMESPACE/PROJECT_NAME |
| `deny_delete_tag` **(STARTER)**               | boolean        | no       | Deny deleting a tag |
| `member_check` **(STARTER)**                  | boolean        | no       | Restrict commits by author (email) to existing GitLab users |
| `prevent_secrets` **(STARTER)**               | boolean        | no       | GitLab will reject any files that are likely to contain secrets |
| `commit_message_regex` **(STARTER)**          | string         | no       | All commit messages must match this, e.g. `Fixed \d+\..*` |
| `commit_message_negative_regex` **(STARTER)** | string         | no       | No commit message is allowed to match this, e.g. `ssh\:\/\/` |
| `branch_name_regex` **(STARTER)**             | string         | no       | All branch names must match this, e.g. `(feature|hotfix)\/*` |
| `author_email_regex` **(STARTER)**            | string         | no       | All commit author emails must match this, e.g. `@my-company.com$` |
2124
| `file_name_regex` **(STARTER)**               | string         | no       | All committed filenames must **not** match this, e.g. `(jar|exe)$` |
2125 2126
| `max_file_size` **(STARTER)**                 | integer        | no       | Maximum file size (MB) |
| `commit_committer_check` **(PREMIUM)**        | boolean        | no       | Users can only push commits to this repository that were committed with one of their own verified emails. |
2127
| `reject_unsigned_commits` **(PREMIUM)**        | boolean        | no       | Reject commit when it is not signed through GPG. |
2128 2129 2130 2131 2132

### Edit project push rule

Edits a push rule for a specified project.

2133
```plaintext
2134 2135 2136
PUT /projects/:id/push_rule
```

2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
| Attribute                                     | Type           | Required | Description |
| --------------------------------------------- | -------------- | -------- | ----------- |
| `id`                                          | integer/string | yes      | The ID of the project or NAMESPACE/PROJECT_NAME |
| `deny_delete_tag` **(STARTER)**               | boolean        | no       | Deny deleting a tag |
| `member_check` **(STARTER)**                  | boolean        | no       | Restrict commits by author (email) to existing GitLab users |
| `prevent_secrets` **(STARTER)**               | boolean        | no       | GitLab will reject any files that are likely to contain secrets |
| `commit_message_regex` **(STARTER)**          | string         | no       | All commit messages must match this, e.g. `Fixed \d+\..*` |
| `commit_message_negative_regex` **(STARTER)** | string         | no       | No commit message is allowed to match this, e.g. `ssh\:\/\/` |
| `branch_name_regex` **(STARTER)**             | string         | no       | All branch names must match this, e.g. `(feature|hotfix)\/*` |
| `author_email_regex` **(STARTER)**            | string         | no       | All commit author emails must match this, e.g. `@my-company.com$` |
2147
| `file_name_regex` **(STARTER)**               | string         | no       | All committed filenames must **not** match this, e.g. `(jar|exe)$` |
2148 2149
| `max_file_size` **(STARTER)**                 | integer        | no       | Maximum file size (MB) |
| `commit_committer_check` **(PREMIUM)**        | boolean        | no       | Users can only push commits to this repository that were committed with one of their own verified emails. |
2150
| `reject_unsigned_commits` **(PREMIUM)**        | boolean        | no       | Reject commits when they are not GPG signed. |
2151 2152 2153 2154 2155 2156 2157 2158

### Delete project push rule

> Introduced in [GitLab Starter](https://about.gitlab.com/pricing/) 9.0.

Removes a push rule from a project. This is an idempotent method and can be called multiple times.
Either the push rule is available or not.

2159
```plaintext
2160 2161 2162
DELETE /projects/:id/push_rule
```

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

2167 2168 2169
## Transfer a project to a new namespace

> Introduced in GitLab 11.1.
2170

2171
```plaintext
2172 2173 2174 2175 2176 2177 2178
PUT /projects/:id/transfer
```

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `namespace` | integer/string | yes | The ID or path of the namespace to transfer to project to |

2179 2180 2181 2182
## Branches

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

J
James Lopez 已提交
2183 2184
## Project Import/Export

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

2187 2188 2189
## Project members

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

2191
## Start the pull mirroring process for a Project **(STARTER)**
2192

2193
> Introduced in [GitLab Starter](https://about.gitlab.com/pricing/) 10.3.
2194

2195
```plaintext
2196 2197 2198 2199 2200 2201 2202
POST /projects/:id/mirror/pull
```

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

2203
```shell
2204 2205 2206
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/mirror/pull
```

2207 2208 2209
## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
2210 2211 2212

## Issue and merge request description templates

2213 2214
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).

2215
## Download snapshot of a Git repository
2216 2217 2218 2219 2220

> Introduced in GitLab 10.7

This endpoint may only be accessed by an administrative user.

2221
Download a snapshot of the project (or wiki, if requested) Git repository. This
2222 2223 2224 2225 2226 2227
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.

2228
```plaintext
2229 2230 2231 2232 2233 2234 2235
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 |
2236

2237
[ce-27427]: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/27427