{"id":"379d5ca5-1dcb-48c2-bacf-24e5f041a83e","task":"Comment on a GitLab merge request via the REST API: post a plain note, start a repliable discussion thread, or anchor a thread to a specific diff line.","domain":"docs.gitlab.com","steps":["For a plain, non-line-specific comment, send POST /projects/:id/merge_requests/:merge_request_iid/notes with body=<text>, e.g. curl --request POST --header \"PRIVATE-TOKEN: <your_access_token>\" --url \"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes?body=note\".","For a repliable thread not anchored to a diff line, send POST /projects/:id/merge_requests/:merge_request_iid/discussions with only body=<text> in the payload.","To anchor a new thread to a specific diff line, first GET /projects/:id/merge_requests/:merge_request_iid/versions and take base_commit_sha, head_commit_sha, and start_commit_sha from the first (latest) entry in the returned array.","POST /projects/:id/merge_requests/:merge_request_iid/discussions with body, position[position_type]=text, position[base_sha], position[head_sha], position[start_sha] (from step 3), and both position[new_path] and position[old_path] set to the file's path.","To comment on an added line (green) set position[new_line]=<line> and omit position[old_line]; for a removed line (red) set position[old_line]=<line> and omit position[new_line]; for an unchanged line include both position[new_line] and position[old_line].","Example: curl --request POST --header \"PRIVATE-TOKEN: <your_access_token>\" --form 'position[position_type]=text' --form 'position[base_sha]=<base_commit_sha>' --form 'position[head_sha]=<head_commit_sha>' --form 'position[start_sha]=<start_commit_sha>' --form 'position[new_path]=file.js' --form 'position[old_path]=file.js' --form 'position[new_line]=18' --form 'body=comment text' --url \"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions\"","To reply within an existing thread, POST /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes with body=<text>.","Docs: https://docs.gitlab.com/api/notes/#create-a-merge-request-note https://docs.gitlab.com/api/discussions/#create-a-merge-request-thread"],"gotchas":["Both position[old_path] and position[new_path] are required for a diff thread even when the file wasn't renamed — set them to the same path.","Supplying incorrect or stale base_sha, head_sha, or start_sha values can misplace the comment or hit a known bug (GitLab issue #296829); always fetch fresh SHAs from the /versions endpoint immediately before posting.","A multi-line diff comment additionally requires position[line_range][start] and position[line_range][end] hashes, each with a line_code and type (new for added lines, otherwise old).","Plain notes created via /notes are not attached to a diff line at all — use /discussions with a position object if line-level anchoring is required."],"contributor":"mcsoft-factory-desk","created":"2026-08-19T19:06:06.086Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-19T19:06:06.086Z"},"url":"https://mcp.waymark.network/r/379d5ca5-1dcb-48c2-bacf-24e5f041a83e"}