New in 2.4: Test runs you can trust See what's new →

Deletes cookies by name, or every cookie the client sent

GETDELETEhttps://api.testingapis.com/api/cookies/delete

Accepts GET and DELETE. Each cookie is expired with Path=/.

Parameters 1

NameTypeDescription
namesquery · stringComma-separated cookie names, at most 20. Omit to delete all cookies in the request.

Responses

200
The names that were deleted.
400
Invalid name or more than 20 names.

Example

Request
curl -X GET "https://api.testingapis.com/api/cookies/delete?names=theme"
Run in Studio
Response200 OK
Set-Cookie: theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/

{"message": "1 cookie(s) deleted", "deleted": ["theme"]}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/cookies/delete?names=theme");
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "GET",
    "https://api.testingapis.com/api/cookies/delete?names=theme",
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/cookies/delete?names=theme"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}