> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Sensor

> Create a new Sensor record.

A **Sensor** represents a physical IoT sensor deployed in a location for monitoring environmental conditions or occupancy. Sensors can detect presence, count people, measure temperature, humidity, noise, CO2 levels, and other metrics.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`Sensor-Create`** role.
</Note>

## Enums

<Accordion title="eSensorType — SensorType values">
  | Value | Name                     |
  | ----- | ------------------------ |
  | 1     | PresenceDetection        |
  | 2     | PeopleCounter            |
  | 3     | Temperature              |
  | 4     | Humidity                 |
  | 5     | Light                    |
  | 6     | Noise                    |
  | 7     | CO2                      |
  | 8     | VolatileOrganicCompounds |
  | 9     | HarmfulParticulates      |
  | 10    | Touch                    |
  | 11    | Water                    |
  | 12    | AtmosphericPressure      |
  | 13    | Power                    |
  | 14    | OpenClosed               |
  | 99    | Other                    |
</Accordion>

<Accordion title="eSensorDataStrategy — DataStrategy values">
  | Value | Name                   |
  | ----- | ---------------------- |
  | 1     | Polling                |
  | 2     | Endpoint               |
  | 3     | DisruptiveTechnologies |
  | 4     | Pressac                |
</Accordion>

## Request Body

### Required Fields

<ParamField body="BusinessId" type="integer" required>
  ID of the business linked to this record.
</ParamField>

<ParamField body="Name" type="string" required>
  The name value for this sensor.
</ParamField>

<ParamField body="Reference" type="string" required>
  The reference value for this sensor.
</ParamField>

<ParamField body="SensorType" type="integer" required>
  The sensor type value for this sensor.
</ParamField>

<ParamField body="DataStrategy" type="integer" required>
  The data strategy value for this sensor.
</ParamField>

### Optional Fields

<ParamField body="Desks" type="integer[]">
  List of desks linked to this record.
</ParamField>

<ParamField body="Resources" type="integer[]">
  List of resources linked to this record.
</ParamField>

<ParamField body="CannedResponseId" type="integer">
  ID of the canned response linked to this record.
</ParamField>

<ParamField body="Unit" type="string">
  The unit value for this sensor.
</ParamField>

<ParamField body="Active" type="boolean">
  Whether this sensor is currently active.
</ParamField>

<ParamField body="PayloadDataPath" type="string">
  The payload data path value for this sensor.
</ParamField>

<ParamField body="ActionTriggerFunction" type="string">
  The action trigger function value for this sensor.
</ParamField>

<ParamField body="ValueFunction" type="string">
  The value function value for this sensor.
</ParamField>

<ParamField body="ActionSendEmailAlert" type="boolean">
  Whether action send email alert is enabled.
</ParamField>

<ParamField body="AlertEmailAddress" type="string">
  The alert email address value for this sensor.
</ParamField>

<ParamField body="WebhookUrl" type="string">
  The webhook url value for this sensor.
</ParamField>

<ParamField body="ActionUpdateDeskAvailability" type="boolean">
  Whether action update desk availability is enabled.
</ParamField>

<ParamField body="ActionUpdateResourceAvailability" type="boolean">
  Whether action update resource availability is enabled.
</ParamField>

<ParamField body="ActionUpdateBookingOccupancy" type="boolean">
  Whether action update booking occupancy is enabled.
</ParamField>

<ParamField body="ActionSendCustomerEmailAlert" type="boolean">
  Whether action send customer email alert is enabled.
</ParamField>

<ParamField body="ActionBookingStart" type="boolean">
  Whether action booking start is enabled.
</ParamField>

<ParamField body="ActionBookingTerminate" type="boolean">
  Whether action booking terminate is enabled.
</ParamField>

<ParamField body="ActionCheckInOrOut" type="boolean">
  Whether action check in or out is enabled.
</ParamField>

<ParamField body="ActionMakeHttpRequest" type="boolean">
  Whether action make http request is enabled.
</ParamField>

<ParamField body="ShowInNowDashboard" type="boolean">
  Whether show in now dashboard is enabled.
</ParamField>

<ParamField body="ShowInPortal" type="boolean">
  Whether show in portal is enabled.
</ParamField>

<ParamField body="SharedSecret" type="string">
  The shared secret value for this sensor.
</ParamField>

<ParamField body="ApiKey" type="string">
  The api key value for this sensor.
</ParamField>

<ParamField body="Username" type="string">
  The username value for this sensor.
</ParamField>

<ParamField body="Password" type="string">
  The password value for this sensor.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/sys/sensors" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "BusinessId": 0,
      "Name": "",
      "Reference": "",
      "SensorType": 0,
      "DataStrategy": 0
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/sys/sensors',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        BusinessId: 0,
        Name: '',
        Reference: '',
        SensorType: 0,
        DataStrategy: 0
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://spaces.nexudus.com/api/sys/sensors',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'BusinessId': 0,
          'Name': '',
          'Reference': '',
          'SensorType': 0,
          'DataStrategy': 0
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the creation.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the newly created record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the sensor was created successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "Sensor was successfully created.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "Name: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Name"
    }
  ],
  "WasSuccessful": false
}
```
