Sample - GitHub REST API
DELETE/repos/{owner}/{repo}/contents/{path}

Delete a file

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.

[!NOTE] If you use this endpoint and the "Create or update file contents" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 5 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
pathstringrequired
path parameter
messagestringrequired
The commit message.
shastringrequired
The blob SHA of the file being deleted.
branchstringoptional
The branch name. Default: the repository’s default branch
committerobjectoptional
object containing information about the committer.
authorobjectoptional
object containing information about the author.

5 status codes
200Response
contentobjectrequired
commitobjectrequired
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
409Conflict
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional
503Service unavailable
codestringoptional
messagestringoptional
documentation_urlstringoptional

Error handling

A 404 is returned: Resource not found. A 409 is returned: Conflict. A 422 is returned: Validation failed, or the endpoint has been spammed. A 503 is returned: Service unavailable.