---
title: "Creates a sensor rule"
method: POST
path: "/sensors/v3"
tags: ["Sensors"]
---

# Creates a sensor rule

`POST /sensors/v3`

Creates a sensor rule of the specified rule type.
After the sensor rule has been created, it needs to be associated to a device to get activated.

For a sensor rule of the battery, humidity, pressure and temperature type, a `range` parameter needs 
to be specified, defining both upper and lower thresholds for the sensor readings. 
When the device ingests data, the reported sensor reading is compared to the defined range 
and in case in or out of range transition has taken place, an event gets triggered.

For a sensor rule of the acceleration type, a `threshold` parameter needs 
to be specified, defining the acceleration threshold value.
Every time the device reports its accelerometer sensor reading being above the threshold, 
an event gets triggered.

For a sensor rule of the attach and tamper types, no additional parameters
need to be specified.
The attach sensor detects whether the device is attached to some object (for example to an 
asset).
The tamper sensor detects whether the device cover is open or closed. When the cover is open,
the device is considered to be tampered with.
Every time the device reports getting attached, detached, tampered with or left with the 
cover closed (that is, not tampered with), an event gets triggered.

When a sensor rule has been successfully created, the response body will contain the created rule ID.

## Request body

- union
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `range` object, required
      - `begin` number, required — A minimum battery sensor alarm threshold value. Must be less than end.
      - `end` number, required — A maximum battery sensor alarm threshold value. Must be greater than begin.
    - `type` 'battery', required — The sensor type.
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `range` object, required
      - `begin` number, required — A minimum humidity sensor alarm threshold value. Must be less than end.
      - `end` number, required — A maximum humidity sensor alarm threshold value. Must be greater than begin.
    - `type` 'humidity', required — The sensor type.
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `range` object, required
      - `begin` number, required — A minimum pressure sensor alarm threshold value. Must be less than end.
      - `end` number, required — A maximum pressure sensor alarm threshold value. Must be greater than begin.
    - `type` 'pressure', required — The sensor type.
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `range` object, required
      - `begin` number, required — A minimum temperature sensor alarm threshold value. Must be less than end.
      - `end` number, required — A maximum temperature sensor alarm threshold value. Must be greater than begin.
    - `type` 'temperature', required — The sensor type.
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `type` 'attach' | 'tamper', required — The sensor type.
  - object
    - `description` string — Sensor rule description
    - `name` string — Sensor rule name
    - `threshold` object, required
      - `value` number, required — An acceleration sensor alarm threshold value.
    - `type` 'acceleration', required — The sensor type.

## Response `201`

Created

The sensor rule was successfully created.

- object
  - `id` string, uuid, required — Must be a valid UUIDv4.
  - `message` string — Set to `created` if the sensor rule creation was successful.

## Other responses

- `400` — Bad request The request object is in an incorrect format or has values that are invalid or out of range. If available, further error details are provided in the response body.
- `401` — Unauthorized The request did not provide correct authentication details
- `403` — Forbidden The account does not have the correct privileges

---

[API](https://skmtc.net/here/apis/tracking.md) · [All operations](https://skmtc.net/here/apis/tracking/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/here/tracking/versions/efa162f7023c/schema)
