projects.md 69.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 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
| `auto_cancel_pending_pipelines` | string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
739
| `build_coverage_regex` | string | no | Test coverage parsing |
740
| `ci_config_path` | string | no | The path to CI config file |
741 742 743 744
| `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 已提交
745
| `initialize_with_readme` | boolean | no | `false` by default |
746

747 748 749 750
>**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.

751
## Create project for user
752

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

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

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

806
## Edit project
807

808
Updates an existing project.
809 810 811 812 813

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

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

865
## Fork project
866

867
Forks a project into the user namespace of the authenticated user or the one provided.
868

869 870 871
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.
872

873
```
874
POST /projects/:id/fork
875 876
```

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

884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
## 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 |
902
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
903
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
904 905 906
| `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 |
907
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
908 909
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
910
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
911 912

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

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 已提交
928
    "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
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 963 964 965
    "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,
966
    "merge_method": "merge",
967 968 969 970 971 972 973 974 975 976 977 978 979
    "_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"
    }
  }
]
```

980
## Star a project
981

982
Stars a given project. Returns status code `304` if the project is already starred.
983 984 985 986 987 988 989

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

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

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

Example response:

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

1066
## Unstar a project
1067

1068
Unstars a given project. Returns status code `304` if the project is not starred.
1069 1070

```
1071
POST /projects/:id/unstar
1072 1073 1074 1075
```

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

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

Example response:

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

1152 1153 1154 1155 1156 1157 1158 1159 1160
## Languages

Get languages used in a project with percentage value.

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

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

Example response:

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

1175
## Archive a project
1176

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

```
1181
POST /projects/:id/archive
1182 1183 1184 1185
```

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

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

Example response:

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

1280
## Unarchive a project
1281

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

```
S
Sergey Gnuskov 已提交
1286
POST /projects/:id/unarchive
1287 1288 1289 1290
```

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

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

Example response:

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

1385
## Remove project
D
Dmitriy Zaporozhets 已提交
1386

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

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

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

1397
## Upload a file
D
Douwe Maan 已提交
1398 1399 1400 1401 1402 1403 1404

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

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

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

1410 1411 1412 1413 1414 1415
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
1416
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "file=@dk.png" https://gitlab.example.com/api/v4/projects/5/uploads
1417 1418 1419 1420
```

Returned object:

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

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

1433
## Share project with group
1434 1435 1436 1437 1438 1439 1440

Allow to share project with group.

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

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

1448
## Delete a shared project link within a group
1449 1450 1451 1452 1453 1454 1455 1456 1457

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

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

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

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

1465 1466
## Hooks

1467 1468 1469
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1470 1471
### List project hooks

1472
Get a list of project hooks.
M
miks 已提交
1473 1474 1475 1476 1477

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

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

1482
### Get project hook
1483

1484
Get a specific hook for a project.
1485 1486 1487 1488 1489

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

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

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

### Add project hook

1517
Adds a hook to a specified project.
M
miks 已提交
1518 1519 1520 1521 1522

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

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

1540 1541
### Edit project hook

1542
Edits a hook for a specified project.
1543 1544 1545 1546 1547

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

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

1566
### Delete project hook
M
miks 已提交
1567

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

```
1572
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1573 1574
```

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

1580 1581
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.
1582

1583
## Fork relationship
1584

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

1587
### Create a forked from/to relation between existing projects
1588

1589 1590 1591 1592 1593
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.

1594 1595 1596 1597
```
POST /projects/:id/fork/:forked_from_id
```

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

### Delete an existing forked from relationship

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

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

## Search for projects by name

1615 1616 1617
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 已提交
1618 1619

```
1620
GET /projects
I
Izaak Alpert 已提交
1621 1622
```

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

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

1633 1634
## Start the Housekeeping task for a Project

1635
> Introduced in GitLab 9.0.
1636 1637 1638 1639 1640

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

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 1731 1732 1733
| 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
```

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

1738 1739 1740
## Transfer a project to a new namespace

> Introduced in GitLab 11.1.
1741 1742 1743 1744 1745 1746 1747 1748 1749

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

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

1750 1751 1752 1753
## Branches

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

J
James Lopez 已提交
1754 1755
## Project Import/Export

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

1758 1759 1760
## Project members

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

1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
## 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
```

1778 1779 1780
## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
1781 1782 1783

## Issue and merge request description templates

1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806
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 |
1807

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