Is there any existing api to clean up the closed workflow history before retention period?
There is no direct api that I am aware of. You could change namespace retention period but that would affect executions that complete after this update, not before.
What’s specific need for this? What persistence store do you use?
One thing you maybe be able to use is tctl admin commands, for example:
tctl adm wf delete -h