# Delete a file

From **GitHub v3 REST API**.

`DELETE /repos/{owner}/{repo}/contents/{path}`

Deletes a file in a repository.

You can provide an additional `committer` parameter, which is an object containing information about the committer. Or, you can provide an `author` parameter, which is an object containing information about the author.

The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user's information is used.

You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you'll receive a `422` status code.

## Parameters

### `owner`

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

### `repo`

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

### `path`

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

path parameter

## Request body

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

- Type: `object`

```json
{
  "committer": {
    "email": "octocat@github.com",
    "name": "Monalisa Octocat"
  },
  "message": "my commit message",
  "sha": "329688480d39049927147c162b9d2deaf885005f"
}
```

```json
{"properties":{"author":{"description":"object containing information about the author.","properties":{"email":{"description":"The email of the author (or committer) of the commit","type":"string"},"name":{"description":"The name of the author (or committer) of the commit","type":"string"}},"type":"object"},"branch":{"description":"The branch name. Default: the repository’s default branch (usually `master`)","type":"string"},"committer":{"description":"object containing information about the committer.","properties":{"email":{"description":"The email of the author (or committer) of the commit","type":"string"},"name":{"description":"The name of the author (or committer) of the commit","type":"string"}},"type":"object"},"message":{"description":"The commit message.","type":"string"},"sha":{"description":"The blob SHA of the file being replaced.","type":"string"}},"required":["message","sha"],"type":"object"}
```

## Responses

### `200`

Response

### `application/json`

- Type: `object`

File Commit

```json
{
  "commit": {
    "author": {
      "date": "2014-11-07T22:01:45Z",
      "email": "octocat@github.com",
      "name": "Monalisa Octocat"
    },
    "committer": {
      "date": "2014-11-07T22:01:45Z",
      "email": "octocat@github.com",
      "name": "Monalisa Octocat"
    },
    "html_url": "https://github.com/octocat/Hello-World/git/commit/7638417db6d59f3c431d3e1f261cc637155684cd",
    "message": "my commit message",
    "node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==",
    "parents": [
      {
        "html_url": "https://github.com/octocat/Hello-World/git/commit/1acc419d4d6a9ce985db7be48c6349a0475975b5",
        "sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5",
        "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5"
      }
    ],
    "sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
    "tree": {
      "sha": "691272480426f78a0138979dd3ce63b77f706feb",
      "url": "https://api.github.com/repos/octocat/Hello-World/git/trees/691272480426f78a0138979dd3ce63b77f706feb"
    },
    "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
    "verification": {
      "payload": null,
      "reason": "unsigned",
      "signature": null,
      "verified": false
    }
  },
  "content": null
}
```

```json
{"description":"File Commit","properties":{"commit":{"properties":{"author":{"properties":{"date":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"}},"type":"object"},"committer":{"properties":{"date":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"}},"type":"object"},"html_url":{"type":"string"},"message":{"type":"string"},"node_id":{"type":"string"},"parents":{"items":{"properties":{"html_url":{"type":"string"},"sha":{"type":"string"},"url":{"type":"string"}},"type":"object"},"type":"array"},"sha":{"type":"string"},"tree":{"properties":{"sha":{"type":"string"},"url":{"type":"string"}},"type":"object"},"url":{"type":"string"},"verification":{"properties":{"payload":{"nullable":true,"type":"string"},"reason":{"type":"string"},"signature":{"nullable":true,"type":"string"},"verified":{"type":"boolean"}},"type":"object"}},"type":"object"},"content":{"nullable":true,"properties":{"_links":{"properties":{"git":{"type":"string"},"html":{"type":"string"},"self":{"type":"string"}},"type":"object"},"download_url":{"type":"string"},"git_url":{"type":"string"},"html_url":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"size":{"type":"integer"},"type":{"type":"string"},"url":{"type":"string"}},"type":"object"}},"required":["content","commit"],"title":"File Commit","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"}
```

### `409`

Conflict

### `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"}
```

### `503`

Service unavailable

### `application/json`

- Type: `object`

```json
{"properties":{"code":{"type":"string"},"documentation_url":{"type":"string"},"message":{"type":"string"}},"type":"object"}
```

## Request examples

### cURL

```shell
curl --request DELETE \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/contents/{path} \
  --header 'content-type: application/json' \
  --data '{
  "committer": {
    "email": "octocat@github.com",
    "name": "Monalisa Octocat"
  },
  "message": "my commit message",
  "sha": "329688480d39049927147c162b9d2deaf885005f"
}'
```
