---
title: Activate a new sensor
slug: dev/activate-a-new-sensor
docTags: 
createdAt: 2023-02-23T17:07:09.000Z
---

{
  "id": "t31Ccwrb3A21RlABisDFq",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/sensors",
    "name": "Activate a new sensor",
    "description": "Activate a new sensor with an activation code",
    "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",
          "example": "{\"hw_serial\":\"SE01000000\",\"activation_code\":\"AAAA-BBBB-CCCC-DDDD\"}",
          "schema": [
            {
              "name": "hw_serial",
              "kind": "required",
              "type": "string",
              "description": "hardware serial number of sensor",
              "example": ""
            },
            {
              "name": "activation_code",
              "kind": "required",
              "type": "string",
              "description": "activation code of the sensor",
              "example": ""
            }
          ],
          "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": ""
              },
              {
                "name": "hw_serial",
                "kind": "optional",
                "type": "string",
                "example": "SE01000000"
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "number",
                "example": 1
              },
              {
                "name": "user_id",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "fw_version",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "sensor_profile",
                "kind": "optional",
                "type": "object",
                "example": "{\"label\":\"My sensor\",\"street_and_number\":\"Flurstrasse 30\",\"zip_code\":8048,\"city\":\"Zürich\",\"country\":\"sui\"}",
                "schema": []
              },
              {
                "name": "sensor_type",
                "kind": "optional",
                "type": "string",
                "example": "clemap_lm"
              }
            ],
            "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": "401",
        "description": "Unauthorized",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "name": "name",
                "kind": "optional",
                "type": "string",
                "description": "Error name",
                "example": "NotAuthenticated"
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "Error message",
                "example": "Not authenticated"
              },
              {
                "name": "code",
                "kind": "optional",
                "type": "number",
                "description": "HTTP status code",
                "example": 401
              },
              {
                "name": "className",
                "kind": "optional",
                "type": "string",
                "description": "Error class name",
                "example": "not-authenticated"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "object",
                "description": "Description of errors",
                "example": "",
                "schema": []
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "syE2ZEm0bOZEQpOSXBxFz",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url /sensors \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --header 'authorization: {\"Authorization\":\"Bearer {jwt token}\"}' \\\n     --data '{\n     \"hw_serial\": \"\",\n     \"activation_code\": \"\"\n     }'"
        },
        {
          "id": "88rGrUZdD889L_w1zhIkS",
          "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 raw = JSON.stringify({\n   \"hw_serial\": \"\",\n   \"activation_code\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/sensors\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "SItx0vx7rchPTI3ivVfSz",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/sensors\")\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}\\\"}\"\nrequest.body = JSON.dump({\n   \"hw_serial\": \"\",\n   \"activation_code\": \"\"\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "BCsdcwIGfHiuDsYl8VXDn",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/sensors\"\n\npayload = json.dumps({\n   \"hw_serial\": \"\",\n   \"activation_code\": \"\"\n})\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": "syE2ZEm0bOZEQpOSXBxFz"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Created\n{\n  \"_id\": \"\",\n  \"hw_serial\": \"SE01000000\",\n  \"status\": 1,\n  \"user_id\": \"\",\n  \"fw_version\": \"\",\n  \"sensor_profile\": {},\n  \"sensor_type\": \"clemap_lm\"\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-401",
          "language": "401",
          "code": "// Unauthorized\n{\n  \"name\": \"NotAuthenticated\",\n  \"message\": \"Not authenticated\",\n  \"code\": 401,\n  \"className\": \"not-authenticated\",\n  \"errors\": {}\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "id": "BXxOKVbVV4D6M1S9Z5HrV",
      "type": "paragraph",
      "children": [
        {
          "text": "Activate a new sensor with an activation code"
        }
      ]
    }
  ]
}