---
title: Creates a new user object
slug: dev/creates-a-new-user-object
docTags: 
createdAt: 2023-02-23T17:07:09.000Z
---

{
  "id": "61tjJbpaK1zdyFo7obPnx",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/users",
    "name": "Creates a new user object",
    "description": "Creates a new user object",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "kind": "required",
          "name": "Authorization",
          "type": "string",
          "description": "Auth header",
          "example": "{\"Authorization\":\"Bearer {jwt token}\"}"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "schema": [
            {
              "name": "email",
              "kind": "optional",
              "type": "string",
              "description": "email of the user",
              "example": "myEmail@clemap.ch"
            },
            {
              "name": "password",
              "kind": "optional",
              "type": "string",
              "description": "password of the user",
              "example": "myPassword123"
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Created",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "name": "_id",
                "kind": "optional",
                "type": "string",
                "example": "myUserId"
              },
              {
                "name": "email",
                "kind": "optional",
                "type": "string",
                "example": "myEmail@clemap.ch"
              },
              {
                "name": "isVerified",
                "kind": "optional",
                "type": "boolean",
                "example": false
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Bad Request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "name": "name",
                "kind": "optional",
                "type": "string",
                "description": "Error name",
                "example": "BadRequest"
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "Error message",
                "example": "Data does not match schema"
              },
              {
                "name": "code",
                "kind": "optional",
                "type": "number",
                "description": "HTTP status code",
                "example": 400
              },
              {
                "name": "className",
                "kind": "optional",
                "type": "string",
                "description": "Error class name",
                "example": "bad-request"
              },
              {
                "name": "data",
                "kind": "optional",
                "type": "string",
                "description": "Error data",
                "example": ""
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "array",
                "description": "Description of errors",
                "example": "[\"detailed description of error\"]",
                "itemType": "object",
                "customType": "object[]",
                "itemExample": ""
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "409",
        "description": "Conflict",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "name": "name",
                "kind": "optional",
                "type": "string",
                "example": "Conflict"
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "Error message",
                "example": "Email myEmail@clemap.ch already exists"
              },
              {
                "name": "code",
                "kind": "optional",
                "type": "number",
                "description": "HTTP status code",
                "example": 409
              },
              {
                "name": "className",
                "kind": "optional",
                "type": "string",
                "description": "Error class name",
                "example": "conflict"
              },
              {
                "name": "data",
                "kind": "optional",
                "type": "string",
                "description": "Error data",
                "example": ""
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "array",
                "description": "Description of errors",
                "example": "[\"Email myEmail@clemap.ch already exists\"]",
                "itemType": "object",
                "customType": "object[]",
                "itemExample": ""
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "KAlW0qTnqddyj-pcLqP9u",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url /users \\\n     --header 'accept: application/json' \\\n     --header 'authorization: {\"Authorization\":\"Bearer {jwt token}\"}'"
        },
        {
          "id": "PQYcz3s9Wtao7K0GsvV4O",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"authorization\", \"{\\\"Authorization\\\":\\\"Bearer {jwt token}\\\"}\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"/users\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "RTm1U0b1_hxy-k8VCPgHx",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/users\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"authorization\"] = \"{\\\"Authorization\\\":\\\"Bearer {jwt token}\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "yjIStSVaqsGsRqFErGpfm",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/users\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'authorization': '{\"Authorization\":\"Bearer {jwt token}\"}'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "KAlW0qTnqddyj-pcLqP9u"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Created\n{\n  \"_id\": \"myUserId\",\n  \"email\": \"myEmail@clemap.ch\",\n  \"isVerified\": false\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request\n{\n  \"name\": \"BadRequest\",\n  \"message\": \"Data does not match schema\",\n  \"code\": 400,\n  \"className\": \"bad-request\",\n  \"data\": \"\",\n  \"errors\": [\n    {}\n  ]\n}"
        },
        {
          "id": "response-2-409",
          "language": "409",
          "code": "// Conflict\n{\n  \"name\": \"Conflict\",\n  \"message\": \"Email myEmail@clemap.ch already exists\",\n  \"code\": 409,\n  \"className\": \"conflict\",\n  \"data\": \"\",\n  \"errors\": [\n    {}\n  ]\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "id": "Z6K6md3FRtGkrFbIAHdHM",
      "type": "paragraph",
      "children": [
        {
          "text": "Creates a new user object"
        }
      ]
    }
  ]
}