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

3
## Project visibility level
4

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

8
Values for the project visibility level are:
9

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

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

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

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
## Project merge method

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

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

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

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


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

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

```
GET /projects
```

43 44 45 46 47 48
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `archived` | boolean | no | Limit by archived status |
| `visibility` | string | no | Limit by visibility `public`, `internal`, or `private` |
| `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at` |
| `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc` |
49
| `search` | string | no | Return list of projects matching the search criteria |
50
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
51
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
52
| `membership` | boolean | no | Limit by projects that the current user is a member of |
T
Toon Claes 已提交
53
| `starred` | boolean | no | Limit by projects starred by the current user |
54
| `statistics` | boolean | no | Include project statistics |
55
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
56 57
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
58 59
| `wiki_checksum_failed` | boolean | no | Limit projects where the wiki checksum calculation has failed _([Introduced][ee-6137] in [GitLab Premium][eep] 11.2)_ |
| `repository_checksum_failed` | boolean | no | Limit projects where the repository checksum calculation has failed _([Introduced][ee-6137] in [GitLab Premium][eep] 11.2)_ |
60
| `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 146 147 148 149 150
    "container_registry_enabled": false,
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "creator_id": 3,
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
      "kind": "group",
      "full_path": "diaspora"
    },
    "import_status": "none",
    "archived": false,
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
151
    "merge_method": "merge",
V
vanadium23 已提交
152 153 154 155 156 157
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
158 159 160 161 162 163 164 165 166 167
    },
    "_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 已提交
168 169 170 171 172 173 174 175 176
  },
  {
    "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 已提交
177
    "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md",
V
vanadium23 已提交
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
    "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,
197
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
198 199 200 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 230 231
    "container_registry_enabled": false,
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
    "creator_id": 3,
    "namespace": {
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
      "kind": "group",
      "full_path": "brightbox"
    },
    "import_status": "none",
    "import_error": null,
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
    "archived": false,
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
    "public_jobs": true,
    "shared_with_groups": [],
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": false,
    "request_access_enabled": false,
232
    "merge_method": "merge",
V
vanadium23 已提交
233 234 235 236 237 238
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
239 240 241 242 243 244 245 246 247
    },
    "_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 已提交
248 249 250 251 252
    }
  }
]
```

253 254 255 256 257 258
You can filter by [custom attributes](custom_attributes.md) with:

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

259
## List user projects
V
vanadium23 已提交
260

D
Davin Walker 已提交
261
Get a list of visible projects owned by the given user. When accessed without authentication, only public projects are returned.
V
vanadium23 已提交
262 263 264 265 266 267 268 269 270 271 272 273 274

```
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 |
275
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
276
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
V
vanadium23 已提交
277 278 279
| `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 |
280
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
281 282
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
283
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
284

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

441
## Get single project
N
Nihad Abbasov 已提交
442

443 444
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
445 446 447 448 449

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

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

A
Alex Denisov 已提交
456 457
```json
{
M
Marin Jankovski 已提交
458
  "id": 3,
A
Alex Denisov 已提交
459
  "description": null,
M
Marin Jankovski 已提交
460
  "default_branch": "master",
461
  "visibility": "private",
M
Marin Jankovski 已提交
462 463 464
  "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 已提交
465
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
466 467 468 469
  "tag_list": [
    "example",
    "disapora project"
  ],
A
Alex Denisov 已提交
470
  "owner": {
M
Marin Jankovski 已提交
471 472
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
473
    "created_at": "2013-09-30T13:46:02Z"
A
Alex Denisov 已提交
474
  },
M
Marin Jankovski 已提交
475 476 477 478
  "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 已提交
479
  "issues_enabled": true,
S
Stan Hu 已提交
480
  "open_issues_count": 1,
A
Alex Denisov 已提交
481
  "merge_requests_enabled": true,
482
  "jobs_enabled": true,
A
Alex Denisov 已提交
483
  "wiki_enabled": true,
M
Marin Jankovski 已提交
484
  "snippets_enabled": false,
485
  "resolve_outdated_diff_discussions": false,
486
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
487 488
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
489
  "creator_id": 3,
M
Marin Jankovski 已提交
490 491 492 493
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
494 495
    "kind": "group",
    "full_path": "diaspora"
J
Johannes Schleifenbaum 已提交
496
  },
497 498
  "import_status": "none",
  "import_error": null,
D
Dmitriy Zaporozhets 已提交
499 500 501 502 503 504 505 506 507
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
508
  },
S
sue445 已提交
509
  "archived": false,
T
Tomasz Maczukin 已提交
510 511 512 513
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
514
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
515
  "public_jobs": true,
516 517 518 519 520 521 522 523 524 525 526
  "shared_with_groups": [
    {
      "group_id": 4,
      "group_name": "Twitter",
      "group_access_level": 30
    },
    {
      "group_id": 3,
      "group_name": "Gitlab Org",
      "group_access_level": 10
    }
527
  ],
J
James Lopez 已提交
528
  "only_allow_merge_if_pipeline_succeeds": false,
529
  "only_allow_merge_if_all_discussions_are_resolved": false,
530
  "printing_merge_requests_link_enabled": true,
531
  "request_access_enabled": false,
532
  "merge_method": "merge",
533 534 535 536 537 538
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
    "lfs_objects_size": 0,
    "job_artifacts_size": 0
539 540 541 542 543 544 545 546 547
  },
  "_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"
548
  }
A
Alex Denisov 已提交
549 550 551
}
```

