# Smart REST static template 101 creates a child device with unexpected external id

**URL:** https://community.cumulocity.com/t/smart-rest-static-template-101-creates-a-child-device-with-unexpected-external-id/7427
**Category:** Forum
**Tags:** cumulocity
**Created:** [April 30, 2024, 12:28pm UTC](https://community.cumulocity.com/t/smart-rest-static-template-101-creates-a-child-device-with-unexpected-external-id/7427 "2024-04-30T12:28:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dacsystemsw](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dacsystemsw](https://community.cumulocity.com/u/dacsystemsw)
#### Post date: [April 30, 2024, 12:28pm UTC](https://community.cumulocity.com/t/smart-rest-static-template-101-creates-a-child-device-with-unexpected-external-id/7427/1 "2024-04-30T12:28:14Z")

</div>

#### _ **Product/components** used and **version/fix** level:_

Cumulocity IoT 1020.296.0

#### _Detailed explanation of the problem:_

As mentioned in the title we use Smart REST to create devices. In particular we already created a root device and we are now creating some child devices.

We are able to create a child device but the external id bounded to that device is not what we expect.

Indeed from the [docs](https://cumulocity.com/docs/smartrest/mqtt-static-templates/#101) about child device creation is stated that:

> […] an externaId for the child will be created with type `c8y_Serial` and the **value a combination of the serial of the root device and the unique child ID.**

The value of the external id of the resulting child device is just the id included in the mqtt message.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/5/5/558bac1537d51615301d317c0533e027cf2f4401.png)

The code:

```auto
String childDeviceName = "childSensor";
		String childDeviceType = "dac_sensor";
		String childId = "1";
		String staticTemplateCode = "101";

		client.publish("s/us",
				(staticTemplateCode + "," + childId + "," + childDeviceName + "," + childDeviceType).getBytes(), 2,
				false);

```

Should I manually create the combination of parent and child id?

#### _Error messages / **full error** message screenshot / **log** file:_

#### _Question related to a **free trial** , or to a **production (customer)** instance?_

Customer instance

---

<div class="post-metadata">

### Author: ![Stefan\_Witschel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/stefan_witschel/32/31955_2.png) [@Stefan\_Witschel](https://community.cumulocity.com/u/Stefan_Witschel)
#### Post date: [April 30, 2024, 12:54pm UTC](https://community.cumulocity.com/t/smart-rest-static-template-101-creates-a-child-device-with-unexpected-external-id/7427/2 "2024-04-30T12:54:35Z")

</div>

I think the documentation is misleading here.  
When creating a device using 100 SmartREST template the clientID of the MQTT client is used as an external ID.  
For child devices you must explicitly name the unique ID of the children. If you want to combine the clientID + child device ID you can do so. Still I would suggest to use something unique like serial number also for the child device when available and not “1,2,3” etc. 😉

---

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)
#### Post date: [October 27, 2024, 12:54pm UTC](https://community.cumulocity.com/t/smart-rest-static-template-101-creates-a-child-device-with-unexpected-external-id/7427/3 "2024-10-27T12:54:44Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
