projects.md 46.4 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
## List all projects
N
Nihad Abbasov 已提交
20

21 22
Get a list of all visible projects across GitLab for the authenticated user.
When accessed without authentication, only public projects are returned.
N
Nihad Abbasov 已提交
23 24 25 26 27

```
GET /projects
```

28 29 30 31 32 33
| 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` |
34
| `search` | string | no | Return list of projects matching the search criteria |
35
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
T
Toon Claes 已提交
36
| `owned` | boolean | no | Limit by projects owned by the current user |
37
| `membership` | boolean | no | Limit by projects that the current user is a member of |
T
Toon Claes 已提交
38
| `starred` | boolean | no | Limit by projects starred by the current user |
39
| `statistics` | boolean | no | Include project statistics |
40 41
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
V
vanadium23 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

```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",
    "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,
72
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    "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,
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
102 103 104 105 106 107 108 109 110 111
    },
    "_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 已提交
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  },
  {
    "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",
    "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,
140
    "resolve_outdated_diff_discussions": false,
V
vanadium23 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    "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,
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
181 182 183 184 185 186 187 188 189
    },
    "_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 已提交
190 191 192 193 194
    }
  }
]
```

195 196 197 198 199 200
You can filter by [custom attributes](custom_attributes.md) with:

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

201
## List user projects
V
vanadium23 已提交
202

203 204
Get a list of visible projects for the given user. When accessed without
authentication, only public projects are returned.
V
vanadium23 已提交
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222

```
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 |
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
| `owned` | boolean | no | Limit by projects owned by the current user |
| `membership` | boolean | no | Limit by projects that the current user is a member of |
| `starred` | boolean | no | Limit by projects starred by the current user |
| `statistics` | boolean | no | Include project statistics |
223 224
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
225