552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
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",
      "star_count":3812,
      "forks_count":3561,
577 578 579 580 581 582 583 584 585
      "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
      }
586 587 588 589 590 591 592
   }

   ...

}
```

593
## Get project users
D
Dmitriy Zaporozhets 已提交
594

595
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
596

597 598 599
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
600

601 602
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
603 604
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
605
```json
J
Johannes Schleifenbaum 已提交
606 607
[
  {
608 609 610 611 612 613
    "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 已提交
614
  },
J
Johannes Schleifenbaum 已提交
615
  {
616 617 618 619 620 621
    "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 已提交
622 623
  }
]
D
Dmitriy Zaporozhets 已提交
624 625
```

626
## Get project events
D
Dmitriy Zaporozhets 已提交
627

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

630
## Create project
A
Alex Denisov 已提交
631

632
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
633 634 635 636 637

```
POST /projects
```

638 639
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
640 641
| `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). |
642 643 644 645
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
646
| `jobs_enabled` | boolean | no | Enable jobs for this project |
647 648
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
649
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
650 651
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
652
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
653
| `import_url` | string | no | URL to import repository from |
654 655
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
656
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
657
| `merge_method` | string | no | Set the merge method used |
658 659
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
660
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
661
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
662
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
663
| `ci_config_path` | string | no | The path to CI config file |
664

665
## Create project for user
666

667
Creates a new project owned by the specified user. Available only for admins.
668 669 670 671 672

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

673 674 675 676 677
| 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 |
678
| `default_branch` | string | no | `master` by default |
679 680 681 682
| `namespace_id` | integer | no | Namespace for the new project (defaults to the current user's namespace) |
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
683
| `jobs_enabled` | boolean | no | Enable jobs for this project |
684 685
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
686
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
687 688
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
689
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
690
| `import_url` | string | no | URL to import repository from |
691 692
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
693
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
694
| `merge_method` | string | no | Set the merge method used |
695 696
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
697
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
698
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
699
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
700
| `ci_config_path` | string | no | The path to CI config file |
A
Alex Denisov 已提交
701

702
## Edit project
703

704
Updates an existing project.
705 706 707 708 709

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

710 711
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
712
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
713 714
| `name` | string | yes | The name of the project |
| `path` | string | no | Custom repository name for the project. By default generated based on name |
715
| `default_branch` | string | no | `master` by default |
716 717 718
| `description` | string | no | Short project description |
| `issues_enabled` | boolean | no | Enable issues for this project |
| `merge_requests_enabled` | boolean | no | Enable merge requests for this project |
719
| `jobs_enabled` | boolean | no | Enable jobs for this project |
720 721
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
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 728
| `public_jobs` | boolean | no | If `true`, jobs can be viewed by non-project-members |
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
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
| `ci_config_path` | string | no | The path to CI config file |
736

737
## Fork project
738

739
Forks a project into the user namespace of the authenticated user or the one provided.
740

741 742 743
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.
744

745
```
746
POST /projects/:id/fork
747 748
```

749 750
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
751
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
752
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
753

754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
## 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 |
772
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
773
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
774 775 776
| `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 |
777
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
778 779
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
780
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797

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

Example responses:

```json
[
  {
    "id": 3,
    "description": null,
    "default_branch": "master",
    "visibility": "internal",
    "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git",
    "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
    "web_url": "http://example.com/diaspora/diaspora-project-site",
I
Imre Farkas 已提交
798
    "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
    "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,
836
    "merge_method": "merge",
837 838 839 840 841 842 843 844 845 846 847 848 849
    "_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"
    }
  }
]
```

850
## Star a project
851

852
Stars a given project. Returns status code `304` if the project is already starred.
853 854 855 856 857 858 859

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

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

```bash
R
Robert Schilling 已提交
863
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
864 865 866 867 868 869 870 871 872
```

Example response:

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

928
## Unstar a project
929

930
Unstars a given project. Returns status code `304` if the project is not starred.
931 932

```
933
POST /projects/:id/unstar
934 935 936 937
```

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

```bash
R
Robert Schilling 已提交
941
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
942 943 944 945 946 947 948 949 950
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
951
  "visibility": "internal",
