---
title: Delete a pet
description: "DELETE`/pets/{petId}` ## Code Samples ```curl curl --request DELETE \\ --url 'https://petstore.example.com/v1/pets/{petId}' \\ --header 'X-Api-Key: YOUR_API_KEY' const response = await fetch('https://petstore.example.com/v1/pets/{petId}', { method: 'DELETE', headers: { 'X-Api-Key': 'YOUR_API_KEY' } }); const data = await response.json(); console.log(data); import requests headers = {…"
url: "https://cbotai.shahrear.msf.bd/docs/delete-a-pet/"
updated: "2026-08-16"
category: tes2 / pets
---

# Delete a pet

DELETE`/pets/{petId}`

## Code Samples

```curl

                curl --request DELETE \
  --url 'https://petstore.example.com/v1/pets/{petId}' \
  --header 'X-Api-Key: YOUR_API_KEY'

                const response = await fetch('https://petstore.example.com/v1/pets/{petId}', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY'
  }
});

const data = await response.json();
console.log(data);

                import requests

headers = {
    "X-Api-Key": "YOUR_API_KEY"
}

response = requests.delete("https://petstore.example.com/v1/pets/{petId}", headers=headers)

print(response.json())

                <?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://petstore.example.com/v1/pets/{petId}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => [
  'X-Api-Key: YOUR_API_KEY'
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;

                using System.Net.Http;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("DELETE"), "https://petstore.example.com/v1/pets/{petId}");
request.Headers.Add("X-Api-Key", "YOUR_API_KEY");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

                import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://petstore.example.com/v1/pets/{petId}"))
    .header("X-Api-Key", "YOUR_API_KEY")
    .method("DELETE", HttpRequest.BodyPublishers.noBody())
    .build();

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

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `petId` | integer (int64) | **Required** | ID of the pet |

## Responses

### 204 — Deleted

### 404 — Pet not found
