Create TextNote

doc   = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
active_view  = doc.ActiveView

# ARGUMENTS
text_type_id = FilteredElementCollector(doc).OfClass(TextNoteType).FirstElementId()
pt           = XYZ(0,0,0)
text         = 'Hello BIM World!'

# CREATE TEXT NOTE
TextNote.Create(doc, active_view.Id, pt, text, text_type_id)


legend = ... #Get Legend View

def create_text(view, pt, text, typeId=None):
    """Create a TextNote"""
    if not typeId or typeId == ElementId(-1):
        typeId = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType)
    text_note = TextNote.Create(doc, view.Id, pt, text, typeId)
    return text_note

#📍 Starting Coordinate
X,Y = 0,0

#🖼️ Create Legend Elements
title = create_text(legend, XYZ(X,Y,0), 'Apartments Legend:')

⌨️ Happy Coding!
Erik Frits