# Thing Types

A Thing Type is a schema template that defines a category of devices. It describes the properties a device reports, the events it can emit, and the commands it accepts. Individual devices (Things) are registered against a Thing Type and inherit its structure.

When a Thing Type is created, Fleets automatically creates a **default Thing Group** for it, which contains all Things of that type. See [Thing Groups](./thing_groups.md) for details on group management.

## Create a Thing Type

1. In your Fleets deployment, go to **Device Management** > **Thing Types**.
2. Click **+ New Type**. The New Type page opens.
3. Fill in the basic fields:
   - **Name** (required): A unique identifier for this type within the deployment. Use a reverse-domain format for clarity, for example `com.example.thermostat`.
   - **Version**: Defaults to `1.0.0`.
   - **Description** (optional).
   - **Tags** (optional).
4. Define the schema by adding properties, events, and commands (see below). All sections are optional. You can leave them empty and add items later by editing the Thing Type.
5. Click **Confirm**.

![new_thing_type](./_assets/new_thing_type.png)

### Add a Property

Properties represent state variables that a device reports. A writable property can also be set from the cloud via Device Shadow.

1. In the **Properties** section, click **+ Add**.
2. Fill in the fields:
   - **Name**: The property name.
   - **Type**: Select one of `string`, `int`, `float`, `boolean`, or `enum`.
   - **Writable**: Toggle on to allow cloud-side updates via shadow desired state.
   - **Description** (optional).
3. For numeric types (`int` or `float`), expand **Number constraints** to set:
   - **Unit** (optional): The unit of measurement, for example `°C` or `%`.
   - **Min** / **Max** (optional): The allowed value range.
4. Click **Confirm**.

![add_property](./_assets/add_property.png)

### Add an Event

Events are named occurrences that a device can emit, such as an alarm or a fault condition.

1. In the **Events** section, click **+ Add**.
2. Fill in the fields:
   - **Name**: The event name.
   - **Severity**: Select `info`, `warn`, or `error`. Defaults to `warn`.
   - **Description** (optional).
3. Click **Confirm**.

### Add a Command

Commands are actions that can be sent to a device for execution.

1. In the **Commands** section, click **+ Add**.
2. Fill in the fields:
   - **Name**: The command name.
   - **Type**: `sync` (real-time, with a configurable timeout).
   - **Timeout (ms)**: How long Fleets waits for a device response. Defaults to `5000`.
   - **Description** (optional).
3. To add input parameters, click **+ Add** in the **Input** section. In the Add Field dialog, enter a **Name** and select a **Type** (`string`, `int`, `float`, `boolean`, or `enum`).
4. To add output parameters, click **+ Add** in the **Output** section and fill in the same fields.
5. Click **Confirm**.

### Raw JSON

Toggle **Raw JSON** in the upper right to view the full schema as a JSON object while editing. The panel updates in real time as you add properties, events, and commands.

## Import a Thing Type

You can import a Thing Type from a JSON file to reuse schemas across deployments or environments.

1. Click **Import** in the upper right of the **Thing Types** page.
2. Click **Download Template** to get a sample JSON file showing the expected format.
3. Edit the template with your schema, then click **Select File** to choose the file.
4. Click **Import**.

If a Thing Type with the same name already exists, the import returns an error.

## View a Thing Type

Click a Thing Type name in the list to open its detail page. The detail page shows the basic fields and the full schema (properties, events, and commands) in read-only mode. Click the edit icon in the upper right to open the Edit Type page.

![thing_type_details](./_assets/thing_type_details.png)

## Export a Thing Type

To export a Thing Type as a JSON file, click the export icon in the **Actions** column. The file can be used to import the same schema into another deployment.

## Update a Thing Type

To edit the basic fields (name, version, description, or tags):

1. In the **Thing Types** list, click the edit icon in the **Actions** column, or open the detail page and click the edit icon in the upper right.
2. Modify the fields.
3. Click **Save**.

To update the schema (add or remove properties, events, or commands), open the Edit Type page and use the **+ Add** buttons or the delete icon next to each item.

::: warning Important Notice

Updating a Thing Type schema does not automatically update the shadow state or properties of existing Things. Changes apply to Things registered after the update.

:::

## Delete a Thing Type

1. In the **Thing Types** list, click the delete icon in the **Actions** column.
2. Confirm the deletion.

A Thing Type cannot be deleted if it has registered Things. Delete or reassign all associated Things first.

Deleting a Thing Type also deletes its default Thing Group.

## Next Steps

- [Things](./things.md)
- [Thing Groups](./thing_groups.md)
- [Device Shadow](../device_shadow.md)
