Sample - GitHub REST API
POST/repos/{owner}/{repo}/commits/{commit_sha}/comments

Create a commit comment

Create a comment for a commit using its :commit_sha.

Access to commit comments can be controlled by organization owners. For more information, see "Managing commit comments for your organization".

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API."

This endpoint supports the following custom media types. For more information, see "Media types."

  • application/vnd.github-commitcomment.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
  • application/vnd.github-commitcomment.text+json: Returns a text only representation of the markdown body. Response will include body_text.
  • application/vnd.github-commitcomment.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
  • application/vnd.github-commitcomment.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.
  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 4 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
commit_shastringrequired
The SHA of the commit.
bodystringrequired
The contents of the comment.
pathstringoptional
Relative path of the file to comment on.
positionintegeroptional
Line index in the diff to comment on.
lineintegeroptional
**Closing down notice**. Use **position** parameter instead. Line number in the file to comment on.

3 status codes
201Response
html_urlstringrequired
urlstringrequired
idintegerrequired
node_idstringrequired
bodystringrequired
pathstringrequired
positionintegerrequired
lineintegerrequired
commit_idstringrequired
userobjectrequired
A GitHub user.
created_atstringrequired
updated_atstringrequired
author_associationstringrequired
How the author is associated with the repository.
Allowed:COLLABORATORCONTRIBUTORFIRST_TIMERFIRST_TIME_CONTRIBUTORMANNEQUINMEMBERNONEOWNER
reactionsobjectoptional
403Forbidden
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned: Forbidden. A 422 is returned: Validation failed, or the endpoint has been spammed.