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

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::[]

.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
----