---
title: Add a new pet to the store
slug: docs/demo/add-a-new-pet-to-the-store
description: This document offers a comprehensive code example featuring the CURL command to execute a successful POST request on the Swagger Petstore API. It encompasses essential details like headers, request body parameters, pet identification, name, photo URLs, ta
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "M-4WiBcVjEB2kWjj46xgj",
  "data": {
    "url": "https://petstore.swagger.io/v2/pet",
    "name": "Add a new pet to the store",
    "method": "POST",
    "request": {
      "pathParameters": [],
      "queryParameters": [],
      "headerParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "id",
              "type": "integer<int64>",
              "example": 0
            },
            {
              "kind": "optional",
              "name": "category",
              "type": "object",
              "schema": [
                {
                  "kind": "optional",
                  "name": "id",
                  "type": "integer<int64>",
                  "example": 0
                },
                {
                  "kind": "optional",
                  "name": "name",
                  "type": "string",
                  "example": ""
                }
              ],
              "modelRef": "#/definitions/Category",
              "customType": "Category"
            },
            {
              "kind": "required",
              "name": "name",
              "type": "string",
              "example": "doggie"
            },
            {
              "kind": "required",
              "name": "photoUrls",
              "type": "array",
              "example": [],
              "itemType": "string",
              "customType": "string[]",
              "itemExample": ""
            },
            {
              "kind": "optional",
              "name": "tags",
              "type": "array",
              "schema": [
                {
                  "kind": "optional",
                  "name": "id",
                  "type": "integer<int64>",
                  "example": 0
                },
                {
                  "kind": "optional",
                  "name": "name",
                  "type": "string",
                  "example": ""
                }
              ],
              "modelRef": "#/definitions/Tag",
              "customType": "Tag[]"
            },
            {
              "kind": "optional",
              "name": "status",
              "type": "string<available | pending | sold>",
              "example": "",
              "description": "pet status in the store"
            }
          ],
          "modelRef": "#/definitions/Pet",
          "customType": "Pet",
          "isExpanded": true
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "405",
        "description": "Invalid input",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "",
    "examples": {
      "languages": [
        {
          "id": "0i3MHIMFd9cfUAM-4Q6bt",
          "language": "curl",
          "label": "cURL",
          "code": "curl --location 'https://petstore.swagger.io/v2/pet' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"id\": 0,\n  \"category\": {\n    \"id\": 0,\n    \"name\": \"\"\n  },\n  \"name\": \"\",\n  \"photoUrls\": [\n    \"\"\n  ],\n  \"tags\": [\n    {\n      \"id\": 0,\n      \"name\": \"\"\n    }\n  ],\n  \"status\": \"\"\n}'"
        },
        {
          "id": "DRWoKeq53rmyKoka1Qbm8",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"id\": 0,\n   \"category\": {\n      \"id\": 0,\n      \"name\": \"\"\n   },\n   \"name\": \"\",\n   \"photoUrls\": [\n      \"\"\n   ],\n   \"tags\": [\n      {\n         \"id\": 0,\n         \"name\": \"\"\n      }\n   ],\n   \"status\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://petstore.swagger.io/v2/pet\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "ctCn8JfKxWzctMw-v24xy",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/pet\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Content-Type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"id\": 0,\n   \"category\": {\n      \"id\": 0,\n      \"name\": \"\"\n   },\n   \"name\": \"\",\n   \"photoUrls\": [\n      \"\"\n   ],\n   \"tags\": [\n      {\n         \"id\": 0,\n         \"name\": \"\"\n      }\n   ],\n   \"status\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "CtpPj2IVqwMDnpEkn2zrH",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/pet\"\n\npayload = json.dumps({\n   \"id\": 0,\n   \"category\": {\n      \"id\": 0,\n      \"name\": \"\"\n   },\n   \"name\": \"\",\n   \"photoUrls\": [\n      \"\"\n   ],\n   \"tags\": [\n      {\n         \"id\": 0,\n         \"name\": \"\"\n      }\n   ],\n   \"status\": \"\"\n})\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "0i3MHIMFd9cfUAM-4Q6bt"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-405",
          "language": "405",
          "code": "// Invalid input\n"
        }
      ],
      "selectedLanguageId": "response-0-405"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}