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

3
## Project visibility level
4

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

8
Values for the project visibility level are:
9

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

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

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

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

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

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

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

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


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

36
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 |
J
J.D. Bean 已提交
454
| `license` | boolean | no | Include project license data |
455
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
N
Nihad Abbasov 已提交
456

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

561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
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 已提交
584 585 586 587 588 589 590 591
      "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",
      },
592 593
      "star_count":3812,
      "forks_count":3561,
594 595 596 597 598 599 600 601 602
      "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
      }
603 604 605 606 607 608 609
   }

   ...

}
```

610
## Get project users
D
Dmitriy Zaporozhets 已提交
611

612
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
613

614 615 616
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
617

618 619
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
620 621
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
622
```json
J
Johannes Schleifenbaum 已提交
623 624
[
  {
625 626 627 628 629 630
    "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 已提交
631
  },
J
Johannes Schleifenbaum 已提交
632
  {
633 634 635 636 637 638
    "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 已提交
639 640
  }
]
D
Dmitriy Zaporozhets 已提交
641 642
```

643
## Get project events
D
Dmitriy Zaporozhets 已提交
644

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

647
## Create project
A
Alex Denisov 已提交
648

649
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
650 651 652 653 654

```
POST /projects
```

655 656
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
657 658
| `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). |
659 660 661 662
| `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 |
663
| `jobs_enabled` | boolean | no | Enable jobs for this project |
664 665
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
666
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
667 668
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
669
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
670
| `import_url` | string | no | URL to import repository from |
671
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
672
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
673
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
674
| `merge_method` | string | no | Set the merge method used |
675 676
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
677
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
678
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
679
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
680
| `ci_config_path` | string | no | The path to CI config file |
S
Steve 已提交
681
| `initialize_with_readme` | boolean | no | `false` by default |
682

683
## Create project for user
684

685
Creates a new project owned by the specified user. Available only for admins.
686 687 688 689 690

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

691 692 693 694 695
| 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 |
696
| `default_branch` | string | no | `master` by default |
697 698 699 700
| `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 |
701
| `jobs_enabled` | boolean | no | Enable jobs for this project |
702 703
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
704
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
705 706
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
707
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
708
| `import_url` | string | no | URL to import repository from |
709
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
710
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
711
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
712
| `merge_method` | string | no | Set the merge method used |
713 714
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
715
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
716
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
717
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
718
| `ci_config_path` | string | no | The path to CI config file |
A
Alex Denisov 已提交
719

720
## Edit project
721

722
Updates an existing project.
723 724 725 726 727

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

728 729
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
730
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
731
| `name` | string | no | The name of the project |
732
| `path` | string | no | Custom repository name for the project. By default generated based on name |
733
| `default_branch` | string | no | `master` by default |
734 735 736
| `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 |
737
| `jobs_enabled` | boolean | no | Enable jobs for this project |
738 739
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
740
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
741 742
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
743
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
744
| `import_url` | string | no | URL to import repository from |
745
| `public_builds` | boolean | no | If `true`, jobs can be viewed by non-project-members |
746
| `only_allow_merge_if_pipeline_succeeds` | boolean | no | Set whether merge requests can only be merged with successful jobs |
747
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
748
| `merge_method` | string | no | Set the merge method used |
749 750
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
751
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
752
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
753
| `ci_config_path` | string | no | The path to CI config file |
754

755
## Fork project
756

757
Forks a project into the user namespace of the authenticated user or the one provided.
758

759 760 761
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.
762

763
```
764
POST /projects/:id/fork
765 766
```

767 768
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
769
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
770
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
771

772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
## 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 |
790
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. |
791
| `owned` | boolean | no | Limit by projects explicitly owned by the current user |
792 793 794
| `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 |
795
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
796 797
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
798
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) |
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815

```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 已提交
816
    "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853
    "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,
854
    "merge_method": "merge",
855 856 857 858 859 860 861 862 863 864 865 866 867
    "_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"
    }
  }
]
```

868
## Star a project
869

870
Stars a given project. Returns status code `304` if the project is already starred.
871 872 873 874 875 876 877

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

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