N
Nihad Abbasov 已提交
226 227 228
```json
[
  {
M
Marin Jankovski 已提交
229
    "id": 4,
N
Nihad Abbasov 已提交
230 231
    "description": null,
    "default_branch": "master",
232
    "visibility": "private",
M
Marin Jankovski 已提交
233 234 235
    "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",
236 237 238 239
    "tag_list": [
      "example",
      "disapora client"
    ],
N
Nihad Abbasov 已提交
240
    "owner": {
M
Marin Jankovski 已提交
241 242
      "id": 3,
      "name": "Diaspora",
B
Ben Boeckel 已提交
243
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
244
    },
M
Marin Jankovski 已提交
245 246 247 248 249
    "name": "Diaspora Client",
    "name_with_namespace": "Diaspora / Diaspora Client",
    "path": "diaspora-client",
    "path_with_namespace": "diaspora/diaspora-client",
    "issues_enabled": true,
S
Stan Hu 已提交
250
    "open_issues_count": 1,
M
Marin Jankovski 已提交
251
    "merge_requests_enabled": true,
252
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
253
    "wiki_enabled": true,
M
Marin Jankovski 已提交
254
    "snippets_enabled": false,
255
    "resolve_outdated_diff_discussions": false,
256
    "container_registry_enabled": false,
B
Ben Boeckel 已提交
257 258
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
259
    "creator_id": 3,
M
Marin Jankovski 已提交
260 261 262 263
    "namespace": {
      "id": 3,
      "name": "Diaspora",
      "path": "diaspora",
264 265
      "kind": "group",
      "full_path": "diaspora"
266
    },
267
    "import_status": "none",
S
sue445 已提交
268
    "archived": false,
T
Tomasz Maczukin 已提交
269 270 271
    "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
    "shared_runners_enabled": true,
    "forks_count": 0,
272 273
    "star_count": 0,
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
274
    "public_jobs": true,
275
    "shared_with_groups": [],
J
James Lopez 已提交
276
    "only_allow_merge_if_pipeline_succeeds": false,
277
    "only_allow_merge_if_all_discussions_are_resolved": false,
278 279 280 281 282 283 284
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 37,
      "storage_size": 1038090,
      "repository_size": 1038090,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
285 286 287 288 289 290 291 292 293
    },
    "_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"
294
    }
N
Nihad Abbasov 已提交
295 296
  },
  {
M
Marin Jankovski 已提交
297
    "id": 6,
N
Nihad Abbasov 已提交
298
    "description": null,
M
Marin Jankovski 已提交
299
    "default_branch": "master",
300
    "visibility": "private",
M
Marin Jankovski 已提交
301 302 303
    "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",
304 305 306 307
    "tag_list": [
      "example",
      "puppet"
    ],
J
Johannes Schleifenbaum 已提交
308
    "owner": {
M
Marin Jankovski 已提交
309 310 311
      "id": 4,
      "name": "Brightbox",
      "created_at": "2013-09-30T13:46:02Z"
N
Nihad Abbasov 已提交
312
    },
M
Marin Jankovski 已提交
313 314 315 316
    "name": "Puppet",
    "name_with_namespace": "Brightbox / Puppet",
    "path": "puppet",
    "path_with_namespace": "brightbox/puppet",
N
Nihad Abbasov 已提交
317
    "issues_enabled": true,
S
Stan Hu 已提交
318
    "open_issues_count": 1,
N
Nihad Abbasov 已提交
319
    "merge_requests_enabled": true,
320
    "jobs_enabled": true,
N
Nihad Abbasov 已提交
321
    "wiki_enabled": true,
M
Marin Jankovski 已提交
322
    "snippets_enabled": false,
323
    "resolve_outdated_diff_discussions": false,
324
    "container_registry_enabled": false,
M
Marin Jankovski 已提交
325 326
    "created_at": "2013-09-30T13:46:02Z",
    "last_activity_at": "2013-09-30T13:46:02Z",
327
    "creator_id": 3,
J
Johannes Schleifenbaum 已提交
328
    "namespace": {
M
Marin Jankovski 已提交
329 330 331
      "id": 4,
      "name": "Brightbox",
      "path": "brightbox",
332 333
      "kind": "group",
      "full_path": "brightbox"
334
    },
335 336
    "import_status": "none",
    "import_error": null,
337 338 339 340 341 342 343 344 345 346
    "permissions": {
      "project_access": {
        "access_level": 10,
        "notification_level": 3
      },
      "group_access": {
        "access_level": 50,
        "notification_level": 3
      }
    },
S
sue445 已提交
347
    "archived": false,
T
Tomasz Maczukin 已提交
348 349 350 351
    "avatar_url": null,
    "shared_runners_enabled": true,
    "forks_count": 0,
    "star_count": 0,
352
    "runners_token": "b8547b1dc37721d05889db52fa2f02",
353
    "public_jobs": true,
354
    "shared_with_groups": [],
J
James Lopez 已提交
355
    "only_allow_merge_if_pipeline_succeeds": false,
356
    "only_allow_merge_if_all_discussions_are_resolved": false,
357 358 359 360 361 362 363
    "request_access_enabled": false,
    "statistics": {
      "commit_count": 12,
      "storage_size": 2066080,
      "repository_size": 2066080,
      "lfs_objects_size": 0,
      "job_artifacts_size": 0
364 365 366 367 368 369 370 371 372
    },
    "_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"
373
    }
374 375 376 377
  }
]
```

378
## Get single project
N
Nihad Abbasov 已提交
379

380 381
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
382 383 384 385 386

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

387 388
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
389
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
390
| `statistics` | boolean | no | Include project statistics |
N
Nihad Abbasov 已提交
391

