Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Requests · Function

requests.delete

Sends an HTTP DELETE request to a URL and returns the resulting Response object. Optional keyword arguments use the same request configuration supported by requests.request.

How it works

Call this convenience function with the target URL and any optional keyword arguments accepted by requests.request. It creates and sends a DELETE request, then returns the resulting Response object, which exposes the status code, headers, body, and other response details.

Syntax

requests.delete(url, **kwargs)

Parameters

NameTypeDescription
url_t.UriTypeURL for the new Request object.
**kwargsUnpack[_t.RequestKwargs]Optional arguments accepted by requests.request.

Returns

Response object

Key points

  • The function fixes the HTTP method to DELETE and sends the request to the provided URL.
  • Optional keyword arguments configure the request using the same options as the general request function.
  • The URL identifies the destination for the request.
  • The function returns a Response instance representing the HTTP result.

Common mistakes

  • All keyword arguments are delegated to the general request function, so their meaning and accepted values follow that function's interface.

Example: Delete a resource

import requests

response = requests.delete(
    "https://httpbin.org/delete",
    headers={"Accept": "application/json"},
)
response.raise_for_status()
print(response.status_code)

Sends a DELETE request and checks that the server returned a successful HTTP status.

When to use it

Delete a resource

Removing a server-side resource through an HTTP API.

Configure the request

Passing request options such as headers, authentication, or timeouts through the common request interface.

Handle the result

Inspecting the returned HTTP status and response metadata after deletion.

Interview questions

QWhat does requests.delete do and what does it return?

requests.delete is a convenience function for sending an HTTP DELETE request. Its signature accepts a URL plus optional keyword arguments, and it returns a Response object.

Follow-up: How would you inspect whether the operation succeeded? Check response.status_code or call response.raise_for_status() before processing the response.

QWhat are the parameters of requests.delete?

The required url identifies the new Request object. The optional **kwargs provide the request configuration supported by requests.request.

Follow-up: Why is this useful? It gives the convenience method the same configuration surface as the general request API while fixing the HTTP method to DELETE.

QHow should a caller use the returned value?

The function sends the DELETE method to the supplied URL and returns the server's Response object. The response can then be used to inspect status and other HTTP response data.

Follow-up: What if the server returns no content? Use the response metadata, such as status_code, rather than assuming a response body exists.

  • requests.request
  • requests.get
  • requests.options
  • requests.head
  • requests.post
  • requests.put
  • requests.patch
  • requests.Session.delete

Source: Developer Interface — Requests 2.34.2 documentation. Checked 2026-10-15.