# Device

{% hint style="success" %}
API SERVER:

⇒ <mark style="color:yellow;">**<https://apivcloud.innoway.vn>**</mark>
{% endhint %}

## POST /api/devices

> Create device

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}},"schemas":{"Device":{"type":"object","properties":{"name":{"type":"string","description":"Tên thiết bị"},"project_id":{"type":"string","format":"uuid","description":"ID của project mà thiết bị thuộc về"},"key":{"type":"string","description":"Khóa định danh duy nhất cho thiết bị (nếu không có sẽ được gán với id thiết bị trên hệ thống)"},"type_id":{"type":"string","description":"Mã loại thiết bị (nếu có)"},"template_id":{"type":"string","description":"ID template của thiết bị (nếu có)"},"group_id":{"type":"string","description":"ID nhóm mà thiết bị thuộc về (nếu có)"},"org_id":{"type":"string","description":"ID tổ chức quản lý thiết bị (nếu có)"},"org_name":{"type":"string","description":"Tên tổ chức quản lý thiết bị (nếu có)"},"thing_id":{"type":"string","description":"ID liên kết với \"thing\" trong hệ thống IoT (nếu có)"},"handle_msg_svc":{"type":"string","description":"Tên service xử lý message từ thiết bị (nếu có)"},"metadata":{"type":"object","additionalProperties":true,"description":"Thông tin metadata bổ sung (các cặp key-value tùy ý)"},"additional_info":{"type":"object","description":"Thông tin bổ sung về hoạt động của thiết bị","properties":{"heartbeat_interval":{"type":"integer","description":"Thời gian chờ trước khi coi thiết bị là mất kết nối (tính bằng giây, ví dụ 172800 = 2 ngày)"},"timeout_lifecycle":{"type":"integer","description":"Hệ số nhân với heartbeat_interval (mặc định = 1)"}}},"attributes":{"type":"array","description":"Danh sách các thuộc tính (attributes) của thiết bị (nếu có)","items":{"$ref":"#/components/schemas/DeviceAttribute"}}},"required":["name","project_id"]},"DeviceAttribute":{"type":"object","properties":{"attribute_type":{"type":"string","description":"Phạm vi của attribute (SCOPE_CLIENT)"},"attribute_key":{"type":"string","description":"Tên khóa attribute"},"logged":{"type":"boolean","description":"Cho biết attribute có được ghi log lại hay không"},"value":{"type":"string","description":"Giá trị của attribute (dưới dạng string)"},"value_t":{"type":"string","description":"Kiểu dữ liệu của giá trị (STR = string, DBL = double, BOOL = boolean, JSON, LONG = integer)"}},"required":["attribute_type","attribute_key","value","value_t"]}}},"paths":{"/api/devices":{"post":{"summary":"Create device","tags":[],"responses":{"200":{"description":"Tạo mới thiết bị thành công","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}}}}}}
```

## POST /api/devices/bulk

> Create devices list

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}},"schemas":{"CreateDevicesListRequest":{"type":"object","properties":{"devices":{"type":"array","description":"Danh sách thiết bị cần tạo","items":{"$ref":"#/components/schemas/Device"}}}},"Device":{"type":"object","properties":{"name":{"type":"string","description":"Tên thiết bị"},"project_id":{"type":"string","format":"uuid","description":"ID của project mà thiết bị thuộc về"},"key":{"type":"string","description":"Khóa định danh duy nhất cho thiết bị (nếu không có sẽ được gán với id thiết bị trên hệ thống)"},"type_id":{"type":"string","description":"Mã loại thiết bị (nếu có)"},"template_id":{"type":"string","description":"ID template của thiết bị (nếu có)"},"group_id":{"type":"string","description":"ID nhóm mà thiết bị thuộc về (nếu có)"},"org_id":{"type":"string","description":"ID tổ chức quản lý thiết bị (nếu có)"},"org_name":{"type":"string","description":"Tên tổ chức quản lý thiết bị (nếu có)"},"thing_id":{"type":"string","description":"ID liên kết với \"thing\" trong hệ thống IoT (nếu có)"},"handle_msg_svc":{"type":"string","description":"Tên service xử lý message từ thiết bị (nếu có)"},"metadata":{"type":"object","additionalProperties":true,"description":"Thông tin metadata bổ sung (các cặp key-value tùy ý)"},"additional_info":{"type":"object","description":"Thông tin bổ sung về hoạt động của thiết bị","properties":{"heartbeat_interval":{"type":"integer","description":"Thời gian chờ trước khi coi thiết bị là mất kết nối (tính bằng giây, ví dụ 172800 = 2 ngày)"},"timeout_lifecycle":{"type":"integer","description":"Hệ số nhân với heartbeat_interval (mặc định = 1)"}}},"attributes":{"type":"array","description":"Danh sách các thuộc tính (attributes) của thiết bị (nếu có)","items":{"$ref":"#/components/schemas/DeviceAttribute"}}},"required":["name","project_id"]},"DeviceAttribute":{"type":"object","properties":{"attribute_type":{"type":"string","description":"Phạm vi của attribute (SCOPE_CLIENT)"},"attribute_key":{"type":"string","description":"Tên khóa attribute"},"logged":{"type":"boolean","description":"Cho biết attribute có được ghi log lại hay không"},"value":{"type":"string","description":"Giá trị của attribute (dưới dạng string)"},"value_t":{"type":"string","description":"Kiểu dữ liệu của giá trị (STR = string, DBL = double, BOOL = boolean, JSON, LONG = integer)"}},"required":["attribute_type","attribute_key","value","value_t"]}}},"paths":{"/api/devices/bulk":{"post":{"summary":"Create devices list","tags":[],"parameters":[],"responses":{"200":{"description":"Tạo mới nhiều thiết bị thành công"}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDevicesListRequest"}}}}}}}}
```

## GET /api/devices/{device\_id}

> Get device by id

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}},"schemas":{"DeviceResponses":{"type":"object","properties":{"id":{"type":"string","description":"id thiết bị"},"name":{"type":"string","description":"Tên thiết bị"},"project_id":{"type":"string","format":"uuid","description":"ID của project mà thiết bị thuộc về"},"key":{"type":"string","description":"Khóa định danh duy nhất cho thiết bị (nếu không có sẽ được gán với id thiết bị trên hệ thống)"},"type_id":{"type":"string","description":"Mã loại thiết bị (nếu có)"},"template_id":{"type":"string","description":"ID template của thiết bị (nếu có)"},"group_id":{"type":"string","description":"ID nhóm mà thiết bị thuộc về (nếu có)"},"org_id":{"type":"string","description":"ID tổ chức quản lý thiết bị (nếu có)"},"org_name":{"type":"string","description":"Tên tổ chức quản lý thiết bị (nếu có)"},"thing_id":{"type":"string","description":"ID liên kết với \"thing\" trong hệ thống IoT (nếu có)"},"handle_msg_svc":{"type":"string","description":"Tên service xử lý message từ thiết bị (nếu có)"},"metadata":{"type":"object","additionalProperties":true,"description":"Thông tin metadata bổ sung (các cặp key-value tùy ý)"},"additional_info":{"type":"object","description":"Thông tin bổ sung về hoạt động của thiết bị","properties":{"heartbeat_interval":{"type":"integer","description":"Thời gian chờ trước khi coi thiết bị là mất kết nối (tính bằng giây, ví dụ 172800 = 2 ngày)"},"timeout_lifecycle":{"type":"integer","description":"Hệ số nhân với heartbeat_interval (mặc định = 1)"}}},"attributes":{"type":"array","description":"Danh sách các thuộc tính (attributes) của thiết bị (nếu có)","items":{"$ref":"#/components/schemas/DeviceAttribute"}}}},"DeviceAttribute":{"type":"object","properties":{"attribute_type":{"type":"string","description":"Phạm vi của attribute (SCOPE_CLIENT)"},"attribute_key":{"type":"string","description":"Tên khóa attribute"},"logged":{"type":"boolean","description":"Cho biết attribute có được ghi log lại hay không"},"value":{"type":"string","description":"Giá trị của attribute (dưới dạng string)"},"value_t":{"type":"string","description":"Kiểu dữ liệu của giá trị (STR = string, DBL = double, BOOL = boolean, JSON, LONG = integer)"}},"required":["attribute_type","attribute_key","value","value_t"]}}},"paths":{"/api/devices/{device_id}":{"get":{"summary":"Get device by id","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Lấy thông tin thiết bị thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceResponses"}}}}}}}}}
```

## GET /api/devices

> Get list devices

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}},"schemas":{"GetDevicesListResponses":{"type":"object","properties":{"devices":{"type":"array","description":"Danh sách thiết bị","items":{"$ref":"#/components/schemas/DeviceResponses"}}}},"DeviceResponses":{"type":"object","properties":{"id":{"type":"string","description":"id thiết bị"},"name":{"type":"string","description":"Tên thiết bị"},"project_id":{"type":"string","format":"uuid","description":"ID của project mà thiết bị thuộc về"},"key":{"type":"string","description":"Khóa định danh duy nhất cho thiết bị (nếu không có sẽ được gán với id thiết bị trên hệ thống)"},"type_id":{"type":"string","description":"Mã loại thiết bị (nếu có)"},"template_id":{"type":"string","description":"ID template của thiết bị (nếu có)"},"group_id":{"type":"string","description":"ID nhóm mà thiết bị thuộc về (nếu có)"},"org_id":{"type":"string","description":"ID tổ chức quản lý thiết bị (nếu có)"},"org_name":{"type":"string","description":"Tên tổ chức quản lý thiết bị (nếu có)"},"thing_id":{"type":"string","description":"ID liên kết với \"thing\" trong hệ thống IoT (nếu có)"},"handle_msg_svc":{"type":"string","description":"Tên service xử lý message từ thiết bị (nếu có)"},"metadata":{"type":"object","additionalProperties":true,"description":"Thông tin metadata bổ sung (các cặp key-value tùy ý)"},"additional_info":{"type":"object","description":"Thông tin bổ sung về hoạt động của thiết bị","properties":{"heartbeat_interval":{"type":"integer","description":"Thời gian chờ trước khi coi thiết bị là mất kết nối (tính bằng giây, ví dụ 172800 = 2 ngày)"},"timeout_lifecycle":{"type":"integer","description":"Hệ số nhân với heartbeat_interval (mặc định = 1)"}}},"attributes":{"type":"array","description":"Danh sách các thuộc tính (attributes) của thiết bị (nếu có)","items":{"$ref":"#/components/schemas/DeviceAttribute"}}}},"DeviceAttribute":{"type":"object","properties":{"attribute_type":{"type":"string","description":"Phạm vi của attribute (SCOPE_CLIENT)"},"attribute_key":{"type":"string","description":"Tên khóa attribute"},"logged":{"type":"boolean","description":"Cho biết attribute có được ghi log lại hay không"},"value":{"type":"string","description":"Giá trị của attribute (dưới dạng string)"},"value_t":{"type":"string","description":"Kiểu dữ liệu của giá trị (STR = string, DBL = double, BOOL = boolean, JSON, LONG = integer)"}},"required":["attribute_type","attribute_key","value","value_t"]}}},"paths":{"/api/devices":{"get":{"summary":"Get list devices","tags":[],"parameters":[{"name":"project_id","in":"query","required":false,"schema":{"type":"integer"}},{"name":"search_str","in":"query","required":false,"schema":{"type":"string"}},{"name":"search_field","in":"query","required":false,"schema":{"type":"string"}},{"name":"created_by","in":"query","required":false,"schema":{"type":"integer"}},{"name":"org_id","in":"query","required":false,"schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"schema":{"type":"boolean"}},{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"type_id","in":"query","required":false,"schema":{"type":"string"}},{"name":"get_attributes","in":"query","required":false,"schema":{"type":"boolean"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Lấy danh sách thiết bị thành công","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetDevicesListResponses"}}}}}}}}}
```

## PUT /api/devices/{device\_id}

> Update device

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}}},"paths":{"/api/devices/{device_id}":{"put":{"summary":"Update device","tags":[],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{}}}},"responses":{"200":{"description":"Cập nhật thông tin thiết bị thành công"}}}}}}
```

## DELETE /api/devices/{device\_id}

> Delete device

```json
{"openapi":"3.0.0","info":{"title":"Device","version":"1.0.0"},"servers":[{"url":"https://apivcloud.innoway.vn"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"<token>"}}},"paths":{"/api/devices/{device_id}":{"delete":{"summary":"Delete device","tags":[],"parameters":[],"responses":{"200":{"description":"Xóa thiết bị thành công"}},"requestBody":{"content":{"application/json":{"schema":{}}}}}}}}
```


---

# Agent Instructions: 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://innoway.gitbook.io/innoway/tai-lieu/api/rest-api/device.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.
