Delete a file in a repository
const url = 'https://gitea.example.com/api/v1/repos/example/example/contents/example';const options = { method: 'DELETE', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"author":{"email":"hello@example.com","name":"example"},"branch":"example","committer":{"email":"hello@example.com","name":"example"},"dates":{"author":"2026-04-15T12:00:00Z","committer":"2026-04-15T12:00:00Z"},"message":"example","new_branch":"example","sha":"example","signoff":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request DELETE \ --url https://gitea.example.com/api/v1/repos/example/example/contents/example \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "author": { "email": "hello@example.com", "name": "example" }, "branch": "example", "committer": { "email": "hello@example.com", "name": "example" }, "dates": { "author": "2026-04-15T12:00:00Z", "committer": "2026-04-15T12:00:00Z" }, "message": "example", "new_branch": "example", "sha": "example", "signoff": true }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Owner of the repo
Name of the repo
Path of the file to delete
Request Body
Section titled “Request Body”DeleteFileOptions options for deleting files (used for other File structs below)
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)
object
Identity for a person’s identity like an author or committer
object
Branch (optional) to base this file from. if not given, the default branch is used
Identity for a person’s identity like an author or committer
object
CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
object
Message (optional) for the commit of this file. if not supplied, a default message will be used
New_branch (optional) will make a new branch from branch before creating the file
Sha is the SHA for the file that already exists
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Examplegenerated
{ "author": { "email": "hello@example.com", "name": "example" }, "branch": "example", "committer": { "email": "hello@example.com", "name": "example" }, "dates": { "author": "2026-04-15T12:00:00Z", "committer": "2026-04-15T12:00:00Z" }, "message": "example", "new_branch": "example", "sha": "example", "signoff": true}Responses
Section titled “Responses”FileDeleteResponse
FileDeleteResponse contains information about a repo’s file that was deleted
object
object
object
object
object
object
PayloadCommitVerification represents the GPG verification of a commit
object
PayloadUser represents the author or committer of a commit
object
Full name of the commit author
Examplegenerated
{ "commit": { "author": { "date": "example", "email": "hello@example.com", "name": "example" }, "committer": { "date": "example", "email": "hello@example.com", "name": "example" }, "created": "2026-04-15T12:00:00Z", "html_url": "example", "message": "example", "parents": [ { "created": "2026-04-15T12:00:00Z", "sha": "example", "url": "example" } ], "sha": "example", "tree": { "created": "2026-04-15T12:00:00Z", "sha": "example", "url": "example" }, "url": "example" }, "content": "example", "verification": { "payload": "example", "reason": "example", "signature": "example", "signer": { "email": "hello@example.com", "name": "example", "username": "example" }, "verified": true }}APIError is error format response
Headers
Section titled “Headers”APIError is error format response
Headers
Section titled “Headers”APIError is error format response
Headers
Section titled “Headers”APIRepoArchivedError is an error that is raised when an archived repo should be modified