projects.md 69.2 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 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 58 59 60
| `with_programming_language`   | string  | no | Limit by projects which use the given programming language |
| `wiki_checksum_failed`        | boolean | no | **[PREMIUM]** Limit projects where the wiki checksum calculation has failed *([Introduced](https://gitlab.com/gitlab-org/gitlab-ee/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-ee/merge_requests/6137) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.2)* |
| `min_access_level`            | integer | no | Limit by current user minimal [access level](members.md) |
V
vanadium23 已提交
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
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 已提交
97 98 99 100 101 102 103 104 105 106
```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 已提交
107
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
V
vanadium23 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    "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,
127
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
    "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",
146
    "ci_default_git_depth": 50,
V
vanadium23 已提交
147 148 149 150 151
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
152
    "merge_method": "merge",
V
vanadium23 已提交
153 154 155 156
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
157
      "wiki_size" : 0,
V
vanadium23 已提交
158
      "lfs_objects_size": 0,
159 160
      "job_artifacts_size": 0,
      "packages_size": 0
161 162 163 164 165 166 167 168 169 170
    },
    "_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 已提交
171 172 173 174 175 176 177 178 179
  },
  {
    "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 已提交
180
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
V
vanadium23 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    "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,
200
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
    "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",
230
    "ci_default_git_depth": 0,
V
vanadium23 已提交
231 232 233 234 235
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
236
    "merge_method": "merge",
V
vanadium23 已提交
237 238 239 240
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
241
      "wiki_size" : 0,
V
vanadium23 已提交
242
      "lfs_objects_size": 0,
243 244
      "job_artifacts_size": 0,
      "packages_size": 0
245 246 247 248 249 250 251 252 253
    },
    "_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 已提交
254 255 256 257 258
    }
  }
]
```

259 260 261 262 263 264 265 266 267 268 269 270 271 272
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,
    ...
  }
]
```

273 274 275 276 277 278
You can filter by [custom attributes](custom_attributes.md) with:

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

279
## List user projects
V
vanadium23 已提交
280

D
Davin Walker 已提交
281
Get a list of visible projects owned by the given user. When accessed without authentication, only public projects are returned.
V
vanadium23 已提交
282 283 284 285 286 287 288 289 290 291 292 293 294

```
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 |
295
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
296
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
V
vanadium23 已提交
297 298 299
| `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 |
300
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
301 302
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
303
| `with_programming_language` | string | no | Limit by projects which use the given programming language |
304
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
305

N
Nihad Abbasov 已提交
306 307 308
```json
[
  {
M
Marin Jankovski 已提交
309
    "id": 4,
N
Nihad Abbasov 已提交
310 311
    "description": null,
    "default_branch": "master",
312
    "visibility": "private",
M
Marin Jankovski 已提交
313 314 315
    "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 已提交
316
    "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md",
317 318 319 320
    "tag_list": [
      "example",
      "disapora client"
    ],
N
Nihad Abbasov 已提交
321
    "owner": {
M
Marin Jankovski 已提交
322 323
      "id": 3,
      "name": "Diaspora",
B
Ben Boeckel 已提交
324
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
325
    },
M
Marin Jankovski 已提交
326 327 328 329 330
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
S
Stan Hu 已提交
331
    "open_issues_count": 1,
M
Marin Jankovski 已提交
332
    "merge_requests_enabled": true,
333
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
334
    "wiki_enabled": true,
M
Marin Jankovski 已提交
335
    "snippets_enabled": false,
336
    "resolve_outdated_diff_discussions": false,
337
    "container_registry_enabled": false,
B
Ben Boeckel 已提交
338 339
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
340
    "creator_id": 3,
M
Marin Jankovski 已提交
341 342 343 344
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
345 346
      "kind": "group",
      "full_path": "diaspora"
347
    },
348
    "import_status": "none",
S
sue445 已提交
349
    "archived": false,
T
Tomasz Maczukin 已提交
350 351 352
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
353 354
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
355
    "ci_default_git_depth": 50,
356
    "public_jobs": true,
357
    "shared_with_groups": [],
J
James Lopez 已提交
358
    "only_allow_merge_if_pipeline_succeeds": false,
359
    "only_allow_merge_if_all_discussions_are_resolved": false,
360
    "request_access_enabled": false,
361
    "merge_method": "merge",
362 363 364 365
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
366
      "wiki_size" : 0,
367
      "lfs_objects_size": 0,
368 369
      "job_artifacts_size": 0,
      "packages_size": 0
370 371 372 373 374 375 376 377 378
    },
    "_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"
