> For the complete documentation index, see [llms.txt](https://docs.akenza.io/akenza.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akenza.io/akenza.io/get-started/reference/api-documentation/schema-inference.md).

# Schema inference

Each device has its own [Custom Device Types](/akenza.io/get-started/your-data-flow/device-type/device-type.md#data-schema), describing which type of data is available on which topic. This schema can be inferred from the stored data and queried over the REST API. The inferred schema is combined from both device type schema and effective data that is measured by the device. The device type schema can be used to further annotate the underlying data model and units.

## Infer schema

<mark style="color:green;">`GET`</mark> `https://api.akenza.io/v3/devices/{deviceId}/infer-schema`

Infer the schema of a device identified by its id

{% hint style="warning" %}
The /infer-schema/ endpoint returns a maximum of 50 topics.&#x20;
{% endhint %}

#### Query Parameters

| Name     | Type   | Description                    |
| -------- | ------ | ------------------------------ |
| deviceId | String | akenza device id of the sensor |

#### Response example

```json
{
    "lifecycle": { // topic
        "$id": "https://akenza.io/dynamic/08fe4bc0d0994882/lifecycle.schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Lifecycle",
        "type": "object",
        "properties": {
            "batteryVoltage": { // data key
                "title": "Battery Voltage",
                "type": "number",
                "inferred": true,
                "properties": {}
            },
            "batteryLevel": {
                "title": "Battery Level",
                "type": "number",
                "inferred": true,
                "properties": {}
            }
        }
    },
    "default": {
        "$id": "https://akenza.io/internal/deviceSimulator/default.schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Default",
        "type": "object",
        "properties": {
            "illuminance": {
                "title": "Light",
                "unit": "lx",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/environment/schema.json#/$defs/illuminance/lux",
                "measurementType": "akenza/environment/illuminance/lux",
                "type": "number",
                "description": "Light value",
                "properties": {}
            },
            "light": {
                "title": "Light",
                "type": "number",
                "inferred": true,
                "properties": {}
            },
            "co2": {
                "title": "CO2",
                "unit": "ppm",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/environment/schema.json#/$defs/co2/ppm",
                "measurementType": "akenza/environment/co2/ppm",
                "type": "number",
                "description": "Carbon Dioxide in ppm",
                "properties": {}
            },
            "sound": {
                "title": "Sound",
                "unit": "dB(A)",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/environment/schema.json#/$defs/soundLevel/dba",
                "measurementType": "akenza/environment/soundLevel/dba",
                "type": "number",
                "description": "Average value of the sound pressure level in decibel",
                "minimum": 20,
                "maximum": 120,
                "properties": {}
            },
            "temperature": {
                "title": "Temperature",
                "unit": "°C",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/environment/schema.json#/$defs/temperature/celsius",
                "measurementType": "akenza/environment/temperature/celsius",
                "type": "number",
                "description": "Temperature in degrees Celcius",
                "properties": {}
            },
            "humidity": {
                "title": "Humidity",
                "unit": "%",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/environment/schema.json#/$defs/humidity/percent",
                "measurementType": "akenza/environment/humidity/percent",
                "type": "number",
                "description": "Relative humidity in percent",
                "minimum": 0,
                "maximum": 100,
                "properties": {}
            },
            "occupied": {
                "title": "Occupied",
                "$ref": "https://raw.githubusercontent.com/akenza-io/device-type-library/main/data-models/spaces/schema.json#/$defs/occupied/boolean",
                "measurementType": "akenza/spaces/occupied/boolean",
                "type": "boolean",
                "description": "Whether the space is occupied",
                "properties": {}
            }
        }
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akenza.io/akenza.io/get-started/reference/api-documentation/schema-inference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
