Support in the Revit API is very limited for Legends, there isn’t a way to directly create a legend.
But if you want to place them on sheets, use the Add Viewport Component.