952 953 954
  "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 已提交
955
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
956 957 958 959 960 961 962 963 964 965 966
  "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,
967
  "jobs_enabled": true,
968 969
  "wiki_enabled": true,
  "snippets_enabled": false,
970
  "resolve_outdated_diff_discussions": false,
971
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
972 973
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
974 975 976 977 978
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
979 980
    "kind": "group",
    "full_path": "diaspora"
981
  },
982
  "import_status": "none",
983 984 985 986
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
987
  "star_count": 0,
988
  "public_jobs": true,
989
  "shared_with_groups": [],
J
James Lopez 已提交
990
  "only_allow_merge_if_pipeline_succeeds": false,
991
  "only_allow_merge_if_all_discussions_are_resolved": false,
992
  "request_access_enabled": false,
993
  "merge_method": "merge",
994 995 996 997 998 999 1000 1001 1002
  "_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"
  }
1003 1004 1005
}
```

1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
## Languages

Get languages used in a project with percentage value.

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

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

Example response:

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

1029
## Archive a project
1030

1031
Archives the project if the user is either admin or the project owner of this project. This action is
1032 1033 1034
idempotent, thus archiving an already archived project will not change the project.

```
1035
POST /projects/:id/archive
1036 1037 1038 1039
```

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

```bash
R
Robert Schilling 已提交
1043
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
1044 1045 1046 1047 1048 1049 1050 1051 1052
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1053
  "visibility": "private",
1054 1055 1056
  "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 已提交
1057
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1058 1059 1060 1061 1062 1063 1064
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1065
    "created_at": "2013-09-30T13:46:02Z"
1066 1067 1068 1069 1070 1071 1072 1073
  },
  "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,
1074
  "jobs_enabled": true,
1075 1076
  "wiki_enabled": true,
  "snippets_enabled": false,
1077
  "resolve_outdated_diff_discussions": false,
1078
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1079 1080
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1081 1082 1083 1084 1085
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1086 1087
    "kind": "group",
    "full_path": "diaspora"
1088
  },
1089 1090
  "import_status": "none",
  "import_error": null,
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
  },
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1106
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1107
  "public_jobs": true,
1108
  "shared_with_groups": [],
J
James Lopez 已提交
1109
  "only_allow_merge_if_pipeline_succeeds": false,
1110
  "only_allow_merge_if_all_discussions_are_resolved": false,
1111
  "request_access_enabled": false,
1112
  "merge_method": "merge",
1113 1114 1115 1116 1117 1118 1119 1120 1121
  "_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"
  }
1122 1123 1124
}
```

1125
## Unarchive a project
1126

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

```
S
Sergey Gnuskov 已提交
1131
POST /projects/:id/unarchive
1132 1133 1134 1135
```

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

```bash
R
Robert Schilling 已提交
1139
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
1140 1141 1142 1143 1144 1145 1146 1147 1148
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1149
  "visibility": "private",
1150 1151 1152
  "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 已提交
1153
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
1154 1155 1156 1157 1158 1159 1160
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1161
    "created_at": "2013-09-30T13:46:02Z"
1162 1163 1164 1165 1166 1167 1168 1169
  },
  "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,
1170
  "jobs_enabled": true,
1171 1172
  "wiki_enabled": true,
  "snippets_enabled": false,
1173
  "resolve_outdated_diff_discussions": false,
1174
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1175 1176
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1177 1178 1179 1180 1181
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1182 1183
    "kind": "group",
    "full_path": "diaspora"
1184
  },
1185 1186
  "import_status": "none",
  "import_error": null,
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
  },
  "archived": false,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
1202
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1203
  "public_jobs": true,
1204
  "shared_with_groups": [],
J
James Lopez 已提交
1205
  "only_allow_merge_if_pipeline_succeeds": false,
1206
  "only_allow_merge_if_all_discussions_are_resolved": false,