A
Alex Denisov 已提交
392 393
```json
{
M
Marin Jankovski 已提交
394
  "id": 3,
A
Alex Denisov 已提交
395
  "description": null,
M
Marin Jankovski 已提交
396
  "default_branch": "master",
397
  "visibility": "private",
M
Marin Jankovski 已提交
398 399 400
  "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",
401 402 403 404
  "tag_list": [
    "example",
    "disapora project"
  ],
A
Alex Denisov 已提交
405
  "owner": {
M
Marin Jankovski 已提交
406 407
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
408
    "created_at": "2013-09-30T13:46:02Z"
A
Alex Denisov 已提交
409
  },
M
Marin Jankovski 已提交
410 411 412 413
  "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 已提交
414
  "issues_enabled": true,
S
Stan Hu 已提交
415
  "open_issues_count": 1,
A
Alex Denisov 已提交
416
  "merge_requests_enabled": true,
417
  "jobs_enabled": true,
A
Alex Denisov 已提交
418
  "wiki_enabled": true,
M
Marin Jankovski 已提交
419
  "snippets_enabled": false,
420
  "resolve_outdated_diff_discussions": false,
421
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
422 423
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
424
  "creator_id": 3,
M
Marin Jankovski 已提交
425 426 427 428
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
429 430
    "kind": "group",
    "full_path": "diaspora"
J
Johannes Schleifenbaum 已提交
431
  },
432 433
  "import_status": "none",
  "import_error": null,
D
Dmitriy Zaporozhets 已提交
434 435 436 437 438 439 440 441 442
  "permissions": {
    "project_access": {
      "access_level": 10,
      "notification_level": 3
    },
    "group_access": {
      "access_level": 50,
      "notification_level": 3
    }
443
  },
S
sue445 已提交
444
  "archived": false,
T
Tomasz Maczukin 已提交
445 446 447 448
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
  "star_count": 0,
449
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
450
  "public_jobs": true,
451 452 453 454 455 456 457 458 459 460 461
  "shared_with_groups": [
    {
      "group_id": 4,
      "group_name": "Twitter",
      "group_access_level": 30
    },
    {
      "group_id": 3,
      "group_name": "Gitlab Org",
      "group_access_level": 10
    }
462
  ],
J
James Lopez 已提交
463
  "only_allow_merge_if_pipeline_succeeds": false,
464
  "only_allow_merge_if_all_discussions_are_resolved": false,
465
  "printing_merge_requests_link_enabled": true,
466 467 468 469 470 471 472
  "request_access_enabled": false,
  "statistics": {
    "commit_count": 37,
    "storage_size": 1038090,
    "repository_size": 1038090,
    "lfs_objects_size": 0,
    "job_artifacts_size": 0
473 474 475 476 477 478 479 480 481
  },
  "_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"
482
  }
A
Alex Denisov 已提交
483 484 485
}
```

486
## Get project users
D
Dmitriy Zaporozhets 已提交
487

488
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
489

490 491 492
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
493

494 495
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
496 497
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
498
```json
J
Johannes Schleifenbaum 已提交
499 500
[
  {
501 502 503 504 505 506
    "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 已提交
507
  },
J
Johannes Schleifenbaum 已提交
508
  {
509 510 511 512 513 514
    "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 已提交
515 516
  }
]
D
Dmitriy Zaporozhets 已提交
517 518
```

519
## Get project events
D
Dmitriy Zaporozhets 已提交
520

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

523
## Create project
A
Alex Denisov 已提交
524

525
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
526 527 528 529 530

```
POST /projects
```

531 532
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
533 534
| `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). |
535 536 537 538
| `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 |
539
| `jobs_enabled` | boolean | no | Enable jobs for this project |
540 541
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
542
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
543 544
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
545
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
546
| `import_url` | string | no | URL to import repository from |
547 548
| `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 |
549
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
550 551
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
552
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
553
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
554
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
555
| `ci_config_path` | string | no | The path to CI config file |
556

557
## Create project for user
558

559
Creates a new project owned by the specified user. Available only for admins.
560 561 562 563 564

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

565 566 567 568 569
| 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 |
570
| `default_branch` | string | no | `master` by default |
571 572 573 574
| `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 |
575
| `jobs_enabled` | boolean | no | Enable jobs for this project |
576 577
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
578
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
579 580
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
581
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
582
| `import_url` | string | no | URL to import repository from |
583 584
| `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 |
585
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
586 587
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
588
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
589
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
590
| `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line |
591
| `ci_config_path` | string | no | The path to CI config file |
A
Alex Denisov 已提交
592

