Use this API to manage code suggestions.
Suggestions provide a way to propose specific changes that can be directly applied to the code. You can programmatically create and apply code suggestions in merge request discussions with this API. Every API call to suggestions must be authenticated.
Apply multiple suggestions to a merge request
PUT /api/v4/suggestions/batch_apply
Applies multiple suggested patches in a merge request. You must have the Developer, Maintainer, or Owner role.
Request body (application/json)
| Property | Type | Description |
|---|---|---|
commit_ | String | Custom commit message to use instead of the default generated message or the project’s default message |
idsRequired | Array of integers | IDs of suggestions to apply |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
Apply a suggestion to a merge request
PUT /api/v4/suggestions/{id}/apply
Applies a suggested patch in a merge request. You must have the Developer, Maintainer, or Owner role.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the suggestion |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
commit_ | String | Custom commit message to use instead of the default generated message or the project’s default message |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesSuggestion
| Property | Type | Description |
|---|---|---|
appliable | Boolean | If true,Example: true |
applied | Boolean | If true,Example: false |
from_ | String | Original content before the suggestion Example: Original content |
from_ | Integer | First line number of the suggestion Example: 1 |
id | Integer (int64) | ID of the suggestion Example: 1 |
to_ | String | Suggested content that replaces the original Example: New content |
to_ | Integer | Last line number of the suggestion Example: 1 |