# Generate a UUID in Painless

**URL:** <https://discuss.elastic.co/t/generate-a-uuid-in-painless/191017>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [July 17, 2019, 1:50pm UTC](https://discuss.elastic.co/t/generate-a-uuid-in-painless/191017 "2019-07-17T13:50:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fluffierbump](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@fluffierbump](https://discuss.elastic.co/u/fluffierbump)\
**Post date:** [July 17, 2019, 1:50pm UTC](https://discuss.elastic.co/t/generate-a-uuid-in-painless/191017/1 "2019-07-17T13:50:39Z")

</div>

Use case: I need to generate a UUID in a watcher transform script to use in an API call which creates an event on another system with a UUID, which I can also write to an ES doc so that I can link the events in the other system with documents in ES.

I know that UUID.randomuuid() exists in Groovy but is not whitelisted in Painless. Is there an alternative that I can use to create a UUID?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 14, 2019, 1:50pm UTC](https://discuss.elastic.co/t/generate-a-uuid-in-painless/191017/2 "2019-08-14T13:50:47Z")

</div>

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