Skip to content

Update a repository milestone

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

This endpoint updates milestone information in the specified repository. You can change the milestone title, state, description, and due date, and it returns the updated milestone details.

Access token support

  • AtomGit user access token (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 of the namespace that owns the repository (the address path of an enterprise, organization, or personal namespace)
repo path string Yes Repository path (path)
number path integer Yes Milestone serial number (number)
access_token query string Yes User authorization code

Request Body:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "title": {
      "description": "Milestone title",
      "type": "string"
    },
    "state": {
      "description": "Milestone state",
      "type": "string",
      "enum": ["open", "closed", "all"],
      "default": "open"
    },
    "description": {
      "description": "Detailed milestone description",
      "type": "string"
    },
    "due_on": {
      "description": "Milestone due date",
      "type": "string"
    }
  },
  "required": ["title", "due_on"]
}

Response parameters

Field Type Always returned Nullable Description
closed_issues integer Yes — Number of closed issues
created_at string Yes — Milestone creation time
description string Yes — Detailed milestone description
due_on string Yes — Milestone due date
number integer Yes — Milestone serial number (number)
open_issues integer Yes — Number of in-progress issues
repository_id integer Yes — Repository id
state string Yes — Milestone state
title string Yes — Milestone title
updated_at string Yes — Milestone update time
url string Yes — Milestone address

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 Invalid parameters

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

401 Unauthenticated

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

The error field names are subject to the actual backend response.

HTTP response status codes

Status code Description
200 Success (OK)
400 Invalid parameters or the request cannot be parsed
401 Requires authentication
403 Forbidden
404 The milestone or repository does not exist
500 Internal system error

Request example

Parameter description

  • Replace <owner> with the address of the namespace that owns the repository (the address path of an enterprise, organization, or personal namespace);
  • replace <repo> with the repository path (path);
  • replace <number> with the milestone serial number (number);
  • replace <token> with your AtomGit user access token;
  • replace <title> with the milestone title;
  • replace <due_on> with the milestone due date.

cURL

curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/milestones/<number>?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -d '{"title": "<title>", "state": "open", "description": "<description>", "due_on": "<due_on>"}'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/milestones/<number>?access_token=<token>", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    title: "<title>",
    state: "open",
    description: "<description>",
    due_on: "<due_on>",
  }),
});

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>/milestones/<number>",
    params={"access_token": "<token>"},
    json={
        "title": "<title>",
        "state": "open",
        "description": "<description>",
        "due_on": "<due_on>",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "closed_issues": 0,
  "created_at": "2024-10-08T10:58:16+08:00",
  "description": "Hello China",
  "due_on": "2024-11-08",
  "number": 4914,
  "open_issues": 0,
  "repository_id": 4066481,
  "state": "open",
  "title": "Hello China",
  "updated_at": "2024-10-08T10:58:16+08:00",
  "url": "https://api.atomgit.com/dengmengmian/oneapi/milestones/1"
}

Error codes

Error code Description
400 Invalid parameters or the request cannot be parsed
401 Unauthenticated or invalid credentials (missing/invalid access token)
403 Forbidden
404 The request path does not exist or the resource does not exist
405 The request method is 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