Changing the ids of folders from script

Due to copying items (with ims.zip), I have some objects with spaces in their ids. For some reason, I am not able to change the ids of folders from a script. If I run this script twice, brain.id is still 'some thing' instead of 'some-thing'. obj.id is (correct) 'some-thing', but even clearing and rebuilding the catalog does not seem to work.

Are there any other (better) ways of doing this, should I use plone.api.rename or something similar instead?

(PS: the content was originally added on another instance (but with same versions/add-ons)

#python 3
#from plone.indexer import indexer

from zope.component.hooks import setSite
from zope.lifecycleevent import modified
import transaction

setSite(app['mysite'])
brains = app.mysite.portal_catalog(portal_type="Folder")

if brains:
	print('Total  objects: ')
	print(len(brains))
	for brain in brains:
		
		if ' '  in brain.id:
             obj = brain.getObject()
			 ide = obj.id.replace(' ', '-')
             print(ide)
			 obj.id = ide #update don't use this
             api.content.rename(obj=obj, new_id=ide) #update, use this
			 
		 
			 #tried all combinations of this
			 #obj.reindexObject(idxs=['id'])
			 #obj.reindexObject(idxs=['getId'])
			 #obj.reindexObject()
			 #obj.reindexObject(idxs=['modified'])
			 obj.reindexObject()
			 #and this outside of loop (and also inside, 
             #just to be sure)

	transaction.commit()

Why don‘t use the offcial rename() method instead of hacking something together?

The only docs I found looked like they were for Archetype. Where do I find docs (is the synax obj.rename (or do I need to rename it 'from the parent folder' ?

What has plone.api to do with Archetypes vs. DX?
Nothing. rename() is the official method. That’s why is is called plone.api