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_messageStringA custom commit message to use instead of the default generated message or the project’s default message
ids
Required
Array of integersAn array of the suggestion IDs

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
IntegerThe ID of the suggestion

Request body (application/json)

PropertyTypeDescription
commit_messageStringA custom 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
appliableBooleanExample: true
appliedBooleanExample: false
from_contentStringExample: Original content
from_lineIntegerExample: 1
idInteger (int64)Example: 1
to_contentStringExample: New content
to_lineIntegerExample: 1