> For the complete documentation index, see [llms.txt](https://innoway.gitbook.io/innoway/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://innoway.gitbook.io/innoway/tinh-nang/tinh-nang-khac/provision-device.md).

# Provision Device

## Mô tả trường hợp sử dụng

Với tư cách là nhà sản xuất thiết bị hoặc nhà phát triển firmware, tôi muốn các thiết bị của mình tự động được tạo trong Innoway. Trong quá trình cung tạo tự động, thiết bị có thể tạo thông tin xác thực (token) hoặc yêu cầu máy chủ cung cấp thông tin xác thực duy nhất cho thiết bị.

## Mô tả cách hoạt động

<figure><img src="/files/CWtDBr2LlWNz6Uc6y4go" alt=""><figcaption></figcaption></figure>

Thiết bị có thể gửi Provision Request đến Innoway. Provision Request luôn chứa provisionKey, provisionSecret. Ngoài ra Provision Request còn có thể chứa thông tin như deviceName, deviceKey do thiết bị tùy chọn.  Nếu những thông tin đăng nhập đó không có, Innoway sẽ tạo một thiết bị ảo và token trả về cho thiết bị.

Ví dụ Provision Request:

```json
{
  "provision_key": "hHT0d5BId6azReT94Xwk",
  "provision_secret": "6hbFSRcigdKKjhsSO713",
  "device_name": "test 111",
  "device_key": "provision_1"
}
```

Ví dụ Provision Response:

```json
{
  "device_id": "bb56e5d7-96bc-4339-8780-6ebb67e5ac44",
  "status": "SUCCESS",
  "token": "zD8zxMrMaRVnhZhiGEVuRw2jid3oW721"
}
```

## Provision Device APIs <a href="#provision-device-apis" id="provision-device-apis"></a>

Để thực hiện Provision Device, trước tiên người dùng tạo mẫu thiết bị (Templates)

Chọn Đám mây -> Mẫu thiết bị -> Nhấn "**+**" để tạo

<figure><img src="/files/JjTkeyGJXp78VSDrXUJ8" alt=""><figcaption></figcaption></figure>

Sau khi tạo thành công mẫu thiết bị người dùng sẽ có được ProvisionKey và ProvisionSecret

<figure><img src="/files/23RdniaercRKDzL0UMck" alt=""><figcaption></figcaption></figure>

Sau đó sử dụng ProvisionKey và ProvisionSecret để thực hiện Provisioning. Tham khảo các giao thức hỗ trợ

### [**MQTT Device APIs**](/innoway/tai-lieu/api/mqtt-device-api.md)

### [**HTTP Device APIs**](/innoway/tai-lieu/api/http-device-api.md)

<br>


---

# 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, and the optional `goal` query parameter:

```
GET https://innoway.gitbook.io/innoway/tinh-nang/tinh-nang-khac/provision-device.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
