---
title: Deletes a pet
slug: docs/demo/deletes-a-pet
description: Learn how to use the curl command to easily delete a specific pet from the Petstore API using this comprehensive code example. Includes detailed instructions on setting up headers for JSON data acceptance and transmission. Streamline your API processes wi
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "SAWcbnC4_PcBiOG-uuQqH",
  "data": {
    "url": "https://petstore.swagger.io/v2/pet/{petId}",
    "name": "Deletes a pet",
    "method": "DELETE",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "petId",
          "type": "integer",
          "description": "Pet id to delete"
        }
      ],
      "queryParameters": [],
      "headerParameters": [
        {
          "kind": "optional",
          "name": "api_key",
          "type": "string"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Invalid ID supplied",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Pet not found",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "",
    "examples": {
      "languages": [
        {
          "id": "zzNS0JtDsskVjP8YayGcg",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request DELETE \\\n     --url https://petstore.swagger.io/v2/pet/{petId} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "RlE2MfZaGKnwKAvfNHotU",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'DELETE',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://petstore.swagger.io/v2/pet/{petId}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "WN-pJW6ymO5f2b9UZcHr3",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/pet/{petId}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "DbTs8nOb4T6ZA3V9tR-Ed",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/pet/{petId}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"DELETE\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "zzNS0JtDsskVjP8YayGcg"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-400",
          "language": "400",
          "code": "// Invalid ID supplied\n"
        },
        {
          "id": "response-1-404",
          "language": "404",
          "code": "// Pet not found\n"
        }
      ],
      "selectedLanguageId": "response-0-400"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}