# How to generate unique node ID when creating a flow via node-red API

**URL:** <https://discourse.nodered.org/t/how-to-generate-unique-node-id-when-creating-a-flow-via-node-red-api/18237>\
**Category:** General\
**Created:** [21 November 2019 13:30 UTC](https://discourse.nodered.org/t/how-to-generate-unique-node-id-when-creating-a-flow-via-node-red-api/18237 "2019-11-21T13:30:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![POne](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@POne](https://discourse.nodered.org/u/POne)\
**Post date:** [14 May 2020 14:30 UTC](https://discourse.nodered.org/t/how-to-generate-unique-node-id-when-creating-a-flow-via-node-red-api/18237/2 "2020-05-14T14:30:38Z")

</div>

Hi Charlotte, I had the same problem as you. I have found that IDs are generated with this JScript function **(1 + Math.random () \* 4294967295) .toString (16);**

You can find it on file @node-red/util/lib/util.js, function generateId()

I hope it is useful for you  
Ciao

---

_[View the full topic](https://discourse.nodered.org/t/how-to-generate-unique-node-id-when-creating-a-flow-via-node-red-api/18237)._
