Overview
The Comments API allows you to manage comments on both issues and pull requests. Comments provide a way for users to discuss and collaborate on issues and PRs.Comment Object
The Comment object represents a comment with the following structure:integer
The unique identifier of the comment
string
The web URL for viewing the comment
string
The API URL for the pull request (if applicable)
string
The API URL for the issue
object
The user who posted the comment
string
The original author name (for imported comments)
integer
The original author ID (for imported comments)
string
The text content of the comment
array
Array of attachment objects (files attached to the comment)
string
Timestamp when the comment was created (RFC 3339 format)
string
Timestamp when the comment was last updated (RFC 3339 format)
Operations
- List Comments
- Get Comment
- Create Comment
- Update Comment
- Delete Comment
List Issue Comments
List all comments on a specific issue or pull request.Endpoint:GET /api/v1/repos/{owner}/{repo}/issues/{index}/commentsPath Parameters
string
required
Owner of the repository
string
required
Name of the repository
integer
required
Index number of the issue or pull request
Query Parameters
string
Only show comments updated after this timestamp (RFC 3339 format)
string
Only show comments updated before this timestamp (RFC 3339 format)
Example Request
Response
List Repository Comments
List all comments across all issues and pull requests in a repository. Endpoint:GET /api/v1/repos/{owner}/{repo}/issues/comments
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
Query Parameters
string
Only show comments updated after this timestamp (RFC 3339 format)
string
Only show comments updated before this timestamp (RFC 3339 format)
integer
default:"1"
Page number for pagination (1-based)
integer
Number of items per page
Example Request
Response
Timeline Comments
Get all comments and events on an issue or pull request in timeline order. This includes not just regular comments, but also system events like labels being added, state changes, etc. Endpoint:GET /api/v1/repos/{owner}/{repo}/issues/{index}/timeline
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
integer
required
Index number of the issue or pull request
Query Parameters
string
Only show items updated after this timestamp (RFC 3339 format)
string
Only show items updated before this timestamp (RFC 3339 format)
integer
default:"1"
Page number for pagination
integer
Number of items per page
Example Request
Response
Comment Attachments
Comments can have file attachments. Theassets field in the comment object contains an array of attachment objects.
Attachment Object Structure
integer
The unique identifier of the attachment
string
The filename of the attachment
integer
The file size in bytes
string
The URL to download the attachment
string
Timestamp when the attachment was uploaded
Example Comment with Attachments
Permissions
Reading Comments
- Users can read comments on issues and pull requests they have access to
- Public repositories: anyone can read comments
- Private repositories: only members with read access can read comments
Creating Comments
- Authenticated users with read access can create comments
- Comments cannot be added to locked issues unless the user is a maintainer or admin
Editing Comments
- Comment authors can edit their own comments
- Repository maintainers and admins can edit any comment
Deleting Comments
- Comment authors can delete their own comments
- Repository maintainers and admins can delete any comment
Error Responses
Forbidden
User does not have permission to perform the operation, or the issue is locked
Not Found
Repository, issue, or comment not found
Unprocessable Entity
Validation error (e.g., missing required
body field)Locked
Repository is archived and cannot be modified
Best Practices
- Pagination: Always use pagination when listing comments for issues with many comments
- Rate Limiting: Be aware of API rate limits when creating multiple comments
- Markdown: Comment bodies support Markdown formatting
- Mentions: Use
@usernameto mention users in comments - References: Use
#123to reference other issues or pull requests - Timestamps: Use the
sinceandbeforeparameters to filter comments by time range - Attachments: Upload attachments separately and reference them in comment body if needed