```bash
R
Robert Schilling 已提交
881
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
882 883 884 885 886 887 888 889 890
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
891
  "visibility": "internal",
892 893 894
  "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 已提交
895
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
896 897 898 899 900 901 902 903 904 905 906
  "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,
907
  "jobs_enabled": true,
908 909
  "wiki_enabled": true,
  "snippets_enabled": false,
910
  "resolve_outdated_diff_discussions": false,
911
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
912 913
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
914 915 916 917 918
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
919 920
    "kind": "group",
    "full_path": "diaspora"
921
  },
922
  "import_status": "none",
923 924
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
925 926 927 928 929 930 931 932
  "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"
  },
933 934
  "shared_runners_enabled": true,
  "forks_count": 0,
935
  "star_count": 1,
936
  "public_jobs": true,
937
  "shared_with_groups": [],
J
James Lopez 已提交
938
  "only_allow_merge_if_pipeline_succeeds": false,
939
  "only_allow_merge_if_all_discussions_are_resolved": false,
940
  "request_access_enabled": false,
941
  "merge_method": "merge",
942 943 944 945 946 947 948 949 950
  "_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"
  }
951 952 953
}
```

954
## Unstar a project
955

956
Unstars a given project. Returns status code `304` if the project is not starred.
957 958

```
959
POST /projects/:id/unstar
960 961 962 963
```

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

```bash
R
Robert Schilling 已提交
967
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
968 969 970 971 972 973 974 975 976
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
977
  "visibility": "internal",
978 979 980
  "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 已提交
981
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
982 983 984 985 986 987 988 989 990 991 992
  "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,
993
  "jobs_enabled": true,
994 995
  "wiki_enabled": true,
  "snippets_enabled": false,
996
  "resolve_outdated_diff_discussions": false,
997
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
998 999
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1000 1001 1002 1003 1004
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1005 1006
    "kind": "group",
    "full_path": "diaspora"
1007
  },
1008
  "import_status": "none",
1009 1010
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
J
J.D. Bean 已提交
1011 1012 1013 1014 1015 1016 1017 1018
  "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"
  },
1019 1020
  "shared_runners_enabled": true,
  "forks_count": 0,
1021
  "star_count": 0,
1022
  "public_jobs": true,
1023
  "shared_with_groups": [],
J
James Lopez 已提交
1024
  "only_allow_merge_if_pipeline_succeeds": false,
1025
  "only_allow_merge_if_all_discussions_are_resolved": false,
1026
  "request_access_enabled": false,
1027
  "merge_method": "merge",
1028 1029 1030 1031 1032 1033 1034 1035 1036
  "_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"
  }
1037 1038 1039
}
```

1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062
## 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
}
```

1063
## Archive a project
1064

1065
Archives the project if the user is either admin or the project owner of this project. This action is
1066 1067 1068
idempotent, thus archiving an already archived project will not change the project.

```
1069
POST /projects/:id/archive
1070 1071 1072 1073
```

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

```bash
R
Robert Schilling 已提交
1077
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
1078 1079 1080 1081 1082 1083 1084 1085 1086
```

Example response:

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

1167
## Unarchive a project
1168

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

```
S
Sergey Gnuskov 已提交
1173
POST /projects/:id/unarchive
1174 1175 1176 1177
```

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

```bash
R
Robert Schilling 已提交
1181
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
1182 1183 1184 1185 1186 1187 1188 1189 1190
```

Example response:

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

1271
## Remove project
D
Dmitriy Zaporozhets 已提交
1272

1273
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1274 1275 1276 1277 1278

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

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

1283
## Upload a file
D
Douwe Maan 已提交
1284 1285 1286 1287 1288 1289 1290

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

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

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

1296 1297 1298 1299 1300 1301
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
1302
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "file=@dk.png" https://gitlab.example.com/api/v4/projects/5/uploads
1303 1304 1305 1306
```

Returned object:

D
Douwe Maan 已提交
1307 1308 1309 1310 1311 1312 1313 1314
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1319
## Share project with group
1320 1321 1322 1323 1324 1325 1326