379
    }
N
Nihad Abbasov 已提交
380 381
  },
  {
M
Marin Jankovski 已提交
382
    "id": 6,
N
Nihad Abbasov 已提交
383
    "description": null,
M
Marin Jankovski 已提交
384
    "default_branch": "master",
385
    "visibility": "private",
M
Marin Jankovski 已提交
386 387 388
    "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 已提交
389
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
390 391 392 393
    "tag_list": [
      "example",
      "puppet"
    ],
J
Johannes Schleifenbaum 已提交
394
    "owner": {
M
Marin Jankovski 已提交
395 396 397
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
398
    },
M
Marin Jankovski 已提交
399 400 401 402
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
N
Nihad Abbasov 已提交
403
    "issues_enabled": true,
S
Stan Hu 已提交
404
    "open_issues_count": 1,
N
Nihad Abbasov 已提交
405
    "merge_requests_enabled": true,
406
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
407
    "wiki_enabled": true,
M
Marin Jankovski 已提交
408
    "snippets_enabled": false,
409
    "resolve_outdated_diff_discussions": false,
410
    "container_registry_enabled": false,
M
Marin Jankovski 已提交
411 412
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
413
    "creator_id": 3,
J
Johannes Schleifenbaum 已提交
414
    "namespace": {
M
Marin Jankovski 已提交
415 416 417
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
418 419
      "kind": "group",
      "full_path": "brightbox"
420
    },
421 422
    "import_status": "none",
    "import_error": null,
423 424 425 426 427 428 429 430 431 432
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
S
sue445 已提交
433
    "archived": false,
T
Tomasz Maczukin 已提交
434 435 436 437
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
438
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
439
    "ci_default_git_depth": 0,
440
    "public_jobs": true,
441
    "shared_with_groups": [],
J
James Lopez 已提交
442
    "only_allow_merge_if_pipeline_succeeds": false,
443
    "only_allow_merge_if_all_discussions_are_resolved": false,
444
    "request_access_enabled": false,
445
    "merge_method": "merge",
446 447 448 449
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
450
      "wiki_size" : 0,
451
      "lfs_objects_size": 0,
452 453
      "job_artifacts_size": 0,
      "packages_size": 0
454 455 456 457 458 459 460 461 462
    },
    "_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"
463
    }
464 465 466 467
  }
]
```

468
## Get single project
N
Nihad Abbasov 已提交
469

470 471
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
472 473 474 475 476

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

477 478
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
479
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
480
| `statistics` | boolean | no | Include project statistics |
J
J.D. Bean 已提交
481
| `license` | boolean | no | Include project license data |
482
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
N
Nihad Abbasov 已提交
483

A
Alex Denisov 已提交
484 485
```json
{
M
Marin Jankovski 已提交
486
  "id": 3,
A
Alex Denisov 已提交
487
  "description": null,
M
Marin Jankovski 已提交
488
  "default_branch": "master",
489
  "visibility": "private",
M
Marin Jankovski 已提交
490 491 492
  "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 已提交
493
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
494 495 496 497
  "tag_list": [
    "example",
    "disapora project"
  ],
A
Alex Denisov 已提交
498
  "owner": {
M
Marin Jankovski 已提交
499 500
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
501
    "created_at": "2013-09-30T13:46:02Z"
A
Alex Denisov 已提交
502
  },
M
Marin Jankovski 已提交
503 504 505 506
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
A
Alex Denisov 已提交
507
  "issues_enabled": true,
S
Stan Hu 已提交
508
  "open_issues_count": 1,
A
Alex Denisov 已提交
509
  "merge_requests_enabled": true,
510
  "jobs_enabled": true,
A
Alex Denisov 已提交
511
  "wiki_enabled": true,
M
Marin Jankovski 已提交
512
  "snippets_enabled": false,
513
  "resolve_outdated_diff_discussions": false,
514
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
515 516
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
517
  "creator_id": 3,
M
Marin Jankovski 已提交
518 519 520 521
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
522
    "kind": "group",
523 524 525
    "full_path": "diaspora",
    "avatar_url": "http://localhost:3000/uploads/group/avatar/3/foo.jpg",
    "web_url": "http://localhost:3000/groups/diaspora"
J
Johannes Schleifenbaum 已提交
526
  },