593
## Edit project
594

595
Updates an existing project.
596 597 598 599 600

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

601 602
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
603
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
604 605
| `name` | string | yes | The name of the project |
| `path` | string | no | Custom repository name for the project. By default generated based on name |
606
| `default_branch` | string | no | `master` by default |
607 608 609
| `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 |
610
| `jobs_enabled` | boolean | no | Enable jobs for this project |
611 612
| `wiki_enabled` | boolean | no | Enable wiki for this project |
| `snippets_enabled` | boolean | no | Enable snippets for this project |
613
| `resolve_outdated_diff_discussions` | boolean | no | Automatically resolve merge request diffs discussions on lines changed with a push |
614 615
| `container_registry_enabled` | boolean | no | Enable container registry for this project |
| `shared_runners_enabled` | boolean | no | Enable shared runners for this project |
616
| `visibility` | string | no | See [project visibility level](#project-visibility-level) |
617
| `import_url` | string | no | URL to import repository from |
618 619
| `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 |
620
| `only_allow_merge_if_all_discussions_are_resolved` | boolean | no | Set whether merge requests can only be merged when all the discussions are resolved |
621 622
| `lfs_enabled` | boolean | no | Enable LFS |
| `request_access_enabled` | boolean | no | Allow users to request member access |
V
vanadium23 已提交
623
| `tag_list`    | array   | no       | The list of tags for a project; put array of tags, that should be finally assigned to a project |
624
| `avatar`    | mixed   | no      | Image file for avatar of the project                |
625
| `ci_config_path` | string | no | The path to CI config file |
626

627
## Fork project
628

629
Forks a project into the user namespace of the authenticated user or the one provided.
630

631 632 633
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.
634

635
```
636
POST /projects/:id/fork
637 638
```

639 640
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
641
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
642
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
643

644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735
## 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 |
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
| `owned` | boolean | no | Limit by projects owned by the current user |
| `membership` | boolean | no | Limit by projects that the current user is a member of |
| `starred` | boolean | no | Limit by projects starred by the current user |
| `statistics` | boolean | no | Include project statistics |
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |

```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",
    "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,
    "_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"
    }
  }
]
```

736
## Star a project
737

738
Stars a given project. Returns status code `304` if the project is already starred.
739 740 741 742 743 744 745

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

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

```bash
R
Robert Schilling 已提交
749
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
750 751 752 753 754 755 756 757 758
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
759
  "visibility": "internal",
760 761 762 763 764 765 766 767 768 769 770 771 772 773
  "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",
  "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,
774
  "jobs_enabled": true,
775 776
  "wiki_enabled": true,
  "snippets_enabled": false,
777
  "resolve_outdated_diff_discussions": false,
778
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
779 780
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
781 782 783 784 785
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
786 787
    "kind": "group",
    "full_path": "diaspora"
788
  },
789
  "import_status": "none",
790 791 792 793
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
794
  "star_count": 1,
795
  "public_jobs": true,
796
  "shared_with_groups": [],
J
James Lopez 已提交
797
  "only_allow_merge_if_pipeline_succeeds": false,
798
  "only_allow_merge_if_all_discussions_are_resolved": false,
799 800 801 802 803 804 805 806 807 808
  "request_access_enabled": false,
  "_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"
  }
809 810 811
}
```

812
## Unstar a project
813

814
Unstars a given project. Returns status code `304` if the project is not starred.
815 816

```
817
POST /projects/:id/unstar
818 819 820 821
```

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

