Published Sep 14, 2022
Contribute to Docs

The .delete() method sends a DELETE request to a web server; it returns a response object.


import requests

requests.delete("url", **kwargs)

**kwargs are any number of dictionary items (named arguments) that are passed in as parameters. The .delete() method can take in various parameters that allow a user to communicate additional information to the web server (the content type that should be returned, the user’s authentication, etc.). They can also be used to include cookies in the request, set proxies, set user-agents, or set a page timeout.


The .delete() method sends a request to delete data from a web server. The response object it returns contains various types of data such as the webpage text, status code, and the reason for that response.

import requests
response = requests.delete("https://httpbin.org/delete")
print(f"{response.status_code}: {response.reason}")

The following output will look like this:

200: OK

Codebyte Example

Common response codes for a DELETE request including the following:

  • 405: The method is not allowed.
  • 200: The action has been enacted and a response message describes the status.
  • 202: The action is pending.
  • 204: The action has been enacted but there is no further information beyond that.
Visit us
Hide code
Hide output
Hide output

All contributors

Looking to contribute?

Learn Python on Codecademy