---
title: Create user
slug: docs/demo/create-user
description: Learn how to make a POST request to a specific URL and send JSON data using cURL with this comprehensive code example. Discover how to specify headers and populate different fields in the JSON data for a seamless data transfer experience. Boost your progr
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "yb2pWx4pF7D84MEGAdvXS",
  "data": {
    "url": "https://petstore.swagger.io/v2/user",
    "name": "Create user",
    "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": "username",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "firstName",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "lastName",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "email",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "password",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "phone",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "userStatus",
              "type": "integer<int32>",
              "example": 0,
              "description": "User Status"
            }
          ],
          "modelRef": "#/definitions/User",
          "customType": "User",
          "isExpanded": true
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "default",
        "description": "successful operation",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This can only be done by the logged in user.",
    "examples": {
      "languages": [
        {
          "id": "vBJle7oq-0c7ZoneEz4-o",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://petstore.swagger.io/v2/user \\\n     --header 'accept: application/json'"
        },
        {
          "id": "LPL6M-tr9KCbBv6GnBGQ9",
          "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: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://petstore.swagger.io/v2/user\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "Dd5wmNoe3AARL83xrhKCv",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/user\")\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\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "JExi956qB6wN-zmAPUJPv",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/user\"\n\npayload = {}\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": "vBJle7oq-0c7ZoneEz4-o"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-default",
          "language": "default",
          "code": "// successful operation\n"
        }
      ],
      "selectedLanguageId": "response-0-default"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}