# How to create Sparkplug UDT definitions using Node-red / Nodejs

**URL:** <https://forum.inductiveautomation.com/t/how-to-create-sparkplug-udt-definitions-using-node-red-nodejs/105192>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 16, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/how-to-create-sparkplug-udt-definitions-using-node-red-nodejs/105192 "2025-04-16T19:19:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r2s\_6](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@r2s\_6](https://forum.inductiveautomation.com/u/r2s_6)\
**Post date:** [April 16, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/how-to-create-sparkplug-udt-definitions-using-node-red-nodejs/105192/1 "2025-04-16T19:19:02Z")

</div>

"Hello!

I need to generate UDT definitions (templates) for MQTT Engine, using scripts or JSON formatting with Node-RED's Sparkplug B nodes. Is there a way to achieve this, and if so, what's the best method? I haven't been able to find information on this in the Sparkplug B or MQTT Engine documentation. Thank you."

---

<div class="post-metadata">

**Author:** ![bill.liu](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bill.liu](https://forum.inductiveautomation.com/u/bill.liu)\
**Post date:** [April 17, 2025, 2:17am UTC](https://forum.inductiveautomation.com/t/how-to-create-sparkplug-udt-definitions-using-node-red-nodejs/105192/2 "2025-04-17T02:17:25Z")

</div>

I am using the eclipse tahu code base. You can check the example code here: [tahu/javascript/examples/simple/example.js at 5736e404889d4b95910613040a99ba79589ffb13 · eclipse-tahu/tahu · GitHub](https://github.com/eclipse-tahu/tahu/blob/5736e404889d4b95910613040a99ba79589ffb13/javascript/examples/simple/example.js#L49)

Or here is a brief description:

UDT definition:

```javascript
{
    name: "Template1"
    type: "Template",
    value: {
      isDefinition: true,
      metrics: [/* UDT members */],
    },
}

```

UDT instance:

```javascript
{
    name: "TemplateInstance1"
    type: "Template",
    value: {
      templateRef: "Template1",
      isDefinition: false,
      metrics: [/* UDT members */]],
    },
}

```

---

<div class="post-metadata">

**Author:** ![r2s\_6](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@r2s\_6](https://forum.inductiveautomation.com/u/r2s_6)\
**Post date:** [April 17, 2025, 6:01pm UTC](https://forum.inductiveautomation.com/t/how-to-create-sparkplug-udt-definitions-using-node-red-nodejs/105192/3 "2025-04-17T18:01:02Z")

</div>

Thanks for your help. I will do the tests and post the results here, whether successful or not.
