# Issue VCS Changes and Pull Requests

This resource lets you work with VCS changes and pull requests linked to an issue.

Use the `$type` field in the response to distinguish VCS changes from pull requests. For pull request-specific attributes, see the [PullRequest](api-entity-PullRequest.html) entity.

|  Resource  |     ```GENERIC /api/issues/{issueID}/vcsChanges ```    |
| --- | --- |
|  Returned entity  |  [VcsChange](api-entity-VcsChange.html). For the description of the entity attributes, see [Supported Fields](#VcsChange-supported-fields) section.  |
|  Supported methods  |      * `GET`: [Issue VCS Changes and Pull Requests](#get_all-VcsChange-method).    * `POST`: [Issue VCS Changes and Pull Requests](#create-VcsChange-method).    |

## VcsChange attributes

Represents a VCS change linked to an issue.

### Related Resources

Below you can find the list of resources that let you work with this entity.

* [Issue VCS Changes]()

### Attributes

This table describes attributes of the `VcsChange` entity.

* To receive an attribute in the response from the server, specify it explicitly in the `fields` request parameter.

* To update an attribute, provide it in the body of a POST request.

|  Field  |  Type  |  Description  |
| --- | --- | --- |
|  id  |  String  |  The database ID of the VCS change. `Read-only`.  |
|  date  |  DateTime  |  The date when the VCS change was committed to the repository. `Read-only`.  |
|  fetched  |  Long  |  The date when the VCS change was fetched from the repository to YouTrack. `Read-only`. `Can be null`.  |
|  files  |  Int  |  The number of files included into the VCS change. Equals -1 if the number of files is unknown. `Read-only`.  |
|  author  |  [User](api-entity-User.html)  |  The author of the VCS change. `Read-only`.  |
|  processors  |  [Array of ChangesProcessors](api-entity-ChangesProcessor.html)  |  The list of version control systems that contain the VCS change. `Read-only`.  |
|  text  |  String  |  The commit message of the VCS change. `Read-only`. `Can be null`.  |
|  urls  |  Array of Strings  |  The list of links to the VCS change in the corresponding version control systems. The order is the same as in the `processors` attribute. `Read-only`.  |
|  version  |  String  |  The commit hash of the VCS change. `Can be null`.  |
|  issue  |  [Issue](api-entity-Issue.html)  |  The YouTrack issue the VCS change is linked to. `Can be null`.  |
|  state  |  Byte  |    The code of the state of the VCS change. Here is the list of available state codes:    * 0 = default    * 1 = attached manually    * 2 = detached    * 3 = legacy  The list of state codes may be extended in the future API versions.    |

## Read a List of VCS Changes and Pull Requests

Get all accessible VCS changes and pull requests linked to the specified issue.

### Required permissions

Requires:

1. Read access to the issue.

2. Group membership in one of the groups in the "VCS changes visibility" setting in the VCS integration settings.

### Request syntax

```GENERIC
GET /api/issues/{issueID}/vcsChanges?{fields}&{$top}&{$skip}
```

|  null  |  The database ID of VcsChange  |
| --- | --- |

### Request parameters

|  Parameter  |  Type  |  Description  |
| --- | --- | --- |
|  fields  |  String  |  A list of VcsChange attributes that should be returned in the response. If no field is specified, only the `entityID` is returned.  |
|  $skip  |  Int  |  Optional. Lets you set a number of returned entities to skip before returning the first one.  |
|  $top  |  Int  |     Optional. Lets you specify the maximum number of entries that are returned in the response. If you don't set the $top value, the server limits the maximum number of returned entries.       The server returns a maximum of 42 entries for most resources that return collections. For more information, see [Pagination](api-concept-pagination.html).     |

### Sample

#### Sample request

```CURL
https://example.youtrack.cloud/api/issues/NP-5/vcsChanges?fields=id,date,fetched,author(login),text,$type
```

#### Sample response body

```JSON
[
  {
    "date": 1495443753000,
    "author": {
      "login": "jane.doe",
      "$type": "User"
    },
    "fetched": null,
    "text": "#NP-5 In Progress",
    "id": "127-3",
    "$type": "VcsChange"
  },
  {
    "date": 1495443805000,
    "author": {
      "login": "jane.doe",
      "$type": "User"
    },
    "fetched": null,
    "text": " #NP-5 Open",
    "id": "127-4",
    "$type": "VcsChange"
  },
  {
    "date": 1564484957000,
    "author": {
      "login": "system_user@iSoHnНAu9X",
      "$type": "VcsUnresolvedUser"
    },
    "fetched": 1640085901059,
    "text": "Update \n\n#NP-5 fix the issue",
    "id": "127-23",
    "$type": "VcsChange"
  },
  {
    "date": 1642067804000,
    "author": {
      "login": "john.smith",
      "$type": "User"
    },
    "fetched": 1642067825847,
    "text": "Fix NP-5",
    "id": "127-28",
    "$type": "PullRequest"
  }
]
```

## Add a New VcsChange

Link a new VCS change to an issue with a specific ID.

Required fields: `version`, `state`.

### Required permissions

Requires permissions: Update Issue Private Fields

### Request syntax

```GENERIC
POST /api/issues/{issueID}/vcsChanges?{fields}&{muteUpdateNotifications}
```

|  null  |  The database ID of VcsChange  |
| --- | --- |

### Request parameters

|  Parameter  |  Type  |  Description  |
| --- | --- | --- |
|  fields  |  String  |  A list of VcsChange attributes that should be returned in the response. If no field is specified, only the `entityID` is returned.  |
|  muteUpdateNotifications  |  Boolean  |  Set this parameter to `true` if no notifications should be sent on issue changes caused by this request. This doesn't mute notifications sent by any workflow rules. Using this parameter requires Apply Commands Silently permission in all projects affected by the request. Available since 2021.3.  |

### Sample

#### Sample request

```CURL
https://example.youtrack.cloud/api/issues/NP-5/vcsChanges?fields=id,date,fetched,files,author(login),text,version,state
```

#### Sample request body

```JSON
{
  "version": "03e876865ba4388205ac11788c6595f5ba8387a4",
  "state": 1
}
```

#### Sample response body

```JSON
{
  "version": "03e876865ba4388205ac11788c6595f5ba8387a4",
  "date": 1642167090000,
  "state": 1,
  "files": -1,
  "author": {
    "login": "jane.doe",
    "$type": "User"
  },
  "fetched": 1642167188839,
  "text": "Update Test.txt",
  "id": "127-27",
  "$type": "VcsChange"
}
```

