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)

PropertyTypeDescription
commit_messageStringCustom commit message to use instead of the default generated message or the project’s default message
ids
Required
Array of integersIDs of suggestions to apply

Responses

CodeDescriptionSchema
200OKAPIEntitiesSuggestion
400Bad 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

NameTypeDescription
id
Path, required
IntegerID of the suggestion

Request body (application/json)

PropertyTypeDescription
commit_messageStringCustom commit message to use instead of the default generated message or the project’s default message

Responses

CodeDescriptionSchema
200OKAPIEntitiesSuggestion
400Bad Request—
404Not Found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesSuggestion

PropertyTypeDescription
appliableBooleanIf true, the suggestion can be applied
Example: true
appliedBooleanIf true, the suggestion has been applied
Example: false
from_contentStringOriginal content before the suggestion
Example: Original content
from_lineIntegerFirst line number of the suggestion
Example: 1
idInteger (int64)ID of the suggestion
Example: 1
to_contentStringSuggested content that replaces the original
Example: New content
to_lineIntegerLast line number of the suggestion
Example: 1