Skip to content

Update pull request information

PATCH /api/v5/repos/{owner}/{repo}/pulls/{number}

This endpoint updates the information of a pull request in the specified repository. You can modify the title, body, state, milestone, labels, and draft flag, and configure options such as whether to close the associated issue and delete the source branch after merging.

Access token support

  • AtomGit user access tokens (AtomGit user access tokens)

Whether anonymous access is allowed

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes The namespace address the repository belongs to (the address path of an organization or personal namespace)
repo path string Yes Repository path (path)
number path integer Yes Which PR, that is, the ordinal number of the PR in this repository
access_token query string Yes User authorization code

Request Body:

The request body is in JSON format. All fields are optional; pass at least one field that needs to be updated.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "title": {
      "description": "Pull request title",
      "type": "string"
    },
    "body": {
      "description": "Pull request body",
      "type": "string"
    },
    "state": {
      "description": "Pull request state",
      "type": "string"
    },
    "milestone_number": {
      "description": "Milestone ordinal number (id)",
      "type": "integer"
    },
    "labels": {
      "description": "Comma-separated labels. The name must be 2-20 characters long and must not contain special characters. For example: bug,performance",
      "type": "string"
    },
    "draft": {
      "description": "Whether to set the pull request as a draft",
      "type": "boolean"
    },
    "close_related_issue": {
      "description": "Whether to close the associated issue after merging; defaults to the repository configuration",
      "type": "boolean"
    },
    "prune_branch": {
      "description": "Delete the source branch after merging",
      "type": "boolean"
    },
    "squash_merge": {
      "description": "Squash merge",
      "type": "boolean"
    }
  },
  "required": []
}

Response parameters

Field Type Always returned Nullable Description
title string — — Pull request title
body string — — Pull request body
state string — — Pull request state
created_at string — — Creation time
updated_at string — — Update time

The reference documentation does not provide the "Always returned" and "Nullable" attributes of the fields, so they could not be parsed.

Error responses

400 Bad request

{
  "error": "invalid_request",
  "message": "The labels parameter failed validation (the label name must be 2-20 characters long and must not contain special characters)"
}

401 Unauthenticated

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

The field names of error responses are subject to what the backend actually returns; they could not be parsed here, so refer to the actual response.

HTTP response status codes

Status code Description
200 Success (OK)
401 Authentication required (Requires authentication)
403 Forbidden (Forbidden)
404 Resource does not exist (Not found)
429 Too many requests; rate limit triggered (Too many requests)
500 Internal system error (Internal server error)

Request example

Parameter descriptions

<owner> is replaced with the namespace address the repository belongs to (the address path of an organization or personal namespace); <repo> with the repository path (path); <number> with the PR number in the repository (ordinal number); <token> with your AtomGit user access token.

cURL

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

JavaScript

const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>?access_token=<token>", {
  method: "PATCH",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    title: "Updated title",
    body: "Updated body"
  })
});

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>/pulls/<number>",
    params={"access_token": "<token>"},
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json"
    },
    json={"title": "Updated title", "body": "Updated body"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "title": "test_b3->dev",
  "body": "new: added file test_b3 \n2223333444444",
  "state": "opened",
  "created_at": "2024-03-28T22:23:29.999+08:00",
  "updated_at": "2024-04-14T21:06:52.499+08:00"
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Parameter error or the request cannot be parsed
404 Request 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