```bash
R
Robert Schilling 已提交
825
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
826 827 828 829 830 831 832 833 834
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
835
  "visibility": "internal",
836 837 838 839 840 841 842 843 844 845 846 847 848 849
  "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",
  "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,
850
  "jobs_enabled": true,
851 852
  "wiki_enabled": true,
  "snippets_enabled": false,
853
  "resolve_outdated_diff_discussions": false,
854
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
855 856
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
857 858 859 860 861
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
862 863
    "kind": "group",
    "full_path": "diaspora"
864
  },
865
  "import_status": "none",
866 867 868 869
  "archived": true,
  "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
  "shared_runners_enabled": true,
  "forks_count": 0,
870
  "star_count": 0,
871
  "public_jobs": true,
872
  "shared_with_groups": [],
J
James Lopez 已提交
873
  "only_allow_merge_if_pipeline_succeeds": false,
874
  "only_allow_merge_if_all_discussions_are_resolved": false,
875 876 877 878 879 880 881 882 883 884
  "request_access_enabled": false,
  "_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"
  }
885 886 887
}
```

888
## Archive a project
889

890
Archives the project if the user is either admin or the project owner of this project. This action is
891 892 893
idempotent, thus archiving an already archived project will not change the project.

```
894
POST /projects/:id/archive
895 896 897 898
```

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

```bash
R
Robert Schilling 已提交
902
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
903 904 905 906 907 908 909 910 911
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
912
  "visibility": "private",
913 914 915 916 917 918 919 920 921 922
  "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",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
923
    "created_at": "2013-09-30T13:46:02Z"
924 925 926 927 928 929 930 931
  },
  "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,
932
  "jobs_enabled": true,
933 934
  "wiki_enabled": true,
  "snippets_enabled": false,
935
  "resolve_outdated_diff_discussions": false,
936
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
937 938
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
939 940 941 942 943
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
944 945
    "kind": "group",
    "full_path": "diaspora"
946
  },
947 948
  "import_status": "none",
  "import_error": null,
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963
  "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,
964
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
965
  "public_jobs": true,
966
  "shared_with_groups": [],
J
James Lopez 已提交
967
  "only_allow_merge_if_pipeline_succeeds": false,
968
  "only_allow_merge_if_all_discussions_are_resolved": false,
969 970 971 972 973 974 975 976 977 978
  "request_access_enabled": false,
  "_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"
  }
979 980 981
}
```

982
## Unarchive a project
983

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

```
S
Sergey Gnuskov 已提交
988
POST /projects/:id/unarchive
989 990 991 992
```

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

```bash
R
Robert Schilling 已提交
996
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
997 998 999 1000 1001 1002 1003 1004 1005
```

Example response:

```json
{
  "id": 3,
  "description": null,
  "default_branch": "master",
1006
  "visibility": "private",
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
  "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",
  "tag_list": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
B
Ben Boeckel 已提交
1017
    "created_at": "2013-09-30T13:46:02Z"
1018 1019 1020 1021 1022 1023 1024 1025
  },
  "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,
1026
  "jobs_enabled": true,
1027 1028
  "wiki_enabled": true,
  "snippets_enabled": false,
1029
  "resolve_outdated_diff_discussions": false,
1030
  "container_registry_enabled": false,
B
Ben Boeckel 已提交
1031 1032
  "created_at": "2013-09-30T13:46:02Z",
  "last_activity_at": "2013-09-30T13:46:02Z",
1033 1034 1035 1036 1037
  "creator_id": 3,
  "namespace": {
    "id": 3,
    "name": "Diaspora",
    "path": "diaspora",
1038 1039
    "kind": "group",
    "full_path": "diaspora"
1040
  },
1041 1042
  "import_status": "none",
  "import_error": null,
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
  "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,
1058
  "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
1059
  "public_jobs": true,
1060
  "shared_with_groups": [],
J
James Lopez 已提交
1061
  "only_allow_merge_if_pipeline_succeeds": false,
1062
  "only_allow_merge_if_all_discussions_are_resolved": false,
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
  "request_access_enabled": false,
  "_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"
  }
1073 1074 1075
}
```

