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

3
## Project visibility level
4

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

8
Values for the project visibility level are:
9

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

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

16
* `public`:
17 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
## List user projects
V
vanadium23 已提交
196

197 198
Get a list of visible projects for the given user. When accessed without
authentication, only public projects are returned.
V
vanadium23 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216

```
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 |
217 218
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
219

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

372
## Get single project
N
Nihad Abbasov 已提交
373

374 375
Get a specific project. This endpoint can be accessed without authentication if
the project is publicly accessible.
N
Nihad Abbasov 已提交
376 377 378 379 380

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

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

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

480
## Get project users
D
Dmitriy Zaporozhets 已提交
481

482
Get the users list of a project.
D
Dmitriy Zaporozhets 已提交
483

484 485 486
```
GET /projects/:id/users
```
D
Dmitriy Zaporozhets 已提交
487

488 489
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
490 491
| `search` | string | no | Search for specific users |

D
Dmitriy Zaporozhets 已提交
492
```json
J
Johannes Schleifenbaum 已提交
493 494
[
  {
495 496 497 498 499 500
    "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 已提交
501
  },
J
Johannes Schleifenbaum 已提交
502
  {
503 504 505 506 507 508
    "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 已提交
509 510
  }
]
D
Dmitriy Zaporozhets 已提交
511 512
```

513
## Get project events
D
Dmitriy Zaporozhets 已提交
514

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

517
## Create project
A
Alex Denisov 已提交
518

519
Creates a new project owned by the authenticated user.
A
Alex Denisov 已提交
520 521 522 523 524

```
POST /projects
```

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

551
## Create project for user
552

553
Creates a new project owned by the specified user. Available only for admins.
554 555 556 557 558

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

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

587
## Edit project
588

589
Updates an existing project.
590 591 592 593 594

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

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

621
## Fork project
622

623
Forks a project into the user namespace of the authenticated user or the one provided.
624

625 626 627
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.
628

629
```
630
POST /projects/:id/fork
631 632
```

633 634
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
635
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
636
| `namespace` | integer/string | yes | The ID or path of the namespace that the project will be forked to |
637

638 639 640 641 642 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
## 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"
    }
  }
]
```

730
## Star a project
731

732
Stars a given project. Returns status code `304` if the project is already starred.
733 734 735 736 737 738 739

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

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

```bash
R
Robert Schilling 已提交
743
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/star"
744 745 746 747 748 749 750 751 752
```

Example response:

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

806
## Unstar a project
807

808
Unstars a given project. Returns status code `304` if the project is not starred.
809 810

```
811
POST /projects/:id/unstar
812 813 814 815
```

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

```bash
R
Robert Schilling 已提交
819
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unstar"
820 821 822 823 824 825 826 827 828
```

Example response:

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

882
## Archive a project
883

884
Archives the project if the user is either admin or the project owner of this project. This action is
885 886 887
idempotent, thus archiving an already archived project will not change the project.

```
888
POST /projects/:id/archive
889 890 891 892
```

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

```bash
R
Robert Schilling 已提交
896
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/archive"
897 898 899 900 901 902 903 904 905
```

Example response:

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

976
## Unarchive a project
977

978
Unarchives the project if the user is either admin or the project owner of this project. This action is
979 980 981
idempotent, thus unarchiving an non-archived project will not change the project.

```
S
Sergey Gnuskov 已提交
982
POST /projects/:id/unarchive
983 984 985 986
```

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

```bash
R
Robert Schilling 已提交
990
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/5/unarchive"
991 992 993 994 995 996 997 998 999
```

Example response:

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

1070
## Remove project
D
Dmitriy Zaporozhets 已提交
1071

1072
Removes a project including all associated resources (issues, merge requests etc.)
D
Dmitriy Zaporozhets 已提交
1073 1074 1075 1076 1077

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

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

1082
## Upload a file
D
Douwe Maan 已提交
1083 1084 1085 1086 1087 1088 1089

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

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

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

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
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 已提交
1106 1107 1108 1109 1110 1111 1112 1113
```json
{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}
```

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

1118
## Share project with group
1119 1120 1121 1122 1123 1124 1125

Allow to share project with group.

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

1126 1127
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1128
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1129 1130 1131
| `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 |
1132

1133
## Delete a shared project link within a group
1134 1135 1136 1137 1138 1139 1140 1141 1142

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

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

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

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

1150 1151
## Hooks

1152 1153 1154
Also called Project Hooks and Webhooks.
These are different for [System Hooks](system_hooks.md) that are system wide.

1155 1156
### List project hooks

1157
Get a list of project hooks.
M
miks 已提交
1158 1159 1160 1161 1162

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

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

1167
### Get project hook
1168

1169
Get a specific hook for a project.
1170 1171 1172 1173 1174

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

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

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

### Add project hook

1200
Adds a hook to a specified project.
M
miks 已提交
1201 1202 1203 1204 1205

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

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

1221 1222
### Edit project hook

1223
Edits a hook for a specified project.
1224 1225 1226 1227 1228

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

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

1245
### Delete project hook
M
miks 已提交
1246

1247
Removes a hook from a project. This is an idempotent method and can be called multiple times.
1248
Either the hook is available or not.
M
miks 已提交
1249 1250

```
1251
DELETE /projects/:id/hooks/:hook_id
M
miks 已提交
1252 1253
```

1254 1255
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1256
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1257
| `hook_id` | integer | yes | The ID of the project hook |
M
miks 已提交
1258

1259 1260
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.
1261

1262 1263
## Admin fork relation

1264
Allows modification of the forked relationship between existing projects. Available only for admins.
1265

1266
### Create a forked from/to relation between existing projects
1267 1268 1269 1270 1271

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

1272 1273
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1274
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
1275
| `forked_from_id` | ID | yes | The ID of the project that was forked from |
1276 1277 1278 1279 1280 1281 1282

### Delete an existing forked from relationship

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

1283 1284
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1285
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
I
Izaak Alpert 已提交
1286 1287 1288

## Search for projects by name

1289 1290 1291
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 已提交
1292 1293

```
1294
GET /projects
I
Izaak Alpert 已提交
1295 1296
```

1297 1298
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1299
| `search` | string | yes | A string contained in the project name |
1300
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
1301
| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
1302

1303 1304 1305 1306
```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects?search=test
```

1307 1308
## Start the Housekeeping task for a Project

1309
> Introduced in GitLab 9.0.
1310 1311 1312 1313 1314 1315 1316

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

| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
1317 1318 1319 1320 1321 1322 1323 1324 1325
| `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.