527 528
  "import_status": "none",
  "import_error": null,
D
Dmitriy Zaporozhets 已提交
529 530 531 532 533 534 535 536 537
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
538
  },
S
sue445 已提交
539
  "archived": false,
T
Tomasz Maczukin 已提交
540
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
541 542 543 544 545 546 547 548
  "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"
  },
T
Tomasz Maczukin 已提交
549 550 551
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
552
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
553
  "ci_default_git_depth": 50,
554
  "public_jobs": true,
555 556 557 558
  "shared_with_groups": [
    {
      "group_id": 4,
      "group_name": "Twitter",
559
      "group_full_path": "twitter",
560 561 562 563 564
      "group_access_level": 30
    },
    {
      "group_id": 3,
      "group_name": "Gitlab Org",
565
      "group_full_path": "gitlab-org",
566 567
      "group_access_level": 10
    }
568
  ],
569
  "repository_storage": "default",
J
James Lopez 已提交
570
  "only_allow_merge_if_pipeline_succeeds": false,
571
  "only_allow_merge_if_all_discussions_are_resolved": false,
572
  "printing_merge_requests_link_enabled": true,
573
  "request_access_enabled": false,
574
  "merge_method": "merge",
575 576 577 578
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
579
    "wiki_size" : 0,
580
    "lfs_objects_size": 0,
581 582
    "job_artifacts_size": 0,
    "packages_size": 0
583 584 585 586 587 588 589 590 591
  },
  "_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"
592
  }
A
Alex Denisov 已提交
593 594 595
}
```

596 597 598 599 600 601 602 603 604 605 606 607
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,
  ...
}
```

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

610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
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",
      "path":"gitlab-ce",
      "path_with_namespace":"gitlab-org/gitlab-ce",
      "created_at":"2013-09-26T06:02:36.000Z",
      "default_branch":"master",
      "tag_list":[],
      "ssh_url_to_repo":"git@gitlab.com:gitlab-org/gitlab-ce.git",
      "http_url_to_repo":"https://gitlab.com/gitlab-org/gitlab-ce.git",
      "web_url":"https://gitlab.com/gitlab-org/gitlab-ce",
      "avatar_url":"https://assets.gitlab-static.net/uploads/-/system/project/avatar/13083/logo-extra-whitespace.png",
J
J.D. Bean 已提交
633 634 635 636 637 638 639 640
      "license_url": "https://gitlab.com/gitlab-org/gitlab-ce/blob/master/LICENSE",
      "license": {
        "key": "mit",
        "name": "MIT License",
        "nickname": null,
        "html_url": "http://choosealicense.com/licenses/mit/",
        "source_url": "https://opensource.org/licenses/MIT",
      },
641 642
      "star_count":3812,
      "forks_count":3561,
643 644 645 646 647 648 649 650 651
      "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
      }
652 653 654 655 656 657 658
   }

   ...

}
```

659
## Get project users
D
Dmitriy Zaporozhets 已提交
660

661
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
662

663 664 665
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
666

667 668
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
669 670
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
671
```json
J
Johannes Schleifenbaum 已提交
672 673
[
  {
674 675 676 677 678 679
    "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 已提交
680
  },
J
Johannes Schleifenbaum 已提交
681
  {
682 683 684 685 686 687
    "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 已提交
688 689
  }
]
D
Dmitriy Zaporozhets 已提交
690 691
```

692
## Get project events
D
Dmitriy Zaporozhets 已提交
693

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

696
## Create project
A
Alex Denisov 已提交
697

698
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
699 700 701 702 703

```
POST /projects
```

704 705
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
706 707
| `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). |
708
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
709
| `default_branch` | string | no | `master` by default |
710
| `description` | string | no | Short project description |
711 712 713 714 715 716 717 718 719 720 721
| `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` |
| `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` |
722
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
723 724
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
725
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
726
| `import_url` | string | no | URL to import repository from |
727
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
728
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
729
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
730
| `merge_method` | string | no | Set the merge method used |
731 732
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
733
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
734
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
735
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
736
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
737
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
738
| `build_coverage_regex` | string | no | Test coverage parsing |
739
| `ci_config_path` | string | no | The path to CI config file |
740 741 742 743
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
| `approvals_before_merge` | integer | no | **[STARTER]** How many approvers should approve merge requests by default |
| `mirror` | boolean | no | **[STARTER]** Enables pull mirroring in a project |
| `mirror_trigger_builds` | boolean | no | **[STARTER]** Pull mirroring triggers builds |
S
Steve 已提交
744
| `initialize_with_readme` | boolean | no | `false` by default |
745

