Attaching a value change script to my managed tag from within Java at startup of module

I create managed tags that are set at some point and want to trigger a script when the value changes. How do I attach a a script to my managed tag when it is created by my module?
I got as far as getting tag config and trying to add WellKnownTag.EventScripts with a defined BasicTagEventScript, but don’t understand the validId and how to place a script into the object.
An example?