Allow to share project with group.

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

1327 1328
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1329
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1330
| `group_id` | integer | yes | The ID of the group to share with |
1331
| `group_access` | integer | yes | The [permissions level](members.md) to grant the group |
1332
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1333

1334
## Delete a shared project link within a group
1335 1336 1337 1338 1339 1340 1341 1342 1343

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

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

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

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

1351 1352
## Hooks

1353 1354 1355
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1356 1357
### List project hooks

1358
Get a list of project hooks.
M
miks 已提交
1359 1360 1361 1362 1363

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

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

1368
### Get project hook
1369

1370
Get a specific hook for a project.
1371 1372 1373 1374 1375

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

1376 1377
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1378
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1379
| `hook_id` | integer | yes | The ID of a project hook |
1380

1381 1382 1383 1384
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1385
  "project_id": 3,
B
Ben Boeckel 已提交
1386
  "push_events": true,
D
Duana Saskia 已提交
1387
  "push_events_branch_filter": "",
B
Ben Boeckel 已提交
1388
  "issues_events": true,
1389
  "confidential_issues_events": true,
B
Ben Boeckel 已提交
1390
  "merge_requests_events": true,
1391
  "tag_push_events": true,
B
Ben Boeckel 已提交
1392
  "note_events": true,
1393
  "job_events": true,
1394
  "pipeline_events": true,
1395
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1396
  "enable_ssl_verification": true,
1397 1398 1399 1400 1401 1402
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1403
Adds a hook to a specified project.
M
miks 已提交
1404 1405 1406 1407 1408

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

1409 1410
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1411
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1412 1413
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
D
Duana Saskia 已提交
1414
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1415
| `issues_events` | boolean | no | Trigger hook on issues events |
1416
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1417 1418 1419
| `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 |
1420
| `job_events` | boolean | no | Trigger hook on job events |
1421
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
1422
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
1423
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
1424
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1425

1426 1427
### Edit project hook

1428
Edits a hook for a specified project.
1429 1430 1431 1432 1433

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

1434 1435
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1436
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1437 1438 1439
| `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 已提交
1440
| `push_events_branch_filter` | string | no | Trigger hook on push events for matching branches only |
1441
| `issues_events` | boolean | no | Trigger hook on issues events |
1442
| `confidential_issues_events` | boolean | no | Trigger hook on confidential issues events |
1443 1444 1445
| `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 |
1446
| `job_events` | boolean | no | Trigger hook on job events |
1447 1448 1449
| `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 |
1450
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1451

1452
### Delete project hook
M
miks 已提交
1453

1454
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1455
Either the hook is available or not.
M
miks 已提交
1456 1457

```
1458
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1459 1460
```

1461 1462
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1463
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1464
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1465

1466 1467
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.
1468

1469
## Fork relationship
1470

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

1473
### Create a forked from/to relation between existing projects
1474

1475 1476 1477 1478 1479
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.

1480 1481 1482 1483
```
POST /projects/:id/fork/:forked_from_id
```

1484 1485
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1486
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1487
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1488 1489 1490 1491 1492 1493 1494

### Delete an existing forked from relationship

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

1495 1496
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1497
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1498 1499 1500

## Search for projects by name

1501 1502 1503
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 已提交
1504 1505

```
1506
GET /projects
I
Izaak Alpert 已提交
1507 1508
```

1509 1510
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1511
| `search` | string | yes | A string contained in the project name |
1512
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1513
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1514

1515 1516 1517 1518
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1519 1520
## Start the Housekeeping task for a Project

1521
> Introduced in GitLab 9.0.
1522 1523 1524 1525 1526 1527 1528

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

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

1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
### 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 |

1541 1542 1543 1544
## Branches

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

J
James Lopez 已提交
1545 1546
## Project Import/Export

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

1549 1550 1551
## Project members

Read more in the [Project members](members.md) documentation.
1552 1553 1554 1555

## Project badges

Read more in the [Project Badges](project_badges.md) documentation.
1556 1557 1558

## Issue and merge request description templates

1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581
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 |
1582 1583 1584

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