---
title: uploads an image
slug: custom-main-prod/uploads-an-image
createdAt: 2025-06-24T07:41:50.935Z
---

{
  "id": "979n7rY6ZMEyEMDy-zllv",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "//petstore.swagger.io/v2/pet/{petId}/uploadImage",
    "servers": [
      {
        "url": "//petstore.swagger.io/v2/pet/{petId}/uploadImage",
        "description": "Default server"
      },
      {
        "url": "//petstore.swagger.io/sandbox/pet/{petId}/uploadImage",
        "description": "Sandbox server"
      }
    ],
    "name": "uploads an image",
    "description": "",
    "contentType": "application/octet-stream",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "petId",
          "type": "integer<int64>",
          "description": "ID of pet to update"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "successful operation",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "user",
            "code": "// User example in XML\n// https://foo.bar/examples/user-example.xml"
          },
          {
            "label": "use2r",
            "code": "// User example in XML aaa\n{\n  \"name\": \"Fluffy\",\n  \"petType\": \"Cat\",\n  \"color\": \"White\",\n  \"gender\": \"male\",\n  \"breed\": \"Persian\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ApiResponse",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "integer<int32>",
                "example": 0
              },
              {
                "name": "type",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": ""
              }
            ],
            "modelRef": "#/components/schemas/ApiResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url //petstore.swagger.io/v2/pet/{petId}/uploadImage \\\n     --header 'accept: application/json'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/octet-stream\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"//petstore.swagger.io/v2/pet/{petId}/uploadImage\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"//petstore.swagger.io/v2/pet/{petId}/uploadImage\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/octet-stream\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"//petstore.swagger.io/v2/pet/{petId}/uploadImage\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/octet-stream'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n{\n  \"code\": \"\",\n  \"type\": \"\",\n  \"message\": \"\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// successful operation\n{\n  \"code\": \"\",\n  \"type\": \"\",\n  \"message\": \"\"\n}"
            },
            {
              "label": "user",
              "code": "// User example in XML\n// https://foo.bar/examples/user-example.xml"
            },
            {
              "label": "use2r",
              "code": "// User example in XML aaa\n{\n  \"name\": \"Fluffy\",\n  \"petType\": \"Cat\",\n  \"color\": \"White\",\n  \"gender\": \"male\",\n  \"breed\": \"Persian\"\n}"
            }
          ]
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}