// Module included in the following assemblies:
//
// assembly-iot-guide.adoc
// assembly-IoT.adoc

[id='iot-creating-device-{context}']
= Creating an IoT device

After installing the IoT services and creating an IoT project, you can create an IoT device for the device you want to monitor.

ifeval::["{cmdcli}" == "oc"]
:registry: $(oc -n enmasse-infra get routes device-registry --template='{{ .spec.host }}')
endif::[]
ifeval::["{cmdcli}" == "kubectl"]
:registry: $(kubectl -n enmasse-infra get service iot-device-registry-external -o jsonpath={.status.loadBalancer.ingress[0].hostname}):31443
endif::[]

.Prerequisites
* link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#installing-services-iot[The IoT services are installed].
* link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#iot-creating-project-iot[An IoT project is created].

.Procedure

. Register a device:
+
[options="nowrap",subs="attributes"]
----
curl --insecure -X POST -i -H 'Content-Type: application/json' --data-binary '{"device-id": "4711"}' https://{registry}/registration/myapp.iot
----

. Add credentials for a device:
+
[options="nowrap",subs="attributes"]
----
curl --insecure -X POST -i -H 'Content-Type: application/json' --data-binary '{"device-id": "4711","type": "hashed-password","auth-id": "sensor1","secrets": [{"hash-function" : "sha-512","pwd-plain":"'hono-secret'"}]}' https://{registry}/credentials/myapp.iot
----

