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:The unique identifier of the comment
The web URL for viewing the comment
The API URL for the pull request (if applicable)
The API URL for the issue
The user who posted the comment
The original author name (for imported comments)
The original author ID (for imported comments)
The text content of the comment
Array of attachment objects (files attached to the comment)
Timestamp when the comment was created (RFC 3339 format)
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
Owner of the repository
Name of the repository
Index number of the issue or pull request
Query Parameters
Only show comments updated after this timestamp (RFC 3339 format)
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
Owner of the repository
Name of the repository
Query Parameters
Only show comments updated after this timestamp (RFC 3339 format)
Only show comments updated before this timestamp (RFC 3339 format)
Page number for pagination (1-based)
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
Owner of the repository
Name of the repository
Index number of the issue or pull request
Query Parameters
Only show items updated after this timestamp (RFC 3339 format)
Only show items updated before this timestamp (RFC 3339 format)
Page number for pagination
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
The unique identifier of the attachment
The filename of the attachment
The file size in bytes
The URL to download the attachment
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
User does not have permission to perform the operation, or the issue is locked
Repository, issue, or comment not found
Validation error (e.g., missing required
body field)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