---
title: "Delete a file in a repository"
method: DELETE
path: "/repos/{owner}/{repo}/contents/{filepath}"
tags: ["repository"]
---

# Delete a file in a repository

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

## Path parameters

- `owner` string, required
- `repo` string, required
- `filepath` string, required

## Request body

- DeleteFileOptions — DeleteFileOptions options for deleting a file Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
  - `author` Identity — Identity for a person's identity like an author or committer
    - `email` string, email — Email is the person's email address
    - `name` string — Name is the person's name
  - `branch` string — branch (optional) is the base branch for the changes. If not supplied, the default branch is used
  - `committer` Identity — Identity for a person's identity like an author or committer
    - `email` string, email — Email is the person's email address
    - `name` string — Name is the person's name
  - `dates` CommitDateOptions — CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
    - `author` string, date-time — Author is the author date for the commit
    - `committer` string, date-time — Committer is the committer date for the commit
  - `force_push` boolean — force_push (optional) will do a force-push if the new branch already exists
  - `message` string — message (optional) is the commit message of the changes. If not supplied, a default message will be used
  - `new_branch` string — new_branch (optional) will make a new branch from base branch for the changes. If not supplied, the changes will be committed to the base branch
  - `sha` string, required — the blob ID (SHA) for the file to delete
  - `signoff` boolean — Add a Signed-off-by trailer by the committer at the end of the commit log message.

## Response `200`

FileDeleteResponse

- FileDeleteResponse — FileDeleteResponse contains information about a repo's file that was deleted
  - `commit` FileCommitResponse
    - `author` CommitUser
      - `date` string — Date is the commit date in string format
      - `email` string, email — Email is the person's email address
      - `name` string — Name is the person's name
    - `committer` CommitUser
      - `date` string — Date is the commit date in string format
      - `email` string, email — Email is the person's email address
      - `name` string — Name is the person's name
    - `created` string, date-time — Created is the time when the commit was created
    - `html_url` string — HTMLURL is the web URL for viewing this commit
    - `message` string — Message is the commit message
    - `parents` CommitMeta[] — Parents contains parent commit metadata
      - `created` string, date-time — Created is the time when the commit was created
      - `sha` string — SHA is the commit SHA hash
      - `url` string — URL is the API URL for the commit
    - `sha` string — SHA is the commit SHA hash
    - `tree` CommitMeta
      - `created` string, date-time — Created is the time when the commit was created
      - `sha` string — SHA is the commit SHA hash
      - `url` string — URL is the API URL for the commit
    - `url` string — URL is the API URL for the commit
  - `content` unknown
  - `verification` PayloadCommitVerification — PayloadCommitVerification represents the GPG verification of a commit
    - `payload` string — The signed payload content
    - `reason` string — The reason for the verification status
    - `signature` string — The GPG signature of the commit
    - `signer` PayloadUser — PayloadUser represents the author or committer of a commit
      - `email` string, email
      - `name` string — Full name of the commit author
      - `username` string — username of the user
    - `verified` boolean — Whether the commit signature is verified

## Other responses

- `400` — APIError is error format response
- `403` — APIError is error format response
- `404` — APIError is error format response
- `422` — APIError is error format response
- `423` — APIRepoArchivedError is an error that is raised when an archived repo should be modified

---

[API](https://skmtc.net/gitea/apis/gitea-api.md) · [All operations](https://skmtc.net/gitea/apis/gitea-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gitea/gitea-api/revisions/350de506cefa/schema)
