Tag api documentation is here
Don’t forget about group tags you probably want to do it at the same time.
The way I would approach I would create some sort of reference table
Where I would say “this alias path this tag” i.e.
And then iterate through this table getting documents by alias path and tagging them
It is more the question how you are going to use these tags later on.