1076
## Remove project
D
Dmitriy Zaporozhets 已提交
1077

1078
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1079 1080 1081 1082 1083

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

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

1088
## Upload a file
D
Douwe Maan 已提交
1089 1090 1091 1092 1093 1094 1095

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

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

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

1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
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
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "file=@dk.png" https://gitlab.example.com/api/v3/projects/5/uploads
```

Returned object:

D
Douwe Maan 已提交
1112 1113 1114 1115 1116 1117 1118 1119
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1124
## Share project with group
1125 1126 1127 1128 1129 1130 1131

Allow to share project with group.

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

1132 1133
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1134
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1135 1136 1137
| `group_id` | integer | yes | The ID of the group to share with |
| `group_access` | integer | yes | The permissions level to grant the group |
| `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
1138

1139
## Delete a shared project link within a group
1140 1141 1142 1143 1144 1145 1146 1147 1148

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

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

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

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

1156 1157
## Hooks

1158 1159 1160
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1161 1162
### List project hooks

1163
Get a list of project hooks.
M
miks 已提交
1164 1165 1166 1167 1168

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

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

1173
### Get project hook
1174

1175
Get a specific hook for a project.
1176 1177 1178 1179 1180

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

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

1186 1187 1188 1189
```json
{
  "id": 1,
  "url": "http://example.com/hook",
1190
  "project_id": 3,
B
Ben Boeckel 已提交
1191 1192 1193
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
1194
  "tag_push_events": true,
B
Ben Boeckel 已提交
1195
  "note_events": true,
1196
  "job_events": true,
1197
  "pipeline_events": true,
1198
  "wiki_page_events": true,
B
Ben Boeckel 已提交
1199
  "enable_ssl_verification": true,
1200 1201 1202 1203 1204 1205
  "created_at": "2012-10-12T17:04:47Z"
}
```

### Add project hook

1206
Adds a hook to a specified project.
M
miks 已提交
1207 1208 1209 1210 1211

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

1212 1213
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1214
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1215 1216 1217 1218 1219 1220
| `url` | string | yes | The hook URL |
| `push_events` | boolean | no | Trigger hook on push events |
| `issues_events` | boolean | no | Trigger hook on issues events |
| `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 |
1221
| `job_events` | boolean | no | Trigger hook on job events |
1222 1223 1224
| `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 |
1225
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1226

1227 1228
### Edit project hook

1229
Edits a hook for a specified project.
1230 1231 1232 1233 1234

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

1235 1236
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1237
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1238 1239 1240 1241 1242 1243 1244
| `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 |
| `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 |
1245
| `job_events` | boolean | no | Trigger hook on job events |
1246 1247 1248
| `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 |
1249
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
1250

1251
### Delete project hook
M
miks 已提交
1252

1253
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1254
Either the hook is available or not.
M
miks 已提交
1255 1256

```
1257
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1258 1259
```

1260 1261
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1262
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1263
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1264

1265 1266
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.
1267

1268 1269
## Admin fork relation

1270
Allows modification of the forked relationship between existing projects. Available only for admins.
1271

1272
### Create a forked from/to relation between existing projects
1273 1274 1275 1276 1277

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

1278 1279
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1280
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1281
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1282 1283 1284 1285 1286 1287 1288

### Delete an existing forked from relationship

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

1289 1290
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1291
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1292 1293 1294

## Search for projects by name

1295 1296 1297
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 已提交
1298 1299

```
1300
GET /projects
I
Izaak Alpert 已提交
1301 1302
```

1303 1304
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1305
| `search` | string | yes | A string contained in the project name |
1306
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1307
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1308

1309 1310 1311 1312
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1313 1314
## Start the Housekeeping task for a Project

1315
> Introduced in GitLab 9.0.
1316 1317 1318 1319 1320 1321 1322

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

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

## Branches

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

## Project members

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