746 747 748 749
>**Note**: If your HTTP repository is not publicly accessible,
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.

750
## Create project for user
751

752
Creates a new project owned by the specified user. Available only for admins.
753 754 755 756 757

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

758 759 760 761 762 763 764
| 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 |
765 766 767 768 769 770 771 772 773 774 775
| `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` |
| `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` |
776
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
777 778
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
779
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
780
| `import_url` | string | no | URL to import repository from |
781
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
782
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
783
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
784
| `merge_method` | string | no | Set the merge method used |
785 786
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
787
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
788
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
789
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
790
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
791
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
792
| `build_coverage_regex` | string | no | Test coverage parsing |
793
| `ci_config_path` | string | no | The path to CI config file |
794 795 796 797 798 799 800 801 802
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
| `approvals_before_merge` | integer | no | **[STARTER]** How many approvers should approve merge requests by default |
| `external_authorization_classification_label` | string | no | **[CORE ONLY]** The classification label for the project |
| `mirror` | boolean | no | **[STARTER]** Enables pull mirroring in a project |
| `mirror_trigger_builds` | boolean | no | **[STARTER]** Pull mirroring triggers builds |

>**Note**: If your HTTP repository is not publicly accessible,
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 已提交
803

804
## Edit project
805

806
Updates an existing project.
807 808 809 810 811

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

