Skip to content

Update a commit comment

PATCH /api/v5/repos/{owner}/{repo}/comments/{id}

This endpoint updates the content of a comment on a specific commit. You must specify the namespace address that owns the repository, the repository path, and the comment ID, and pass the new comment content in the request body. The endpoint returns the updated comment details.

Access token support

  • AtomGit user access tokens

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Address path of the namespace that owns the repository (address path of the organization or user)
repo path string Yes Repository path (path)
id path string Yes Comment ID
access_token query string Yes User authorization code

Request Body:

The request body is a JSON object containing the updated comment content.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "body": {
      "description": "Comment content",
      "type": "string"
    }
  },
  "required": ["body"]
}

Response parameters

Field Type Always returned Nullable Description
body string Yes — Comment content
created_at string Yes — Comment creation time
id integer Yes — Comment ID
target object Yes — Comment target object; the exact structure depends on the actual response
updated_at string Yes — Comment update time
user object Yes — Comment user information

user object

Field Type Always returned Nullable Description
user.id integer Yes — User ID
user.login string Yes — Login name
user.name string Yes — Username
user.type string Yes — User type

Error response

A 200/success response alone is not enough: callers need to know what a failure looks like in order to write error handling.

400 Parameter error

{
  "error": "invalid_request",
  "message": "Parameter body cannot be empty",
  "field": "body"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

Note: The error response field names above are those actually returned by the backend.

HTTP response status codes

Status code Description
200 Success (OK)
304 Not modified
401 Authentication required
403 Forbidden
404 Resource not found
429 Rate limited
500 Internal server error

Request example

Parameter description

The examples must be consistent with the rest of this document; they can be copied and called successfully as-is. Authentication is done by appending the access_token query parameter (user access token) to the request URL.

Replace <owner> with the address path of the namespace that owns the repository (address path of the enterprise, organization, or user); Replace <repo> with the repository path (path); Replace <id> with the ID of the comment to update; Replace <token> with your AtomGit user access token.

cURL

curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/comments/<id>?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"body": "Updated comment content"}'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch(
  "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/comments/<id>?access_token=<token>",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    body: JSON.stringify({ body: "Updated comment content" })
  }
);

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.patch(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/comments/<id>",
    params={"access_token": "<token>"},
    json={"body": "Updated comment content"},
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "body": "Updated comment content",
  "created_at": "2024-11-06T09:43:23+08:00",
  "id": 1492393,
  "target": {},
  "updated_at": "2024-11-14T18:44:53+08:00",
  "user": {
    "id": 496,
    "login": "xiaogang",
    "name": "xiaogang",
    "type": "User"
  }
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Parameter error or the request cannot be parsed
404 The requested path does not exist
405 Request method not supported
429 Too many requests; rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc