# Create a milestone

From **GitHub v3 REST API**.

`POST /repos/{owner}/{repo}/milestones`

Create a milestone

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

## Request body

- Required: true
### `application/json`

- Type: `object`

```json
{
  "description": "Tracking milestone for version 1.0",
  "due_on": "2012-10-09T23:39:01Z",
  "state": "open",
  "title": "v1.0"
}
```

```json
{"properties":{"description":{"description":"A description of the milestone.","type":"string"},"due_on":{"description":"The milestone due date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.","format":"date-time","type":"string"},"state":{"default":"open","description":"The state of the milestone. Either `open` or `closed`.","enum":["open","closed"],"type":"string"},"title":{"description":"The title of the milestone.","type":"string"}},"required":["title"],"type":"object"}
```

## Responses

### `201`

Response

#### Headers

##### `Location`

- Type: `string`

- Example: `https://api.github.com/repos/octocat/Hello-World/milestones/1`

### `application/json`

- Type: `object`

A collection of related issues and pull requests.

```json
{
  "closed_at": "2013-02-12T13:22:01Z",
  "closed_issues": 8,
  "created_at": "2011-04-10T20:09:31Z",
  "creator": {
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url": "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "gravatar_id": "",
    "html_url": "https://github.com/octocat",
    "id": 1,
    "login": "octocat",
    "node_id": "MDQ6VXNlcjE=",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "site_admin": false,
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "type": "User",
    "url": "https://api.github.com/users/octocat"
  },
  "description": "Tracking milestone for version 1.0",
  "due_on": "2012-10-09T23:39:01Z",
  "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0",
  "id": 1002604,
  "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels",
  "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==",
  "number": 1,
  "open_issues": 4,
  "state": "open",
  "title": "v1.0",
  "updated_at": "2014-03-03T18:58:10Z",
  "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1"
}
```

```json
{"description":"A collection of related issues and pull requests.","properties":{"closed_at":{"example":"2013-02-12T13:22:01Z","format":"date-time","nullable":true,"type":"string"},"closed_issues":{"example":8,"type":"integer"},"created_at":{"example":"2011-04-10T20:09:31Z","format":"date-time","type":"string"},"creator":{"$ref":"#/components/schemas/nullable-simple-user"},"description":{"example":"Tracking milestone for version 1.0","nullable":true,"type":"string"},"due_on":{"example":"2012-10-09T23:39:01Z","format":"date-time","nullable":true,"type":"string"},"html_url":{"example":"https://github.com/octocat/Hello-World/milestones/v1.0","format":"uri","type":"string"},"id":{"example":1002604,"type":"integer"},"labels_url":{"example":"https://api.github.com/repos/octocat/Hello-World/milestones/1/labels","format":"uri","type":"string"},"node_id":{"example":"MDk6TWlsZXN0b25lMTAwMjYwNA==","type":"string"},"number":{"description":"The number of the milestone.","example":42,"type":"integer"},"open_issues":{"example":4,"type":"integer"},"state":{"default":"open","description":"The state of the milestone.","enum":["open","closed"],"example":"open","type":"string"},"title":{"description":"The title of the milestone.","example":"v1.0","type":"string"},"updated_at":{"example":"2014-03-03T18:58:10Z","format":"date-time","type":"string"},"url":{"example":"https://api.github.com/repos/octocat/Hello-World/milestones/1","format":"uri","type":"string"}},"required":["closed_issues","creator","description","due_on","closed_at","id","node_id","labels_url","html_url","number","open_issues","state","title","url","created_at","updated_at"],"title":"Milestone","type":"object"}
```

### `404`

Resource not found

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/milestones \
  --header 'content-type: application/json' \
  --data '{
  "description": "Tracking milestone for version 1.0",
  "due_on": "2012-10-09T23:39:01Z",
  "state": "open",
  "title": "v1.0"
}'
```