812 813
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
814
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
815
| `name` | string | no | The name of the project |
816
| `path` | string | no | Custom repository name for the project. By default generated based on name |
817
| `default_branch` | string | no | `master` by default |
818
| `description` | string | no | Short project description |
819 820 821 822 823 824 825 826 827 828 829
| `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` |
| `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` |
830
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
831 832
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
833
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
834
| `import_url` | string | no | URL to import repository from |
835
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
836
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
837
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
838
| `merge_method` | string | no | Set the merge method used |
839 840
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
841
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
842
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
843
| `build_git_strategy` | string | no | The Git strategy. Defaults to `fetch` |
844
| `build_timeout` | integer | no | The maximum amount of time in minutes that a job is able run (in seconds) |
845
| `build_coverage_regex` | string | no | Test coverage parsing |
846
| `ci_config_path` | string | no | The path to CI config file |
847
| `ci_default_git_depth` | integer | no | Default number of revisions for [shallow cloning](../user/project/pipelines/settings.md#git-shallow-clone) |
848 849 850 851 852 853 854 855 856 857 858 859 860
| `repository_storage` | string | no | Which storage shard the repository is on. Available only to admins |
| `approvals_before_merge` | integer | no | **[STARTER]** How many approvers should approve merge request by default |
| `external_authorization_classification_label` | string | no | **[CORE ONLY]** The classification label for the project |
| `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 |

>**Note**: If your HTTP repository is not publicly accessible,
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.
861

862
## Fork project
863

864
Forks a project into the user namespace of the authenticated user or the one provided.
865

866 867 868
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.
869

870
```
871
POST /projects/:id/fork
872 873
```

874 875
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
876
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
877
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
878 879
| `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 |
880

881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898
## List Forks of a project

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

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

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

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `archived` | boolean | no | Limit by archived status |
| `visibility` | string | no | Limit by visibility `public`, `internal`, or `private` |
| `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at` |
| `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc` |
| `search` | string | no | Return list of projects matching the search criteria |
899
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
900
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
901 902 903
| `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 |
904
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
905 906
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
907
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
908 909

```bash
910
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/forks"
911 912 913 914 915 916 917 918 919 920 921 922 923 924
```

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 已提交
925
    "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962
    "tag_list": [
      "example",
      "disapora project"
    ],
    "name": "Diaspora Project Site",
    "name_with_namespace": "Diaspora / Diaspora Project Site",
    "path": "diaspora-project-site",
    "path_with_namespace": "diaspora/diaspora-project-site",
    "issues_enabled": true,
    "open_issues_count": 1,
    "merge_requests_enabled": true,
    "jobs_enabled": true,
    "wiki_enabled": true,
    "snippets_enabled": false,
    "resolve_outdated_diff_discussions": false,
    "container_registry_enabled": false,
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "creator_id": 3,
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
      "kind": "group",
      "full_path": "diaspora"
    },
    "import_status": "none",
    "archived": true,
    "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 1,
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
963
    "merge_method": "merge",
964 965 966 967 968 969 970 971 972 973 974 975 976
    "_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"
    }
  }
]
```

977
## Star a project
978

979
Stars a given project. Returns status code `304` if the project is already starred.
980 981 982 983 984 985 986

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

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

```bash
990
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/star"
991 992 993 994 995 996 997 998 999
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1000
  "visibility": "internal",
1001 1002 1003
  "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 已提交
1004
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
  "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,
1016
  "jobs_enabled": true,
1017 1018
  "wiki_enabled": true,
  "snippets_enabled": false,
1019
  "resolve_outdated_diff_discussions": false,
1020
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1021 1022
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1023 1024 1025 1026 1027
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1028 1029
    "kind": "group",
    "full_path": "diaspora"
1030
  },
1031
  "import_status": "none",
1032 1033
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
1034 1035 1036 1037 1038 1039 1040 1041
  "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"
  },
1042 1043
  "shared_runners_enabled": true,
  "forks_count": 0,
1044
  "star_count": 1,
1045
  "public_jobs": true,
1046
  "shared_with_groups": [],
J
James Lopez 已提交
1047
  "only_allow_merge_if_pipeline_succeeds": false,
1048
  "only_allow_merge_if_all_discussions_are_resolved": false,
1049
  "request_access_enabled": false,
1050
  "merge_method": "merge",
1051 1052 1053 1054 1055 1056 1057 1058 1059
  "_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"
  }
1060 1061 1062
}
```

1063
## Unstar a project
1064

1065
Unstars a given project. Returns status code `304` if the project is not starred.
1066 1067

```
1068
POST /projects/:id/unstar
1069 1070 1071 1072
```

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

```bash
1076
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unstar"
1077 1078 1079 1080 1081 1082 1083 1084 1085
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1086
  "visibility": "internal",
1087 1088 1089
  "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 已提交
1090
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
  "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,
1102
  "jobs_enabled": true,
1103 1104
  "wiki_enabled": true,
  "snippets_enabled": false,
1105
  "resolve_outdated_diff_discussions": false,
1106
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1107 1108
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1109 1110 1111 1112 1113
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1114 1115
    "kind": "group",
    "full_path": "diaspora"
1116
  },
1117
  "import_status": "none",
1118 1119
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
1120 1121 1122 1123 1124 1125 1126 1127
  "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"
  },
1128 1129
  "shared_runners_enabled": true,
  "forks_count": 0,
1130
  "star_count": 0,
1131
  "public_jobs": true,
1132
  "shared_with_groups": [],
J
James Lopez 已提交
1133
  "only_allow_merge_if_pipeline_succeeds": false,
1134
  "only_allow_merge_if_all_discussions_are_resolved": false,
1135
  "request_access_enabled": false,
1136
  "merge_method": "merge",
1137 1138 1139 1140 1141 1142 1143 1144 1145
  "_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"
  }
1146 1147 1148
}
```

1149 1150 1151 1152 1153 1154 1155 1156 1157
## Languages

Get languages used in a project with percentage value.

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

```bash
1158
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/languages"
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
```

Example response:

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

1172
## Archive a project
1173

1174
Archives the project if the user is either admin or the project owner of this project. This action is
1175 1176 1177
idempotent, thus archiving an already archived project will not change the project.

```
1178
POST /projects/:id/archive
1179 1180 1181 1182
```

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

```bash
1186
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/archive"
1187 1188 1189 1190 1191 1192 1193 1194 1195
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1196
  "visibility": "private",
1197 1198 1199
  "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 已提交
1200
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1201 1202 1203 1204 1205 1206 1207
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1208
    "created_at": "2013-09-30T13:46:02Z"
1209 1210 1211 1212 1213 1214 1215 1216
  },
  "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,
1217
  "jobs_enabled": true,
1218 1219
  "wiki_enabled": true,
  "snippets_enabled": false,
1220
  "resolve_outdated_diff_discussions": false,
1221
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1222 1223
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1224 1225 1226 1227 1228
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1229 1230
    "kind": "group",
    "full_path": "diaspora"
1231
  },
1232 1233
  "import_status": "none",
  "import_error": null,
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245
  "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 已提交
1246 1247 1248 1249 1250 1251 1252 1253
  "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"
  },
1254 1255 1256
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1257
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1258
  "ci_default_git_depth": 50,
1259
  "public_jobs": true,
1260
  "shared_with_groups": [],
J
James Lopez 已提交
1261
  "only_allow_merge_if_pipeline_succeeds": false,
1262
  "only_allow_merge_if_all_discussions_are_resolved": false,
1263
  "request_access_enabled": false,
1264
  "merge_method": "merge",
1265 1266 1267 1268 1269 1270 1271 1272 1273
  "_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"
  }
1274 1275 1276
}
```

1277
## Unarchive a project
1278

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

```
S
Sergey Gnuskov 已提交
1283
POST /projects/:id/unarchive
1284 1285 1286 1287
```

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

```bash
1291
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unarchive"
1292 1293 1294 1295 1296 1297 1298 1299 1300
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1301
  "visibility": "private",
1302 1303 1304
  "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 已提交
1305
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1306 1307 1308 1309 1310 1311 1312
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1313
    "created_at": "2013-09-30T13:46:02Z"
1314 1315 1316 1317 1318 1319 1320 1321
  },
  "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,
1322
  "jobs_enabled": true,
1323 1324
  "wiki_enabled": true,
  "snippets_enabled": false,
1325
  "resolve_outdated_diff_discussions": false,
1326
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1327 1328
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1329 1330 1331 1332 1333
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1334 1335
    "kind": "group",
    "full_path": "diaspora"
1336
  },
1337 1338
  "import_status": "none",
  "import_error": null,
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
  "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 已提交
1351 1352 1353 1354 1355 1356 1357 1358
  "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"
  },
1359 1360 1361
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1362
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1363
  "ci_default_git_depth": 50,
1364
  "public_jobs": true,
1365
  "shared_with_groups": [],
J
James Lopez 已提交
1366
  "only_allow_merge_if_pipeline_succeeds": false,
1367
  "only_allow_merge_if_all_discussions_are_resolved": false,
1368
  "request_access_enabled": false,
1369
  "merge_method": "merge",
1370 1371 1372 1373 1374 1375 1376 1377 1378
  "_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"
  }
1379 1380 1381
}
```

1382
## Remove project
D
Dmitriy Zaporozhets 已提交
1383

1384
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1385 1386 1387 1388 1389

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

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

1394
## Upload a file
D
Douwe Maan 已提交
1395 1396 1397 1398 1399 1400 1401

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

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

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

1407 1408 1409 1410 1411 1412
To upload a file from your filesystem, use the `--form` argument. This causes
cURL to post data using the header `Content-Type: multipart/form-data`.
The `file=` parameter must point to a file on your filesystem and be preceded
by `@`. For example:

```bash
1413
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "file=@dk.png" https://gitlab.example.com/api/v4/projects/5/uploads
1414 1415 1416 1417
```

Returned object:

D
Douwe Maan 已提交
1418 1419 1420 1421 1422 1423 1424 1425
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1430
## Share project with group
1431 1432 1433 1434 1435 1436 1437

Allow to share project with group.

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

1438 1439
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1440
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1441
| `group_id` | integer | yes | The ID of the group to share with |
1442
| `group_access` | integer | yes | The [permissions level](members.md) to grant the group |
1443
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1444

1445
## Delete a shared project link within a group
1446 1447 1448 1449 1450 1451 1452 1453 1454

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

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

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

```bash
1459
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/5/share/17
1460 1461
```

1462 1463
## Hooks

1464 1465 1466
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1467 1468
### List project hooks

1469
Get a list of project hooks.
M
miks 已提交
1470 1471 1472 1473 1474

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

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

1479
### Get project hook
1480

1481
Get a specific hook for a project.
1482 1483 1484 1485 1486

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

1487 1488
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1489
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1490
| `hook_id` | integer | yes | The ID of a project hook |
1491

1492 1493 1494 1495
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1496
  "project_id": 3,
B
Ben Boeckel 已提交
1497
  "push_events": true,
D
Duana Saskia 已提交
1498
  "push_events_branch_filter": "",
B
Ben Boeckel 已提交
1499
  "issues_events": true,
1500
  "confidential_issues_events": true,
B
Ben Boeckel 已提交
1501
  "merge_requests_events": true,
1502
  "tag_push_events": true,
B
Ben Boeckel 已提交
1503
  "note_events": true,
1504
  "job_events": true,
1505
  "pipeline_events": true,
1506
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1507
  "enable_ssl_verification": true,
1508 1509 1510 1511 1512 1513
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1514
Adds a hook to a specified project.
M
miks 已提交
1515 1516 1517 1518 1519

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

1520 1521
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1522
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1523 1524
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
D
Duana Saskia 已提交
1525
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1526
| `issues_events` | boolean | no | Trigger hook on issues events |
1527
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1528 1529 1530
| `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 |
1531
| `job_events` | boolean | no | Trigger hook on job events |
1532
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
1533
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
1534
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1535
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1536

1537 1538
### Edit project hook

1539
Edits a hook for a specified project.
1540 1541 1542 1543 1544

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

1545 1546
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1547
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1548 1549 1550
| `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 已提交
1551
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1552
| `issues_events` | boolean | no | Trigger hook on issues events |
1553
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1554 1555 1556
| `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 |
1557
| `job_events` | boolean | no | Trigger hook on job events |
1558 1559 1560
| `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 |
1561
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1562

1563
### Delete project hook
M
miks 已提交
1564

1565
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1566
Either the hook is available or not.
M
miks 已提交
1567 1568

```
1569
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1570 1571
```

1572 1573
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1574
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1575
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1576

1577 1578
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.
1579

1580
## Fork relationship
1581

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

1584
### Create a forked from/to relation between existing projects
1585

1586 1587 1588 1589 1590
CAUTION: **Warning:**
This will destroy the LFS objects stored in the fork.
So to retain the LFS objects, make sure you've pulled them **before** creating the fork relation,
and push them again **after** creating the fork relation.

1591 1592 1593 1594
```
POST /projects/:id/fork/:forked_from_id
```

1595 1596
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1597
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1598
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1599 1600 1601 1602 1603 1604 1605

### Delete an existing forked from relationship

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

1606 1607
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1608
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1609 1610 1611

## Search for projects by name

1612 1613 1614
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 已提交
1615 1616

```
1617
GET /projects
I
Izaak Alpert 已提交
1618 1619
```

1620 1621
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1622
| `search` | string | yes | A string contained in the project name |
1623
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1624
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1625

1626
```bash
1627
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects?search=test
1628 1629
```

1630 1631
## Start the Housekeeping task for a Project

1632
> Introduced in GitLab 9.0.
1633 1634 1635 1636 1637

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

1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |

## Push Rules **[STARTER]**

### Get project push rules

Get the push rules of a project.

```
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+\..*",
  "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,
  "commit_committer_check": false
}
```

The following attributes are restricted to certain plans, and will not appear if
you do not have access to those features:

* `commit_committer_check` only available on **[PREMIUM]**

### Add project push rule

Adds a push rule to a specified project.

```
POST /projects/:id/push_rule
```

| 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+\..*` |
| `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$` |
| `file_name_regex` **[STARTER]**        | string         | no       | All commited filenames must **not** match this, e.g. `(jar|exe)$` |
| `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. |

### Edit project push rule

Edits a push rule for a specified project.

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

| 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+\..*` |
| `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$` |
| `file_name_regex` **[STARTER]**        | string         | no       | All commited filenames must **not** match this, e.g. `(jar|exe)$` |
| `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. |

### 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.

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

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

1735 1736 1737
## Transfer a project to a new namespace

> Introduced in GitLab 11.1.
1738 1739 1740 1741 1742 1743 1744 1745 1746

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

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

1747 1748 1749 1750
## Branches

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

J
James Lopez 已提交
1751 1752
## Project Import/Export

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

1755 1756 1757
## Project members

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

1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
## Start the pull mirroring process for a Project **[STARTER]**

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

```
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) |

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

1775 1776 1777
## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
1778 1779 1780

## Issue and merge request description templates

1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
The non-default [issue and merge request description templates](../user/project/description_templates.md) are managed inside the project's repository. So you can manage them via the API through the [Repositories API](repositories.md) and the [Repository Files API](repository_files.md).

## Download snapshot of a git repository

> Introduced in GitLab 10.7

This endpoint may only be accessed by an administrative user.

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

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

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

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

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