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 | A custom commit message to use instead of the default generated message or the project’s default message |
idsRequired | Array of integers | An array of the suggestion IDs |
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 | The ID of the suggestion |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
commit_ | String | A 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 | Example:true |
applied | Boolean | Example:false |
from_ | String | Example:Original content |
from_ | Integer | Example:1 |
id | Integer (int64) | Example:1 |
to_ | String | Example:New content |
to_ | Integer | Example:1 |