1207
  "request_access_enabled": false,
1208
  "merge_method": "merge",
1209 1210 1211 1212 1213 1214 1215 1216 1217
  "_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"
  }
1218 1219 1220
}
```

1221
## Remove project
D
Dmitriy Zaporozhets 已提交
1222

1223
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1224 1225 1226 1227 1228

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

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

1233
## Upload a file
D
Douwe Maan 已提交
1234 1235 1236 1237 1238 1239 1240

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

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

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

1246 1247 1248 1249 1250 1251
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
1252
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "file=@dk.png" https://gitlab.example.com/api/v4/projects/5/uploads
1253 1254 1255 1256
```

Returned object:

D
Douwe Maan 已提交
1257 1258 1259 1260 1261 1262 1263 1264
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1269
## Share project with group
1270 1271 1272 1273 1274 1275 1276

Allow to share project with group.

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

1277 1278
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1279
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1280
| `group_id` | integer | yes | The ID of the group to share with |
1281
| `group_access` | integer | yes | The [permissions level](members.md) to grant the group |
1282
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1283

1284
## Delete a shared project link within a group
1285 1286 1287 1288 1289 1290 1291 1292 1293

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

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

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

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

1301 1302
## Hooks

1303 1304 1305
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1306 1307
### List project hooks

1308
Get a list of project hooks.
M
miks 已提交
1309 1310 1311 1312 1313

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

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

1318
### Get project hook
1319

1320
Get a specific hook for a project.
1321 1322 1323 1324 1325

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

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

1331 1332 1333 1334
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1335
  "project_id": 3,
B
Ben Boeckel 已提交
1336 1337
  "push_events": true,
  "issues_events": true,
1338
  "confidential_issues_events": true,
B
Ben Boeckel 已提交
1339
  "merge_requests_events": true,
1340
  "tag_push_events": true,
B
Ben Boeckel 已提交
1341
  "note_events": true,
1342
  "job_events": true,
1343
  "pipeline_events": true,
1344
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1345
  "enable_ssl_verification": true,
1346 1347 1348 1349 1350 1351
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1352
Adds a hook to a specified project.
M
miks 已提交
1353 1354 1355 1356 1357

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

1358 1359
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1360
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1361 1362 1363
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
1364
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1365 1366 1367
| `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 |
1368
| `job_events` | boolean | no | Trigger hook on job events |
1369
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
1370
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
1371
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1372
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1373

1374 1375
### Edit project hook

1376
Edits a hook for a specified project.
1377 1378 1379 1380 1381

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

1382 1383
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1384
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1385 1386 1387 1388
| `hook_id` | integer | yes | The ID of the project hook |
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
1389
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1390 1391 1392
| `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 |
1393
| `job_events` | boolean | no | Trigger hook on job events |
1394 1395 1396
| `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 |
1397
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1398

1399
### Delete project hook
M
miks 已提交
1400

1401
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1402
Either the hook is available or not.
M
miks 已提交
1403 1404

```
1405
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1406 1407
```

1408 1409
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1410
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1411
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1412

1413 1414
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.
1415

1416 1417
## Admin fork relation

1418
Allows modification of the forked relationship between existing projects. Available only for admins.
1419

1420
### Create a forked from/to relation between existing projects
1421 1422 1423 1424 1425

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

1426 1427
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1428
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1429
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1430 1431 1432 1433 1434 1435 1436

### Delete an existing forked from relationship

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

1437 1438
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1439
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1440 1441 1442

## Search for projects by name

1443 1444 1445
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 已提交
1446 1447

```
1448
GET /projects
I
Izaak Alpert 已提交
1449 1450
```

1451 1452
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1453
| `search` | string | yes | A string contained in the project name |
1454
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1455
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1456

1457 1458 1459 1460
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1461 1462
## Start the Housekeeping task for a Project

1463
> Introduced in GitLab 9.0.
1464 1465 1466 1467 1468 1469 1470

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

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

1473 1474 1475 1476 1477 1478 1479 1480 1481 1482
### Transfer a project to a new namespace

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

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

1483 1484 1485 1486
## Branches

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

J
James Lopez 已提交
1487 1488
## Project Import/Export

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

1491 1492 1493
## Project members

Read more in the [Project members](members.md) documentation.
1494 1495 1496 1497

## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
1498 1499 1500

## Issue and merge request description templates

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523
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 |
1524 1525 1526

[eep]: https://about.gitlab.com/pricing/ "Available only in GitLab Premium"
[ee-6137]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6137